mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +00:00
scheduler: dequeue takes a state argument and releases a threadexit lock
This commit is contained in:
@@ -67,6 +67,7 @@ typedef struct _proc_t{
|
|||||||
dirnode_t* cwd;
|
dirnode_t* cwd;
|
||||||
event_t childevent;
|
event_t childevent;
|
||||||
mode_t umask;
|
mode_t umask;
|
||||||
|
int threadexitlock;
|
||||||
} proc_t;
|
} proc_t;
|
||||||
|
|
||||||
|
|
||||||
@@ -76,7 +77,7 @@ typedef struct{
|
|||||||
int lock;
|
int lock;
|
||||||
} sched_queue;
|
} sched_queue;
|
||||||
|
|
||||||
void sched_dequeue();
|
void sched_dequeue(long state);
|
||||||
proc_t* sched_getinit();
|
proc_t* sched_getinit();
|
||||||
thread_t* sched_newuthread(void* ip, size_t stacksize, void* stack, proc_t* proc, bool run, int prio);
|
thread_t* sched_newuthread(void* ip, size_t stacksize, void* stack, proc_t* proc, bool run, int prio);
|
||||||
thread_t* sched_newkthread(void* ip, size_t stacksize, bool run, int prio);
|
thread_t* sched_newkthread(void* ip, size_t stacksize, bool run, int prio);
|
||||||
|
|||||||
@@ -363,7 +363,7 @@ void sched_eventsignal(event_t* event, thread_t* thread){
|
|||||||
spinlock_release(&queues[thread->priority].lock);
|
spinlock_release(&queues[thread->priority].lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sched_dequeue(){
|
void sched_dequeue(long state){
|
||||||
|
|
||||||
timer_stop();
|
timer_stop();
|
||||||
arch_interrupt_disable();
|
arch_interrupt_disable();
|
||||||
@@ -378,16 +378,17 @@ void sched_dequeue(){
|
|||||||
arch_getcls()->thread = thread;
|
arch_getcls()->thread = thread;
|
||||||
vmm_switchcontext(thread->ctx);
|
vmm_switchcontext(thread->ctx);
|
||||||
|
|
||||||
|
thread->state = state;
|
||||||
|
if(state == THREAD_STATE_DEAD)
|
||||||
|
spinlock_release(&thread->proc->threadexitlock);
|
||||||
|
|
||||||
switch_thread(thread);
|
switch_thread(thread);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((noreturn)) int sched_die(){
|
__attribute__((noreturn)) int sched_die(){
|
||||||
|
sched_dequeue(THREAD_STATE_DEAD);
|
||||||
arch_getcls()->thread->state = THREAD_STATE_DEAD;
|
|
||||||
|
|
||||||
sched_dequeue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sched_threadexitcheck(){
|
void sched_threadexitcheck(){
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ void syscall_exit(int status){
|
|||||||
spinlock_release(&proc->lock);
|
spinlock_release(&proc->lock);
|
||||||
spinlock_release(&init->lock);
|
spinlock_release(&init->lock);
|
||||||
|
|
||||||
sched_dequeue();
|
sched_die();
|
||||||
|
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user