Skip to content

Commit

Permalink
credits -> cpu_credits
Browse files Browse the repository at this point in the history
  • Loading branch information
phaubertin committed Nov 21, 2024
1 parent 6b6ba4a commit 7054e58
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/kernel/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ struct thread_t {
machine_thread_t machine_thread;
list_node_t thread_list;
thread_state_t state;
int credits;
int cpu_credits;
process_t *process;
struct thread_t *sender;
struct thread_t *awaiter;
Expand Down
2 changes: 1 addition & 1 deletion kernel/domain/entities/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void thread_prepare(thread_t *thread, const thread_params_t *params) {

thread->awaiter = NULL;
thread->state = THREAD_STATE_STARTING;
thread->credits = 0;
thread->cpu_credits = 0;

spin_unlock(&thread->await_lock);

Expand Down
10 changes: 5 additions & 5 deletions kernel/domain/services/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ static thread_t *select_next_ready_thread(bool current_can_run) {
panic("No thread to schedule");
}

to->credits += SCHEDULER_BASE_CREDITS;
to->cpu_credits += SCHEDULER_BASE_CREDITS;

return to;
}
Expand All @@ -108,7 +108,7 @@ static void thread_ready_locked(thread_t *thread) {
void reschedule(void) {
thread_t *current = get_current_thread();

if(current->credits > 0) {
if(current->cpu_credits > 0) {
return;
}

Expand All @@ -134,8 +134,8 @@ void reschedule(void) {
void scheduler_tick(void) {
thread_t *current = get_current_thread();

if(current->credits > 0) {
--current->credits;
if(current->cpu_credits > 0) {
--current->cpu_credits;
}
}

Expand Down Expand Up @@ -163,7 +163,7 @@ void yield_current_thread(void) {
/* This defers the thread switch to the next time reschedule() is called,
* which will happen at the end of the system call. */
thread_t *current = get_current_thread();
current->credits = 0;
current->cpu_credits = 0;
}

/**
Expand Down

0 comments on commit 7054e58

Please sign in to comment.