aboutsummaryrefslogtreecommitdiff
path: root/kernel/proc
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/proc')
-rw-r--r--kernel/proc/kthread.c9
-rw-r--r--kernel/proc/proc.c9
2 files changed, 15 insertions, 3 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);
}
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);
}