From e0c392c16e9023a1b04a724604ff5c8d7cf81c4e Mon Sep 17 00:00:00 2001 From: Mathieu Maret Date: Fri, 16 Feb 2024 00:47:47 +0100 Subject: [PATCH] Fix usleep for small values --- core/thread.c | 2 ++ userspace/main_user.c | 1 + 2 files changed, 3 insertions(+) diff --git a/core/thread.c b/core/thread.c index b83752e..2f74f01 100644 --- a/core/thread.c +++ b/core/thread.c @@ -331,6 +331,8 @@ int threadUsleep(unsigned long usec) current->state = SLEEPING; current->sleepHaveTimeouted = 0; current->jiffiesSleeping = usecs_to_jiffies(usec); + if (!current->jiffiesSleeping) // sleep at least 1 jiffies + current->jiffiesSleeping = 1; next = threadSelectNext(); assert(next != current); diff --git a/userspace/main_user.c b/userspace/main_user.c index c48db8c..6711c9d 100644 --- a/userspace/main_user.c +++ b/userspace/main_user.c @@ -124,6 +124,7 @@ int func_munmap() static void *print_hello(void *arg) { (void)arg; printf("Hello World from thread %lu\n", gettid()); + usleep(100); return NULL; }