scheduler: hold reference on sched_getprocfrompid

This commit is contained in:
Matheus
2024-05-22 09:44:11 -03:00
parent a9b5451787
commit b61d391778
2 changed files with 13 additions and 2 deletions
+9 -2
View File
@@ -38,9 +38,14 @@ static pid_t currpid = 1;
proc_t *sched_getprocfrompid(int pid) {
MUTEX_ACQUIRE(&sched_pidtablemutex, false);
void *proc = NULL;
hashtable_get(&pidtable, &proc, &pid, sizeof(pid));
void *_proc = NULL;
hashtable_get(&pidtable, &_proc, &pid, sizeof(pid));
proc_t *proc = _proc;
if (proc) {
PROC_HOLD(proc);
}
MUTEX_RELEASE(&sched_pidtablemutex);
return proc;
}
@@ -321,6 +326,8 @@ void sched_inactiveproc(proc_t *proc) {
hashtable_remove(&pidtable, &proc->pid, sizeof(proc->pid));
//arch_e9_puts("\n\ndestroy proc\n\n");
//printf("destroy proc\n");
sched_destroyproc(proc);
}
+4
View File
@@ -35,6 +35,10 @@ syscallret_t syscall_kill(context_t *context, int pid, int signal) {
else
ret.errno = jobctl_signal(target, signal);
if (target) {
PROC_RELEASE(target);
}
ret.errno = 0;
ret.ret = 0;
return ret;