From 6dded99777419746f2dc8ccbc899a1527c121cb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Sun, 24 Jul 2022 16:38:41 +0200 Subject: [PATCH] Kernel+LibC: Report correct scheduling priority limits The priority range was changed several years ago, but the userland-reported limits were just forgotten :skeleyak:. Move the thread priority constants into an API header so that userland can use it properly. --- Kernel/API/POSIX/sched.h | 6 ++++++ Kernel/Thread.h | 7 +------ Userland/Libraries/LibC/sched.cpp | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Kernel/API/POSIX/sched.h b/Kernel/API/POSIX/sched.h index 77dff7fe60..e2e6b978b9 100644 --- a/Kernel/API/POSIX/sched.h +++ b/Kernel/API/POSIX/sched.h @@ -16,6 +16,12 @@ struct sched_param { int sched_priority; }; +#define THREAD_PRIORITY_MIN 1 +#define THREAD_PRIORITY_LOW 10 +#define THREAD_PRIORITY_NORMAL 30 +#define THREAD_PRIORITY_HIGH 50 +#define THREAD_PRIORITY_MAX 99 + #ifdef __cplusplus } #endif diff --git a/Kernel/Thread.h b/Kernel/Thread.h index a6e22826f5..cbb9e9bdd7 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -46,12 +47,6 @@ struct ThreadSpecificData { ThreadSpecificData* self; }; -#define THREAD_PRIORITY_MIN 1 -#define THREAD_PRIORITY_LOW 10 -#define THREAD_PRIORITY_NORMAL 30 -#define THREAD_PRIORITY_HIGH 50 -#define THREAD_PRIORITY_MAX 99 - #define THREAD_AFFINITY_DEFAULT 0xffffffff struct ThreadRegisters { diff --git a/Userland/Libraries/LibC/sched.cpp b/Userland/Libraries/LibC/sched.cpp index 4d1cb46737..914e2eee5b 100644 --- a/Userland/Libraries/LibC/sched.cpp +++ b/Userland/Libraries/LibC/sched.cpp @@ -20,13 +20,13 @@ int sched_yield() // https://pubs.opengroup.org/onlinepubs/9699919799/functions/sched_get_priority_min.html int sched_get_priority_min([[maybe_unused]] int policy) { - return 0; // Idle + return THREAD_PRIORITY_MIN; } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/sched_get_priority_max.html int sched_get_priority_max([[maybe_unused]] int policy) { - return 3; // High + return THREAD_PRIORITY_MAX; } // https://pubs.opengroup.org/onlinepubs/9699919799/functions/sched_setparam.html