mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 20:58:22 +00:00
scheduler: sched_stopotherthreads()
This commit is contained in:
@@ -115,7 +115,9 @@ syscallret_t syscall_execve(context_t *context, char *upath, char *uargv[], char
|
||||
|
||||
ret.ret = 0;
|
||||
|
||||
// TODO kill other threads and close CLOEXEC fds
|
||||
// close CLOEXEC fds
|
||||
|
||||
sched_stopotherthreads();
|
||||
|
||||
error:
|
||||
free(path);
|
||||
|
||||
@@ -11,21 +11,7 @@ __attribute__((noreturn)) void syscall_exit(context_t *context, int status) {
|
||||
__assert(proc != sched_initproc);
|
||||
__assert(spinlock_try(&proc->exiting)); // only one thread can exit at the same time
|
||||
|
||||
// stop other threads
|
||||
spinlock_acquire(&proc->lock);
|
||||
proc->nomorethreads = true;
|
||||
|
||||
for (int i = 0; i < proc->threadtablesize; ++i) {
|
||||
if (proc->threads[i] == NULL || proc->threads[i] == thread)
|
||||
continue;
|
||||
|
||||
proc->threads[i]->shouldexit = true;
|
||||
sched_wakeup(proc->threads[i], SCHED_WAKEUP_REASON_INTERRUPTED);
|
||||
}
|
||||
|
||||
spinlock_release(&proc->lock);
|
||||
|
||||
while (__atomic_load_n(&proc->runningthreadcount, __ATOMIC_SEQ_CST) > 1) sched_yield();
|
||||
sched_stopotherthreads();
|
||||
|
||||
// close fds
|
||||
for (int fd = 0; fd < proc->fdcount; ++fd)
|
||||
|
||||
Reference in New Issue
Block a user