aboutsummaryrefslogtreecommitdiff
path: root/kernel/proc
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2024-02-20 19:49:59 +0000
committersotech117 <michael_foiani@brown.edu>2024-02-20 19:49:59 +0000
commit9c90e73fda0d5df2e1f11b32d459d3bb07a63192 (patch)
tree29272e6765eca78d6a5a9a7c23ec435eaa138d64 /kernel/proc
parentd0c413bd585e5dc1ee2fc2bc8b4af110ef5900c6 (diff)
small conceptual issue with retvals when threads are cancelled. will ask
Diffstat (limited to 'kernel/proc')
-rw-r--r--kernel/proc/kthread.c4
-rw-r--r--kernel/proc/proc.c6
-rw-r--r--kernel/proc/sched.c3
3 files changed, 7 insertions, 6 deletions
diff --git a/kernel/proc/kthread.c b/kernel/proc/kthread.c
index fa447ae..d066dac 100644
--- a/kernel/proc/kthread.c
+++ b/kernel/proc/kthread.c
@@ -162,14 +162,12 @@ void kthread_cancel(kthread_t *thr, void *retval)
// NOT_YET_IMPLEMENTED("PROCS: kthread_cancel");
KASSERT(thr != curthr);
- // TODO: ask about the use of check_curthr_cancelled() in syscall_handler()
+ // FIXME: 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);
-
- //check_curthr_cancelled();
}
/*
diff --git a/kernel/proc/proc.c b/kernel/proc/proc.c
index 7350acb..a1f68f8 100644
--- a/kernel/proc/proc.c
+++ b/kernel/proc/proc.c
@@ -268,7 +268,11 @@ void proc_cleanup(long status)
// update state and status
curproc->p_state = PROC_DEAD;
- curproc->p_status = status;
+ if (curthr->kt_cancelled) {
+ curproc->p_status = curthr->kt_retval;
+ } else {
+ curproc->p_status = status;
+ }
}
/*
diff --git a/kernel/proc/sched.c b/kernel/proc/sched.c
index cd8e438..31976bb 100644
--- a/kernel/proc/sched.c
+++ b/kernel/proc/sched.c
@@ -74,7 +74,6 @@ void sched_queue_init(ktqueue_t *queue)
*/
static void ktqueue_enqueue(ktqueue_t *queue, kthread_t *thr)
{
- // TODO: ask in mentor meeting about what causes this assertion error
KASSERT(!thr->kt_wchan);
list_assert_sanity(&queue->tq_list);
@@ -238,7 +237,7 @@ void sched_switch(ktqueue_t *queue)
curcore.kc_queue = queue;
last_thread_context = &curthr->kt_ctx;
-
+
context_switch(&curthr->kt_ctx, &curcore.kc_ctx);
intr_enable();