diff options
author | julian <julian@FreeBSD.org> | 2002-06-29 17:26:22 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 2002-06-29 17:26:22 +0000 |
commit | aa2dc0a5d9e7a19420c153cd414fefa8498eab71 (patch) | |
tree | 0a0483a267784fa8e2bf86857d8727edb5b122e9 /sys/compat/linprocfs | |
parent | 6dbff7f2c1f8150887038aed666e11675adf0b4e (diff) | |
download | FreeBSD-src-aa2dc0a5d9e7a19420c153cd414fefa8498eab71.zip FreeBSD-src-aa2dc0a5d9e7a19420c153cd414fefa8498eab71.tar.gz |
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
Diffstat (limited to 'sys/compat/linprocfs')
-rw-r--r-- | sys/compat/linprocfs/linprocfs.c | 63 |
1 files changed, 44 insertions, 19 deletions
diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index 02b858e..5129746 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -539,21 +539,6 @@ linprocfs_doprocstat(PFS_FILL_ARGS) } /* - * Map process state to descriptive letter. Note that this does not - * quite correspond to what Linux outputs, but it's close enough. - */ -static char *state_str[] = { - "? (unknown)", - "I (idle)", - "R (running)", - "S (sleeping)", - "T (stopped)", - "Z (zombie)", - "W (waiting)", - "M (mutex)" -}; - -/* * Filler function for proc/pid/status */ static int @@ -562,13 +547,53 @@ linprocfs_doprocstatus(PFS_FILL_ARGS) struct kinfo_proc kp; char *state; segsz_t lsize; + struct thread *td2; int i; mtx_lock_spin(&sched_lock); - if (p->p_stat > sizeof state_str / sizeof *state_str) - state = state_str[0]; - else - state = state_str[(int)p->p_stat]; + td2 = FIRST_THREAD_IN_PROC(p); /* XXXKSE pretend only one thread */ + + if (P_SHOULDSTOP(p)) { + state = "T (stopped)"; + } else { + switch(p->p_state) { + case PRS_NEW: + state = "I (idle)"; + break; + case PRS_NORMAL: + if (p->p_flag & P_WEXIT) { + state = "X (exiting)"; + break; + } + switch(td2->td_state) { + case TDS_SLP: + case TDS_MTX: + state = "S (sleeping)"; + break; + case TDS_RUNQ: + case TDS_RUNNING: + state = "R (running)"; + break; + case TDS_NEW: + case TDS_UNQUEUED: + case TDS_IWAIT: + case TDS_SURPLUS: + default: + state = "? (unknown)"; + break; + } + break; + case PRS_WAIT: + state = "W (waiting)"; + break; + case PRS_ZOMBIE: + state = "Z (zombie)"; + break; + default: + state = "? (unknown)"; + break; + } + } mtx_unlock_spin(&sched_lock); PROC_LOCK(p); |