mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +00:00
scheduler: thread sleep queue pointers
This commit is contained in:
@@ -17,6 +17,8 @@ typedef struct thread_t {
|
|||||||
void *kernelstacktop;
|
void *kernelstacktop;
|
||||||
struct thread_t *next;
|
struct thread_t *next;
|
||||||
struct thread_t *prev;
|
struct thread_t *prev;
|
||||||
|
struct thread_t *sleepnext;
|
||||||
|
struct thread_t *sleepprev;
|
||||||
struct proc_t *proc;
|
struct proc_t *proc;
|
||||||
struct cpu_t *cpu;
|
struct cpu_t *cpu;
|
||||||
context_t context;
|
context_t context;
|
||||||
|
|||||||
@@ -6,24 +6,24 @@ static void insert(semaphore_t *sem, thread_t *thread) {
|
|||||||
if (sem->head == NULL) {
|
if (sem->head == NULL) {
|
||||||
sem->head = thread;
|
sem->head = thread;
|
||||||
sem->tail = thread;
|
sem->tail = thread;
|
||||||
thread->next = NULL;
|
thread->sleepnext = NULL;
|
||||||
thread->prev = NULL;
|
thread->sleepprev = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sem->tail->next = _cpu()->thread;
|
sem->tail->sleepnext = _cpu()->thread;
|
||||||
_cpu()->thread->prev = sem->tail;
|
_cpu()->thread->sleepprev = sem->tail;
|
||||||
}
|
}
|
||||||
|
|
||||||
static thread_t *get(semaphore_t *sem) {
|
static thread_t *get(semaphore_t *sem) {
|
||||||
thread_t *thread = sem->head;
|
thread_t *thread = sem->head;
|
||||||
__assert(thread);
|
__assert(thread);
|
||||||
|
|
||||||
sem->head = sem->head->next;
|
sem->head = sem->head->sleepnext;
|
||||||
if (sem->head == NULL)
|
if (sem->head == NULL)
|
||||||
sem->tail = NULL;
|
sem->tail = NULL;
|
||||||
else
|
else
|
||||||
sem->head->prev = NULL;
|
sem->head->sleepprev = NULL;
|
||||||
|
|
||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user