aboutsummaryrefslogtreecommitdiff
path: root/kernel/proc/kthread.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/kthread.c
parentd2b13e08f8d6111b7f7e79a47a124fc47dd9433c (diff)
add cancellation test, will ask about bug at meeting
Diffstat (limited to 'kernel/proc/kthread.c')
-rw-r--r--kernel/proc/kthread.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/kernel/proc/kthread.c b/kernel/proc/kthread.c
index 46dd627..fa447ae 100644
--- a/kernel/proc/kthread.c
+++ b/kernel/proc/kthread.c
@@ -99,6 +99,9 @@ kthread_t *kthread_create(proc_t *proc, kthread_func_t func, long arg1,
list_init(&new_thread->kt_mutexes);
new_thread->kt_recent_core = 0;
+ // put this thread on the process's thread list
+ list_insert_tail(&proc->p_threads, &new_thread->kt_plink);
+
dbg(DBG_THR, "SUCCESFULLY created a new THREAD with proc name=%s, id=%d\n", proc->p_name, proc->p_pid);
return new_thread;
@@ -160,6 +163,9 @@ void kthread_cancel(kthread_t *thr, void *retval)
KASSERT(thr != curthr);
// TODO: ask about the use of check_curthr_cancelled() in syscall_handler()
+ int status = (int) retval;
+ dbg(DBG_THR, "Cancelling thread with proc name=%s, id=%d, status=%d\n",
+ thr->kt_proc->p_name, thr->kt_proc->p_pid, status);
thr->kt_retval = retval;
sched_cancel(thr);
@@ -172,6 +178,7 @@ void kthread_cancel(kthread_t *thr, void *retval)
void kthread_exit(void *retval)
{
// NOT_YET_IMPLEMENTED("PROCS: kthread_exit");
-
+ dbg(DBG_THR, "Exiting thread with proc name=%s, id=%d, status=%d\n",
+ curthr->kt_proc->p_name, curthr->kt_proc->p_pid, (int) retval);
proc_thread_exiting(retval);
}