mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
vmm: change how vmm_destroycontext is handled
This commit is contained in:
@@ -97,8 +97,9 @@ void sched_destroythread(thread_t *thread) {
|
||||
}
|
||||
|
||||
void sched_destroyproc(proc_t *proc) {
|
||||
free(proc->threads);
|
||||
slab_free(processcache, proc);
|
||||
//free(proc->threads);
|
||||
//free(proc->fd);
|
||||
//slab_free(processcache, proc);
|
||||
}
|
||||
|
||||
static thread_t *runqueuenext(int minprio) {
|
||||
@@ -197,8 +198,14 @@ __attribute__((noreturn)) void sched_threadexit() {
|
||||
thread_t *thread = _cpu()->thread;
|
||||
proc_t *proc = thread->proc;
|
||||
|
||||
if (proc)
|
||||
__atomic_fetch_sub(&currpid, 1, __ATOMIC_SEQ_CST);
|
||||
vmmcontext_t *oldctx = thread->vmmctx;
|
||||
vmm_switchcontext(&vmm_kernelctx);
|
||||
|
||||
if (proc) {
|
||||
__atomic_fetch_sub(&proc->runningthreadcount, 1, __ATOMIC_SEQ_CST);
|
||||
if (proc->runningthreadcount == 0)
|
||||
vmm_destroycontext(oldctx);
|
||||
}
|
||||
|
||||
_cpu()->thread = NULL;
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ syscallret_t syscall_execve(context_t *context, char *upath, char *uargv[], char
|
||||
|
||||
if (vmmctx && ret.errno) {
|
||||
vmm_switchcontext(oldctx);
|
||||
vmm_destroycontext(vmmctx, 0);
|
||||
vmm_destroycontext(vmmctx);
|
||||
}
|
||||
|
||||
if (refnode)
|
||||
@@ -136,8 +136,7 @@ syscallret_t syscall_execve(context_t *context, char *upath, char *uargv[], char
|
||||
free(interp);
|
||||
|
||||
if (ret.errno == 0) {
|
||||
// TODO sync mmap files (unmap all lower memory first before destroying context?)
|
||||
vmm_destroycontext(oldctx, 0);
|
||||
vmm_destroycontext(oldctx);
|
||||
CTX_SP(context) = (uint64_t)stack;
|
||||
CTX_IP(context) = (uint64_t)entry;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user