diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-08-07 20:43:54 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-08-07 20:43:54 +0200 |
commit | 1f9b8f0e7c732ec70a77db7eaf22071f43ef46e9 (patch) | |
tree | 67a74215548bce23ed0021555aa8ed37a77514b4 /Kernel/Scheduler.h | |
parent | 2e416b1b872259442fe596828b5bae61969791a7 (diff) | |
download | serenity-1f9b8f0e7c732ec70a77db7eaf22071f43ef46e9.zip |
Kernel: Don't create Function objects in the scheduling code
Each Function is a heap allocation, so let's make an effort to avoid
doing that during scheduling. Because of header dependencies, I had to
put the runnables iteration helpers in Thread.h, which is a bit meh but
at least this cuts out all the kmalloc() traffic in pick_next().
Diffstat (limited to 'Kernel/Scheduler.h')
-rw-r--r-- | Kernel/Scheduler.h | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/Kernel/Scheduler.h b/Kernel/Scheduler.h index 5363e00d9f..bbde794c1c 100644 --- a/Kernel/Scheduler.h +++ b/Kernel/Scheduler.h @@ -8,11 +8,13 @@ class Process; class Thread; struct RegisterDump; +struct SchedulerData; extern Thread* current; extern Thread* g_last_fpu_thread; extern Thread* g_finalizer; extern u64 g_uptime; +extern SchedulerData* g_scheduler_data; class Scheduler { public: @@ -30,28 +32,14 @@ public: static void beep(); template<typename Callback> - static inline IterationDecision for_each_runnable(Callback callback) - { - return for_each_runnable_func([callback](Thread& thread) { - return callback(thread); - }); - } + static inline IterationDecision for_each_runnable(Callback); template<typename Callback> - static inline IterationDecision for_each_nonrunnable(Callback callback) - { - return for_each_nonrunnable_func([callback](Thread& thread) { - return callback(thread); - }); - } + static inline IterationDecision for_each_nonrunnable(Callback); static void init_thread(Thread& thread); static void update_state_for_thread(Thread& thread); private: static void prepare_for_iret_to_new_process(); - static IterationDecision for_each_runnable_func(Function<IterationDecision(Thread&)>&& callback); - static IterationDecision for_each_nonrunnable_func(Function<IterationDecision(Thread&)>&& callback); - }; - |