aboutsummaryrefslogtreecommitdiff
path: root/kernel/proc/proc.c
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2024-02-20 19:02:36 +0000
committersotech117 <michael_foiani@brown.edu>2024-02-20 19:02:36 +0000
commitd0c413bd585e5dc1ee2fc2bc8b4af110ef5900c6 (patch)
treee22098e4ebc68f14af241afb2876186408e33d5e /kernel/proc/proc.c
parentd2b13e08f8d6111b7f7e79a47a124fc47dd9433c (diff)
add cancellation test, will ask about bug at meeting
Diffstat (limited to 'kernel/proc/proc.c')
-rw-r--r--kernel/proc/proc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/kernel/proc/proc.c b/kernel/proc/proc.c
index d0566ec..7350acb 100644
--- a/kernel/proc/proc.c
+++ b/kernel/proc/proc.c
@@ -242,6 +242,8 @@ proc_t *proc_create(const char *name)
void proc_cleanup(long status)
{
// NOT_YET_IMPLEMENTED("PROCS: proc_cleanup");
+ dbg(DBG_PROC, "proc_cleanup called on proc with pid=%d with exit status=%d\n", curproc->p_pid, status);
+
if (curproc->p_pid == PID_INIT)
{
@@ -258,7 +260,7 @@ void proc_cleanup(long status)
list_link_t *link;
list_iterate(&curproc->p_children, child, proc_t, p_child_link)
{
- // remove insert to init process
+ // remove & insert to init process
list_insert_tail(&curproc->p_pproc->p_children, &child->p_child_link);
list_remove(&child->p_child_link);
child->p_pproc = proc_initproc;
@@ -303,12 +305,14 @@ void proc_thread_exiting(void *retval)
void proc_kill(proc_t *proc, long status)
{
// NOT_YET_IMPLEMENTED("PROCS: proc_kill");
+ dbg(DBG_PROC, "proc_kill called on proc with pid=%d\n", proc->p_pid);
KASSERT(proc != curproc && "proc_kill called on curproc");
list_iterate(&proc->p_threads, thr, kthread_t, kt_plink)
{
- kthread_cancel(thr, (void *) status);
+ dbg(DBG_PROC, "cancelling thread on proc with pid=%d with status=%ld\n", proc->p_pid, status);
+ kthread_cancel(thr, (void *)status);
}
}
@@ -429,6 +433,7 @@ pid_t do_waitpid(pid_t pid, int *status, int options)
// sleep until this specific child process exits
while (child->p_state != PROC_DEAD)
{
+ dbg(DBG_PROC, "waiting for specific child, calling sched_sleep_on\n");
sched_sleep_on(&curproc->p_wait);
}