From aece33c73bb91eb627ecc1f47f7eabaf37522d34 Mon Sep 17 00:00:00 2001 From: Martin Eyben Date: Tue, 25 Mar 2025 00:24:33 +0100 Subject: [PATCH] fix: typo --- src/thread/thread.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/thread/thread.c b/src/thread/thread.c index c6a2d11..70a8425 100644 --- a/src/thread/thread.c +++ b/src/thread/thread.c @@ -16,8 +16,8 @@ #define WAS_ALLOCATED(entry) (entry->status & ALLOCATED) #define WAITING 0x4 #define IS_WAITING(entry) (entry->status & WAITING) -#define GET_WAITING_THREAD(entry) ((struct context_entry*)entry->waiting) -#define IS_WAITING_THREAD_FINISHED(entry) (GET_WAITING_THREAD(entry)->status & FINISHED) +#define GET_WAITED_THREAD(entry) ((struct context_entry*)entry->waiting) +#define IS_WAITED_THREAD_FINISHED(entry) (GET_WAITED_THREAD(entry)->status & FINISHED) #define WAITED 0x8 #define IS_WAITED(entry) (entry->status & WAITED) @@ -35,8 +35,8 @@ struct context_entry { link; // Use to navigate inside the list ucontext_t context; thread_t id; - void *waiting; - void* retvalue; + void *waiting; // the thread that the entry is waiting for + void *retvalue; // retun value or if the thread is waited, the id of the thread that wait for it int valgrind_id; char status; char stack[STACK_SIZE]; @@ -66,7 +66,7 @@ int thread_yield(void) return -1; } TAILQ_REMOVE(&head, first, link); - if (!IS_FINISHED(running) && !(IS_WAITING(running) && !IS_WAITING_THREAD_FINISHED(running))) { + if (!IS_FINISHED(running) && !(IS_WAITING(running) && !IS_WAITED_THREAD_FINISHED(running))) { TAILQ_INSERT_TAIL(&head, running, link); } TRACE("PICKING %p (previous was %p)", first->id, running->id); @@ -140,17 +140,17 @@ int thread_join(thread_t thread, void** retval) TRACE("Join thread %p", thread); struct context_entry* entry = thread; // Check if the target is not already waited by another - if (IS_WAITED(entry) || IS_WAITING(entry) && GET_WAITING_THREAD(entry) == running) { + if (IS_WAITED(entry) || IS_WAITING(entry) && GET_WAITED_THREAD(entry) == running) { return -1; } if (!IS_FINISHED(entry)) { // Use status to be in waiting state running->status |= WAITING; - // Use retvalue to share which thread we are currently waiting for running->waiting = entry; // Mark the waited thread as waited to not be waited by any other thread. entry->status |= WAITED; + // Use retvalue to share which thread is currently waiting for this thread entry->retvalue = running; do { thread_yield();