diff --git a/executer/kernel/mcctrl/procfs.c b/executer/kernel/mcctrl/procfs.c index 1417c2f8..38fb40d3 100644 --- a/executer/kernel/mcctrl/procfs.c +++ b/executer/kernel/mcctrl/procfs.c @@ -1113,7 +1113,7 @@ static const struct procfs_entry pid_entry_stuff[] = { PROC_REG("mem", 0400, NULL), PROC_REG("pagemap", 0444, NULL), // PROC_REG("smaps", S_IRUGO, NULL), -// PROC_REG("stat", 0444, &mckernel_buff_io), + PROC_REG("stat", 0444, &mckernel_buff_io), // PROC_REG("statm", S_IRUGO, NULL), PROC_REG("status", 0444, &mckernel_buff_io), // PROC_REG("syscall", S_IRUGO, NULL), diff --git a/kernel/procfs.c b/kernel/procfs.c index dc7f344d..8a778d4c 100644 --- a/kernel/procfs.c +++ b/kernel/procfs.c @@ -669,6 +669,42 @@ int process_procfs_request(struct ikc_scd_packet *rpacket) } if (!strcmp(p, "stat")) { + const char *comm = "exe"; + char state; + + if (proc->saved_cmdline) { + comm = strrchr(proc->saved_cmdline, '/'); + if (comm) + comm++; + else + comm = proc->saved_cmdline; + } + + switch (thread->status & (0x3f)) { + case PS_INTERRUPTIBLE: + state = 'S'; + break; + case PS_UNINTERRUPTIBLE: + state = 'D'; + break; + case PS_ZOMBIE: + state = 'Z'; + break; + case PS_EXITED: + state = 'X'; + break; + case PS_STOPPED: + state = 'T'; + break; + case PS_RUNNING: + default: + if (thread->in_syscall_offload > 0) { + state = 'S'; + } + else { + state = 'R'; + } + } /* * pid (comm) state ppid @@ -695,8 +731,9 @@ int process_procfs_request(struct ikc_scd_packet *rpacket) "%lu %lu %lu %lu " // sigignore... "%lu %d %d %u " // cnswap... "%u %llu %lu %ld\n", // policy... - 0, "exe", 'R', 0, // pid... - 0, 0, 0, 0, // pgrp... + thread->tid, comm, state, + thread->proc->ppid_parent->pid, // pid... + thread->proc->pid, 0, 0, 0, // pgrp... 0, 0L, 0L, 0L, // flags... 0L, 0L, 0L, 0L, // cmajflt... 0L, 0L, 0L, 0L, // cstime... diff --git a/kernel/syscall.c b/kernel/syscall.c index 1e4c6937..8de5039c 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -4324,6 +4324,7 @@ SYSCALL_DECLARE(rt_sigtimedwait) thread->sigevent = 1; for(;;){ while(thread->sigevent == 0){ + thread->status = PS_INTERRUPTIBLE; if(timeout){ if (gettime_local_support) calculate_time_from_tsc(&ats); @@ -4340,6 +4341,7 @@ SYSCALL_DECLARE(rt_sigtimedwait) thread->sigevent = 0; #endif /* POSTK_DEBUG_TEMP_FIX_33 */ + thread->status = PS_RUNNING; lock = &thread->sigcommon->lock; head = &thread->sigcommon->sigpending; mcs_rwlock_writer_lock(lock, &mcs_rw_node); @@ -4454,6 +4456,8 @@ do_sigsuspend(struct thread *thread, const sigset_t *set) int do_schedule = 0; struct cpu_local_var *v; long runq_irqstate; + + thread->status = PS_INTERRUPTIBLE; runq_irqstate = ihk_mc_spinlock_lock(&(get_this_cpu_local_var()->runq_lock)); v = get_this_cpu_local_var(); @@ -4475,6 +4479,7 @@ do_sigsuspend(struct thread *thread, const sigset_t *set) thread->sigevent = 0; #endif /* POSTK_DEBUG_TEMP_FIX_33 */ + thread->status = PS_RUNNING; lock = &thread->sigcommon->lock; head = &thread->sigcommon->sigpending; mcs_rwlock_writer_lock(lock, &mcs_rw_node);