]> xenbits.xensource.com Git - unikraft/libs/lwip.git/commitdiff
Adopt to refactored scheduling API (lib/uksched)
authorSimon Kuenzer <simon.kuenzer@neclab.eu>
Wed, 20 Apr 2022 21:35:58 +0000 (23:35 +0200)
committerUnikraft <monkey@unikraft.io>
Wed, 23 Nov 2022 20:34:47 +0000 (20:34 +0000)
Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #19

threads.c
uknetdev.c

index fb5fde11f2e8896fc678e37b250f1215ee2d4233..ea7f008137105790eb4be7ae367a72a13557a570 100644 (file)
--- a/threads.c
+++ b/threads.c
 sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg,
                            int stacksize, int prio __unused)
 {
+       struct uk_sched *s = uk_sched_current();
        struct uk_thread *t;
 
-       if (stacksize > (__ssz) __STACK_SIZE) {
-               UK_CRASH("Can't create lwIP thread: stack size %u is too large (> %llu). Dying...\n",
-                        stacksize, __STACK_SIZE);
+       UK_ASSERT(s);
+
+       t = uk_sched_thread_create_fn1(s,
+                                      (uk_thread_fn1_t) thread, arg,
+                                      (size_t) stacksize,
+                                      false,
+                                      false,
+                                      name,
+                                      NULL, NULL);
+       if (!t) {
+               uk_pr_err("Failed to create lwIP thread '%s'\n", name);
+               return NULL;
        }
-       t = uk_thread_create(name, thread, arg);
        return t;
 }
index 091370a545bfeda2ea479ea49974ddcfbba0ac76..ee6284c728eea92e61ae103f9ea2e49133f2c7f1 100644 (file)
@@ -327,7 +327,7 @@ void uknetdev_poll_all(void)
 
 #else /* CONFIG_LWIP_NOTHREADS */
 
-static void _poll_netif(void *arg)
+static __noreturn void _poll_netif(void *arg)
 {
        struct netif *nf = (struct netif *) arg;
 
@@ -384,11 +384,11 @@ static void uknetdev_updown(struct netif *nf)
                                        ("%s: Poll receive enabled\n",
                                         __func__));
                        /* Create a thread */
-                       lwip_data->sched = uk_sched_get_default();
+                       lwip_data->sched = uk_sched_current();
                        UK_ASSERT(lwip_data->sched);
                        lwip_data->poll_thread =
-                               uk_sched_thread_create(lwip_data->sched, NULL,
-                                                      NULL, _poll_netif, nf);
+                               uk_sched_thread_create(lwip_data->sched,
+                                                      _poll_netif, nf, NULL);
 #else /* CONFIG_HAVE_SCHED */
                        uk_pr_warn("The netdevice does not support interrupt. Ensure the netdevice is polled to receive packets");
 #endif /* CONFIG_HAVE_SCHED */
@@ -520,7 +520,7 @@ err_t uknetdev_init(struct netif *nf)
        rxq_conf.callback = uknetdev_input;
        rxq_conf.callback_cookie = nf;
 #ifdef CONFIG_LIBUKNETDEV_DISPATCHERTHREADS
-       rxq_conf.s = uk_sched_get_default();
+       rxq_conf.s = uk_sched_current();
        if (!rxq_conf.s)
                return ERR_IF;