mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 23:18:21 +00:00
scheduler: fix thread array stuff and fix stupid thing
This commit is contained in:
@@ -264,6 +264,8 @@ thread_t* sched_newuthread(void* ip, size_t kstacksize, void* stack, proc_t* pro
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
thread->tid = proc->pid;
|
thread->tid = proc->pid;
|
||||||
|
proc->threadcount = 1;
|
||||||
|
proc->threads[0] = thread;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
spinlock_acquire(&proc->lock);
|
spinlock_acquire(&proc->lock);
|
||||||
@@ -273,6 +275,7 @@ thread_t* sched_newuthread(void* ip, size_t kstacksize, void* stack, proc_t* pro
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
proc->threads = tmp;
|
proc->threads = tmp;
|
||||||
|
proc->threads[proc->threadcount] = thread;
|
||||||
++proc->threadcount;
|
++proc->threadcount;
|
||||||
spinlock_release(&proc->lock);
|
spinlock_release(&proc->lock);
|
||||||
thread->tid = getnextpid();
|
thread->tid = getnextpid();
|
||||||
@@ -326,7 +329,7 @@ void sched_yieldtrampoline(thread_t* thread){
|
|||||||
|
|
||||||
|
|
||||||
thread_t* nthread = getnext();
|
thread_t* nthread = getnext();
|
||||||
|
|
||||||
timer_resume();
|
timer_resume();
|
||||||
|
|
||||||
switch_thread(nthread);
|
switch_thread(nthread);
|
||||||
@@ -368,6 +371,7 @@ void sched_dequeue(long state){
|
|||||||
timer_stop();
|
timer_stop();
|
||||||
arch_interrupt_disable();
|
arch_interrupt_disable();
|
||||||
|
|
||||||
|
thread_t* current = arch_getcls()->thread;
|
||||||
thread_t* thread = getnext();
|
thread_t* thread = getnext();
|
||||||
|
|
||||||
timer_resume();
|
timer_resume();
|
||||||
@@ -378,9 +382,9 @@ void sched_dequeue(long state){
|
|||||||
arch_getcls()->thread = thread;
|
arch_getcls()->thread = thread;
|
||||||
vmm_switchcontext(thread->ctx);
|
vmm_switchcontext(thread->ctx);
|
||||||
|
|
||||||
thread->state = state;
|
current->state = state;
|
||||||
if(state == THREAD_STATE_DEAD)
|
if(state == THREAD_STATE_DEAD)
|
||||||
spinlock_release(&thread->proc->threadexitlock);
|
spinlock_release(¤t->proc->threadexitlock);
|
||||||
|
|
||||||
switch_thread(thread);
|
switch_thread(thread);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user