fix: typo
This commit is contained in:
parent
25d2e181e1
commit
aece33c73b
@ -16,8 +16,8 @@
|
|||||||
#define WAS_ALLOCATED(entry) (entry->status & ALLOCATED)
|
#define WAS_ALLOCATED(entry) (entry->status & ALLOCATED)
|
||||||
#define WAITING 0x4
|
#define WAITING 0x4
|
||||||
#define IS_WAITING(entry) (entry->status & WAITING)
|
#define IS_WAITING(entry) (entry->status & WAITING)
|
||||||
#define GET_WAITING_THREAD(entry) ((struct context_entry*)entry->waiting)
|
#define GET_WAITED_THREAD(entry) ((struct context_entry*)entry->waiting)
|
||||||
#define IS_WAITING_THREAD_FINISHED(entry) (GET_WAITING_THREAD(entry)->status & FINISHED)
|
#define IS_WAITED_THREAD_FINISHED(entry) (GET_WAITED_THREAD(entry)->status & FINISHED)
|
||||||
#define WAITED 0x8
|
#define WAITED 0x8
|
||||||
#define IS_WAITED(entry) (entry->status & WAITED)
|
#define IS_WAITED(entry) (entry->status & WAITED)
|
||||||
|
|
||||||
@ -35,8 +35,8 @@ struct context_entry {
|
|||||||
link; // Use to navigate inside the list
|
link; // Use to navigate inside the list
|
||||||
ucontext_t context;
|
ucontext_t context;
|
||||||
thread_t id;
|
thread_t id;
|
||||||
void *waiting;
|
void *waiting; // the thread that the entry is waiting for
|
||||||
void* retvalue;
|
void *retvalue; // retun value or if the thread is waited, the id of the thread that wait for it
|
||||||
int valgrind_id;
|
int valgrind_id;
|
||||||
char status;
|
char status;
|
||||||
char stack[STACK_SIZE];
|
char stack[STACK_SIZE];
|
||||||
@ -66,7 +66,7 @@ int thread_yield(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
TAILQ_REMOVE(&head, first, link);
|
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);
|
TAILQ_INSERT_TAIL(&head, running, link);
|
||||||
}
|
}
|
||||||
TRACE("PICKING %p (previous was %p)", first->id, running->id);
|
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);
|
TRACE("Join thread %p", thread);
|
||||||
struct context_entry* entry = thread;
|
struct context_entry* entry = thread;
|
||||||
// Check if the target is not already waited by another
|
// 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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IS_FINISHED(entry)) {
|
if (!IS_FINISHED(entry)) {
|
||||||
// Use status to be in waiting state
|
// Use status to be in waiting state
|
||||||
running->status |= WAITING;
|
running->status |= WAITING;
|
||||||
// Use retvalue to share which thread we are currently waiting for
|
|
||||||
running->waiting = entry;
|
running->waiting = entry;
|
||||||
// Mark the waited thread as waited to not be waited by any other thread.
|
// Mark the waited thread as waited to not be waited by any other thread.
|
||||||
entry->status |= WAITED;
|
entry->status |= WAITED;
|
||||||
|
// Use retvalue to share which thread is currently waiting for this thread
|
||||||
entry->retvalue = running;
|
entry->retvalue = running;
|
||||||
do {
|
do {
|
||||||
thread_yield();
|
thread_yield();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user