From d0c413bd585e5dc1ee2fc2bc8b4af110ef5900c6 Mon Sep 17 00:00:00 2001 From: sotech117 Date: Tue, 20 Feb 2024 19:02:36 +0000 Subject: add cancellation test, will ask about bug at meeting --- kernel/proc/kthread.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'kernel/proc/kthread.c') 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); } -- cgit v1.2.3-70-g09d2