From: Simon Kuenzer Date: Wed, 20 Apr 2022 21:35:58 +0000 (+0200) Subject: Adopt to refactored scheduling API (lib/uksched) X-Git-Tag: RELEASE-0.11.0~6 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=08fb02396c978dd47834b50374f0578063dcfac2;p=unikraft%2Flibs%2Flwip.git Adopt to refactored scheduling API (lib/uksched) Signed-off-by: Simon Kuenzer Reviewed-by: Eduard Vintilă Reviewed-by: Razvan Deaconescu Approved-by: Razvan Deaconescu Tested-by: Unikraft CI GitHub-Closes: #19 --- diff --git a/threads.c b/threads.c index fb5fde1..ea7f008 100644 --- a/threads.c +++ b/threads.c @@ -46,12 +46,21 @@ 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; } diff --git a/uknetdev.c b/uknetdev.c index 091370a..ee6284c 100644 --- a/uknetdev.c +++ b/uknetdev.c @@ -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;