Skip to content

Commit

Permalink
Merge branch 'lab8' into 310551038
Browse files Browse the repository at this point in the history
  • Loading branch information
abt8601 committed Jun 30, 2023
2 parents 1b5db3c + a79e5fc commit 306012e
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 40 deletions.
4 changes: 2 additions & 2 deletions lab5/c/include/oscos/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion lab5/c/src/sched/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lab5/c/src/xcpt/syscall/uart-read.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions lab5/c/src/xcpt/syscall/uart-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions lab6/c/include/oscos/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 2 additions & 5 deletions lab6/c/src/sched/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *,
Expand Down Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lab6/c/src/xcpt/syscall/uart-read.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions lab6/c/src/xcpt/syscall/uart-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions lab7/c/include/oscos/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 2 additions & 5 deletions lab7/c/src/sched/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *,
Expand Down Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lab7/c/src/xcpt/syscall/uart-read.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions lab7/c/src/xcpt/syscall/uart-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions lab8/c/include/oscos/sched.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 2 additions & 5 deletions lab8/c/src/sched/sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 *,
Expand Down Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions lab8/c/src/xcpt/syscall/uart-read.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions lab8/c/src/xcpt/syscall/uart-write.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 306012e

Please sign in to comment.