diff --git a/lab5/c/include/oscos/sched.h b/lab5/c/include/oscos/sched.h index bd48e328c..2e92b5284 100644 --- a/lab5/c/include/oscos/sched.h +++ b/lab5/c/include/oscos/sched.h @@ -140,8 +140,8 @@ void schedule(void); /// scheduler. void suspend_to_wait_queue(thread_list_node_t *wait_queue); -/// \brief Adds every thread in the given wait queue to the run queue. -void add_all_threads_to_run_queue(thread_list_node_t *wait_queue); +/// \brief Wake up every thread in the given wait queue. +void wake_up_all_threads_in_wait_queue(thread_list_node_t *wait_queue); /// \brief Gets a process by its PID. process_t *get_process_by_id(size_t pid); diff --git a/lab5/c/src/sched/sched.c b/lab5/c/src/sched/sched.c index ebcf79e27..3f937739e 100644 --- a/lab5/c/src/sched/sched.c +++ b/lab5/c/src/sched/sched.c @@ -542,9 +542,10 @@ void suspend_to_wait_queue(thread_list_node_t *const wait_queue) { _suspend_to_wait_queue(wait_queue); } -void add_all_threads_to_run_queue(thread_list_node_t *const wait_queue) { +void wake_up_all_threads_in_wait_queue(thread_list_node_t *const wait_queue) { thread_t *thread; while ((thread = _remove_first_thread_from_queue(wait_queue))) { + thread->status.is_waiting = false; _add_thread_to_run_queue(thread); } } diff --git a/lab5/c/src/xcpt/syscall/uart-read.c b/lab5/c/src/xcpt/syscall/uart-read.c index e4646bc77..12e00d39c 100644 --- a/lab5/c/src/xcpt/syscall/uart-read.c +++ b/lab5/c/src/xcpt/syscall/uart-read.c @@ -28,8 +28,8 @@ ssize_t sys_uart_read(char buf[const], const size_t size) { thread_t *const curr_thread = current_thread(); - console_notify_read_ready((void (*)(void *))add_all_threads_to_run_queue, - &_wait_queue); + console_notify_read_ready( + (void (*)(void *))wake_up_all_threads_in_wait_queue, &_wait_queue); suspend_to_wait_queue(&_wait_queue); XCPT_MASK_ALL(); diff --git a/lab5/c/src/xcpt/syscall/uart-write.c b/lab5/c/src/xcpt/syscall/uart-write.c index aa23d2722..d612ea85e 100644 --- a/lab5/c/src/xcpt/syscall/uart-write.c +++ b/lab5/c/src/xcpt/syscall/uart-write.c @@ -27,8 +27,8 @@ size_t sys_uart_write(const char buf[const], const size_t size) { thread_t *const curr_thread = current_thread(); - console_notify_write_ready((void (*)(void *))add_all_threads_to_run_queue, - &_wait_queue); + console_notify_write_ready( + (void (*)(void *))wake_up_all_threads_in_wait_queue, &_wait_queue); suspend_to_wait_queue(&_wait_queue); XCPT_MASK_ALL(); diff --git a/lab6/c/include/oscos/sched.h b/lab6/c/include/oscos/sched.h index 560256f2c..d3d710b84 100644 --- a/lab6/c/include/oscos/sched.h +++ b/lab6/c/include/oscos/sched.h @@ -130,8 +130,8 @@ void schedule(void); /// scheduler. void suspend_to_wait_queue(thread_list_node_t *wait_queue); -/// \brief Adds every thread in the given wait queue to the run queue. -void add_all_threads_to_run_queue(thread_list_node_t *wait_queue); +/// \brief Wake up every thread in the given wait queue. +void wake_up_all_threads_in_wait_queue(thread_list_node_t *wait_queue); /// \brief Gets a process by its PID. process_t *get_process_by_id(size_t pid); diff --git a/lab6/c/src/sched/sched.c b/lab6/c/src/sched/sched.c index 42ec4c02a..356f3db36 100644 --- a/lab6/c/src/sched/sched.c +++ b/lab6/c/src/sched/sched.c @@ -190,10 +190,6 @@ void thread_exit(void) { XCPT_MASK_ALL(); - // Workaround of a weird bug where the current thread still remains on the run - // queue. - _remove_thread_from_queue(curr_thread); - if (curr_process) { rb_delete(&_processes, &curr_process->id, (int (*)(const void *, const void *, @@ -456,9 +452,10 @@ void suspend_to_wait_queue(thread_list_node_t *const wait_queue) { _suspend_to_wait_queue(wait_queue); } -void add_all_threads_to_run_queue(thread_list_node_t *const wait_queue) { +void wake_up_all_threads_in_wait_queue(thread_list_node_t *const wait_queue) { thread_t *thread; while ((thread = _remove_first_thread_from_queue(wait_queue))) { + thread->status.is_waiting = false; _add_thread_to_run_queue(thread); } } diff --git a/lab6/c/src/xcpt/syscall/uart-read.c b/lab6/c/src/xcpt/syscall/uart-read.c index e4646bc77..12e00d39c 100644 --- a/lab6/c/src/xcpt/syscall/uart-read.c +++ b/lab6/c/src/xcpt/syscall/uart-read.c @@ -28,8 +28,8 @@ ssize_t sys_uart_read(char buf[const], const size_t size) { thread_t *const curr_thread = current_thread(); - console_notify_read_ready((void (*)(void *))add_all_threads_to_run_queue, - &_wait_queue); + console_notify_read_ready( + (void (*)(void *))wake_up_all_threads_in_wait_queue, &_wait_queue); suspend_to_wait_queue(&_wait_queue); XCPT_MASK_ALL(); diff --git a/lab6/c/src/xcpt/syscall/uart-write.c b/lab6/c/src/xcpt/syscall/uart-write.c index aa23d2722..d612ea85e 100644 --- a/lab6/c/src/xcpt/syscall/uart-write.c +++ b/lab6/c/src/xcpt/syscall/uart-write.c @@ -27,8 +27,8 @@ size_t sys_uart_write(const char buf[const], const size_t size) { thread_t *const curr_thread = current_thread(); - console_notify_write_ready((void (*)(void *))add_all_threads_to_run_queue, - &_wait_queue); + console_notify_write_ready( + (void (*)(void *))wake_up_all_threads_in_wait_queue, &_wait_queue); suspend_to_wait_queue(&_wait_queue); XCPT_MASK_ALL(); diff --git a/lab7/c/include/oscos/sched.h b/lab7/c/include/oscos/sched.h index bc77420e6..403efed6a 100644 --- a/lab7/c/include/oscos/sched.h +++ b/lab7/c/include/oscos/sched.h @@ -135,8 +135,8 @@ void schedule(void); /// scheduler. void suspend_to_wait_queue(thread_list_node_t *wait_queue); -/// \brief Adds every thread in the given wait queue to the run queue. -void add_all_threads_to_run_queue(thread_list_node_t *wait_queue); +/// \brief Wake up every thread in the given wait queue. +void wake_up_all_threads_in_wait_queue(thread_list_node_t *wait_queue); /// \brief Gets a process by its PID. process_t *get_process_by_id(size_t pid); diff --git a/lab7/c/src/sched/sched.c b/lab7/c/src/sched/sched.c index c9c3e1f17..c387d00bf 100644 --- a/lab7/c/src/sched/sched.c +++ b/lab7/c/src/sched/sched.c @@ -190,10 +190,6 @@ void thread_exit(void) { XCPT_MASK_ALL(); - // Workaround of a weird bug where the current thread still remains on the run - // queue. - _remove_thread_from_queue(curr_thread); - if (curr_process) { rb_delete(&_processes, &curr_process->id, (int (*)(const void *, const void *, @@ -470,9 +466,10 @@ void suspend_to_wait_queue(thread_list_node_t *const wait_queue) { _suspend_to_wait_queue(wait_queue); } -void add_all_threads_to_run_queue(thread_list_node_t *const wait_queue) { +void wake_up_all_threads_in_wait_queue(thread_list_node_t *const wait_queue) { thread_t *thread; while ((thread = _remove_first_thread_from_queue(wait_queue))) { + thread->status.is_waiting = false; _add_thread_to_run_queue(thread); } } diff --git a/lab7/c/src/xcpt/syscall/uart-read.c b/lab7/c/src/xcpt/syscall/uart-read.c index e4646bc77..12e00d39c 100644 --- a/lab7/c/src/xcpt/syscall/uart-read.c +++ b/lab7/c/src/xcpt/syscall/uart-read.c @@ -28,8 +28,8 @@ ssize_t sys_uart_read(char buf[const], const size_t size) { thread_t *const curr_thread = current_thread(); - console_notify_read_ready((void (*)(void *))add_all_threads_to_run_queue, - &_wait_queue); + console_notify_read_ready( + (void (*)(void *))wake_up_all_threads_in_wait_queue, &_wait_queue); suspend_to_wait_queue(&_wait_queue); XCPT_MASK_ALL(); diff --git a/lab7/c/src/xcpt/syscall/uart-write.c b/lab7/c/src/xcpt/syscall/uart-write.c index aa23d2722..d612ea85e 100644 --- a/lab7/c/src/xcpt/syscall/uart-write.c +++ b/lab7/c/src/xcpt/syscall/uart-write.c @@ -27,8 +27,8 @@ size_t sys_uart_write(const char buf[const], const size_t size) { thread_t *const curr_thread = current_thread(); - console_notify_write_ready((void (*)(void *))add_all_threads_to_run_queue, - &_wait_queue); + console_notify_write_ready( + (void (*)(void *))wake_up_all_threads_in_wait_queue, &_wait_queue); suspend_to_wait_queue(&_wait_queue); XCPT_MASK_ALL(); diff --git a/lab8/c/include/oscos/sched.h b/lab8/c/include/oscos/sched.h index bc77420e6..403efed6a 100644 --- a/lab8/c/include/oscos/sched.h +++ b/lab8/c/include/oscos/sched.h @@ -135,8 +135,8 @@ void schedule(void); /// scheduler. void suspend_to_wait_queue(thread_list_node_t *wait_queue); -/// \brief Adds every thread in the given wait queue to the run queue. -void add_all_threads_to_run_queue(thread_list_node_t *wait_queue); +/// \brief Wake up every thread in the given wait queue. +void wake_up_all_threads_in_wait_queue(thread_list_node_t *wait_queue); /// \brief Gets a process by its PID. process_t *get_process_by_id(size_t pid); diff --git a/lab8/c/src/sched/sched.c b/lab8/c/src/sched/sched.c index c9c3e1f17..c387d00bf 100644 --- a/lab8/c/src/sched/sched.c +++ b/lab8/c/src/sched/sched.c @@ -190,10 +190,6 @@ void thread_exit(void) { XCPT_MASK_ALL(); - // Workaround of a weird bug where the current thread still remains on the run - // queue. - _remove_thread_from_queue(curr_thread); - if (curr_process) { rb_delete(&_processes, &curr_process->id, (int (*)(const void *, const void *, @@ -470,9 +466,10 @@ void suspend_to_wait_queue(thread_list_node_t *const wait_queue) { _suspend_to_wait_queue(wait_queue); } -void add_all_threads_to_run_queue(thread_list_node_t *const wait_queue) { +void wake_up_all_threads_in_wait_queue(thread_list_node_t *const wait_queue) { thread_t *thread; while ((thread = _remove_first_thread_from_queue(wait_queue))) { + thread->status.is_waiting = false; _add_thread_to_run_queue(thread); } } diff --git a/lab8/c/src/xcpt/syscall/uart-read.c b/lab8/c/src/xcpt/syscall/uart-read.c index e4646bc77..12e00d39c 100644 --- a/lab8/c/src/xcpt/syscall/uart-read.c +++ b/lab8/c/src/xcpt/syscall/uart-read.c @@ -28,8 +28,8 @@ ssize_t sys_uart_read(char buf[const], const size_t size) { thread_t *const curr_thread = current_thread(); - console_notify_read_ready((void (*)(void *))add_all_threads_to_run_queue, - &_wait_queue); + console_notify_read_ready( + (void (*)(void *))wake_up_all_threads_in_wait_queue, &_wait_queue); suspend_to_wait_queue(&_wait_queue); XCPT_MASK_ALL(); diff --git a/lab8/c/src/xcpt/syscall/uart-write.c b/lab8/c/src/xcpt/syscall/uart-write.c index aa23d2722..d612ea85e 100644 --- a/lab8/c/src/xcpt/syscall/uart-write.c +++ b/lab8/c/src/xcpt/syscall/uart-write.c @@ -27,8 +27,8 @@ size_t sys_uart_write(const char buf[const], const size_t size) { thread_t *const curr_thread = current_thread(); - console_notify_write_ready((void (*)(void *))add_all_threads_to_run_queue, - &_wait_queue); + console_notify_write_ready( + (void (*)(void *))wake_up_all_threads_in_wait_queue, &_wait_queue); suspend_to_wait_queue(&_wait_queue); XCPT_MASK_ALL();