mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 15:08:21 +00:00
scheduler: little bit of cleanup
This commit is contained in:
@@ -10,7 +10,7 @@ typedef struct {
|
|||||||
|
|
||||||
int bitmap_init(bitmap_t *bitmap, size_t size);
|
int bitmap_init(bitmap_t *bitmap, size_t size);
|
||||||
void bitmap_set(bitmap_t *bitmap, long idx, int v);
|
void bitmap_set(bitmap_t *bitmap, long idx, int v);
|
||||||
long bitmap_find_first_set(bitmap_t *bitmap, long start_offset);
|
long bitmap_find_first_set(bitmap_t *bitmap);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ typedef struct cpu_t {
|
|||||||
sched_run_queue_t idle_queue;
|
sched_run_queue_t idle_queue;
|
||||||
spinlock_t sched_lock;
|
spinlock_t sched_lock;
|
||||||
|
|
||||||
long calendar_ticks;
|
|
||||||
timerentry_t calendar_tick_timer_entry;
|
timerentry_t calendar_tick_timer_entry;
|
||||||
|
|
||||||
// architecture specific, does not need to be exposed
|
// architecture specific, does not need to be exposed
|
||||||
|
|||||||
@@ -22,13 +22,12 @@ void bitmap_set(bitmap_t *bitmap, long idx, int v) {
|
|||||||
bitmap->data[idx / sizeof(*bitmap->data)] &= ~bit;
|
bitmap->data[idx / sizeof(*bitmap->data)] &= ~bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO fix start offset search
|
long bitmap_find_first_set(bitmap_t *bitmap) {
|
||||||
long bitmap_find_first_set(bitmap_t *bitmap, long start_offset) {
|
|
||||||
size_t loop_size = ROUND_UP(bitmap->size, sizeof(*bitmap->data)) / sizeof(*bitmap->data);
|
size_t loop_size = ROUND_UP(bitmap->size, sizeof(*bitmap->data)) / sizeof(*bitmap->data);
|
||||||
|
|
||||||
long offset = -1;
|
long offset = -1;
|
||||||
|
|
||||||
for (size_t i = start_offset; i < loop_size; ++i) {
|
for (size_t i = 0; i < loop_size; ++i) {
|
||||||
if (bitmap->data[i] == 0)
|
if (bitmap->data[i] == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ static void insert_in_run_queue(sched_run_queue_t *run_queue, thread_t *thread)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static thread_t *pop_from_run_queue(sched_run_queue_t *run_queue) {
|
static thread_t *pop_from_run_queue(sched_run_queue_t *run_queue) {
|
||||||
long idx = bitmap_find_first_set(&run_queue->thread_bitmap, 0);
|
long idx = bitmap_find_first_set(&run_queue->thread_bitmap);
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -363,7 +363,7 @@ void sched_ap_entry() {
|
|||||||
__assert(current_cpu()->reschedule_isr);
|
__assert(current_cpu()->reschedule_isr);
|
||||||
|
|
||||||
timer_insert(current_cpu()->timer, ¤t_cpu()->schedtimerentry, reschedule_timer_dpc, NULL, QUANTUM_US, true);
|
timer_insert(current_cpu()->timer, ¤t_cpu()->schedtimerentry, reschedule_timer_dpc, NULL, QUANTUM_US, true);
|
||||||
timer_insert(current_cpu()->timer, ¤t_cpu()->calendar_tick_timer_entry, sched_calendar_tick, NULL, 1000, true);
|
timer_insert(current_cpu()->timer, ¤t_cpu()->calendar_tick_timer_entry, sched_calendar_tick, NULL, 10000, true);
|
||||||
timer_resume(current_cpu()->timer);
|
timer_resume(current_cpu()->timer);
|
||||||
sched_stop_current_thread();
|
sched_stop_current_thread();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user