#include <lunaix/sched.h>
#include <lunaix/kpreempt.h>
#include <lunaix/kcmd.h>
+#include <lunaix/kthread.h>
#include <klibc/string.h>
}
}
+static void
+__thread_cleaner()
+{
+ while (true)
+ {
+ cleanup_detached_threads();
+ kthread_sleep(30);
+ }
+}
+
+
/**
* @brief LunaixOS的内核进程,该进程永远为可执行。
*
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();
}
}