fix: use a real fifo for yield
This commit is contained in:
parent
9e02e4ef67
commit
c5c1b74906
@ -48,12 +48,10 @@ int thread_yield(void) {
|
||||
}
|
||||
TAILQ_REMOVE(&head, first, link);
|
||||
TAILQ_INSERT_TAIL(&head, first, link);
|
||||
if (first->id == running->id) {
|
||||
return 0;
|
||||
}
|
||||
} while ((first->status & FINISHED) ||
|
||||
((first->status & WAITING) && !(((struct context_entry *)first->retvalue)->status & FINISHED)));
|
||||
TRACE("PICKING %p", first);
|
||||
((first->status & WAITING) && !(((struct context_entry *)first->retvalue)->status & FINISHED)) ||
|
||||
(first->id == running->id));
|
||||
TRACE("PICKING %p (previous was %p)", first->id, running->id);
|
||||
struct context_entry *old_runner = running;
|
||||
running = first;
|
||||
swapcontext(&old_runner->context, &running->context);
|
||||
@ -81,7 +79,7 @@ int thread_create(thread_t *newthread, void *(*func)(void *), void *funcarg) {
|
||||
new_entry->id = 0;
|
||||
new_entry->status = 0;
|
||||
new_entry->retvalue = 0;
|
||||
TAILQ_INSERT_HEAD(&head, new_entry, link);
|
||||
TAILQ_INSERT_TAIL(&head, new_entry, link);
|
||||
running = new_entry;
|
||||
counter++;
|
||||
new_entry = malloc(sizeof(*new_entry));
|
||||
@ -100,7 +98,7 @@ int thread_create(thread_t *newthread, void *(*func)(void *), void *funcarg) {
|
||||
*newthread = new_entry;
|
||||
makecontext(&new_entry->context, (void (*)(void)) thread_function_wrapper, 2, func, funcarg);
|
||||
counter++;
|
||||
TAILQ_INSERT_HEAD(&head, new_entry, link);
|
||||
TAILQ_INSERT_TAIL(&head, new_entry, link);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user