mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 15:08:21 +00:00
scheduler: lock proc when adding a new thread
This commit is contained in:
@@ -260,6 +260,7 @@ thread_t* sched_newuthread(void* ip, size_t kstacksize, void* stack, proc_t* pro
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
spinlock_acquire(&proc->lock);
|
||||||
thread_t** tmp = realloc(proc->threads, sizeof(thread_t*) * (proc->threadcount + 1));
|
thread_t** tmp = realloc(proc->threads, sizeof(thread_t*) * (proc->threadcount + 1));
|
||||||
if(!tmp){
|
if(!tmp){
|
||||||
freethread(thread);
|
freethread(thread);
|
||||||
@@ -267,6 +268,7 @@ thread_t* sched_newuthread(void* ip, size_t kstacksize, void* stack, proc_t* pro
|
|||||||
}
|
}
|
||||||
proc->threads = tmp;
|
proc->threads = tmp;
|
||||||
++proc->threadcount;
|
++proc->threadcount;
|
||||||
|
spinlock_release(&proc->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
thread->priority = prio;
|
thread->priority = prio;
|
||||||
|
|||||||
Reference in New Issue
Block a user