@@ -36,49 +36,54 @@ namespace sched
3636
3737export namespace sched
3838{
39- struct cfs_run_queue_t
39+ struct run_queue_t
4040 {
41+ lib::spinlock lock;
42+
4143 lib::rbtree<
42- entity_t , &entity_t ::hook,
44+ thread_t , &thread_t ::hook,
4345 compare<
44- entity_t ,
46+ thread_t ,
4547 std::uint64_t ,
46- &entity_t ::vruntime
48+ &thread_t ::vruntime
4749 >
4850 > queue;
4951
50- entity_t *current;
51-
5252 std::uint64_t total_weight;
5353 std::uint64_t _min_vruntime;
5454
55- inline std::size_t num_entities () const
56- {
57- return queue.size ();
58- }
55+ std::size_t cpu_idx;
56+ std::uint64_t nr_running;
5957
60- cfs_run_queue_t ()
61- : queue { }, current { nullptr }, total_weight { 0 }, _min_vruntime { 0 } { }
58+ thread_t *current;
59+ thread_t *idle;
6260
63- // enqueue when entity becomes runnable
64- void enqueue ( entity_t *entity);
65- // dequeue when entity leaves runnable state
66- void dequeue ( entity_t *entity) ;
61+ std:: uint64_t nr_switches;
62+
63+ std:: uint64_t load_update;
64+ std:: uint64_t load_active ;
6765
68- // pick the next entity to run (least amount of vruntime)
66+ bool needs_resched;
67+
68+ // enqueue when thread becomes runnable
69+ void enqueue (thread_t *thread);
70+ // dequeue when thread leaves runnable state
71+ void dequeue (thread_t *thread);
72+
73+ // pick the next thread to run (least amount of vruntime)
6974 // nullptr if empty
70- entity_t *pick_next ();
75+ thread_t *pick_next ();
7176
72- // update current entity vruntime
77+ // update current thread vruntime
7378 void update_current (std::uint64_t now);
7479
7580 // adjust vruntime
76- void adjust (entity_t *entity , bool initial);
81+ void adjust (thread_t *thread , bool initial);
7782
78- // check if current should be preempted with entity
79- bool check_preempt_wakeup (entity_t *entity );
83+ // check if current should be preempted with thread
84+ bool check_preempt_wakeup (thread_t *thread );
8085
81- // calculate fair timeslice for an entity
86+ // calculate fair timeslice for a thread
8287 std::uint64_t calc_timeslice (std::uint64_t weight);
8388
8489 std::uint64_t calc_vruntime (
@@ -88,24 +93,4 @@ export namespace sched
8893
8994 void update_min_vruntime ();
9095 };
91-
92- struct run_queue_t
93- {
94- lib::spinlock_preempt lock;
95-
96- std::size_t cpu_idx;
97- std::uint64_t nr_running;
98-
99- thread_t *current;
100- thread_t *idle;
101-
102- cfs_run_queue_t cfs;
103-
104- std::uint64_t nr_switches;
105-
106- std::uint64_t load_update;
107- std::uint64_t load_active;
108-
109- bool needs_resched;
110- };
11196} // export namespace sched
0 commit comments