X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/ec4ff182252b6d7b3cb81f4fa783c5348a6c30fd..refs/heads/cor/lrud:/lunaix-os/kernel/lunad.c diff --git a/lunaix-os/kernel/lunad.c b/lunaix-os/kernel/lunad.c index b808022..25ce7d2 100644 --- a/lunaix-os/kernel/lunad.c +++ b/lunaix-os/kernel/lunad.c @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -84,6 +85,17 @@ lunad_do_usr() { } } +static void +__thread_cleaner() +{ + while (true) + { + cleanup_detached_threads(); + kthread_sleep(30); + } +} + + /** * @brief LunaixOS的内核进程,该进程永远为可执行。 * @@ -95,23 +107,11 @@ lunad_do_usr() { void lunad_main() { - spawn_kthread((ptr_t)init_platform); - - /* - NOTE Kernel preemption after this point. + kthread_spawn((ptr_t)init_platform); + kthread_spawn((ptr_t)__thread_cleaner); - More specifically, it is not a real kernel preemption (as in preemption - happened at any point of kernel, except those marked explicitly). - In Lunaix, things are designed in an non-preemptive fashion, we implement - kernel preemption the other way around: only selected kernel functions which, - of course, with great care of preemptive assumption, will goes into kernel - thread (which is preemptive!) - */ - - set_preemption(); while (1) { - cleanup_detached_threads(); yield_current(); } }