diff options
author | Miles Bader <miles@gnu.org> | 1996-05-29 20:50:02 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1996-05-29 20:50:02 +0000 |
commit | e3889fcd1bfa90420eaf0b99ba1c5a4aae8f089c (patch) | |
tree | bc16dc0c8e7ba27ca298df81e1cb2ab2a435a585 | |
parent | 7ce5bb513f5e7f9b541f88bd2ad3acd92b3ba6d4 (diff) |
(MP_MGET): Only disable msgport on timeout.
(get_thread_wait): Decrement N in loop.
(get_thread_wait): Use strnlen instead of memchr.
(PSTAT_PROCINFO): Typo: PSTAT_THREAD_WAIT --> PSTAT_THREAD_WAITS.
(PSTAT_USES_MSGPORT): Add PSTAT_THREAD_WAIT.
-rw-r--r-- | libps/procstat.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/libps/procstat.c b/libps/procstat.c index 2ed3f1af..a7aed780 100644 --- a/libps/procstat.c +++ b/libps/procstat.c @@ -79,7 +79,7 @@ thread_state (thread_basic_info_t bi) #define PSTAT_PROCINFO \ (PSTAT_PROC_INFO | PSTAT_TASK_BASIC | PSTAT_NUM_THREADS \ | PSTAT_THREAD_BASIC | PSTAT_THREAD_SCHED | PSTAT_THREAD_WAIT \ - | PSTAT_THREAD_WAIT) + | PSTAT_THREAD_WAITS) /* The set of things we get from procinfo that's thread dependent. */ #define PSTAT_PROCINFO_THREAD \ (PSTAT_NUM_THREADS |PSTAT_THREAD_BASIC |PSTAT_THREAD_SCHED \ @@ -237,7 +237,8 @@ add_preconditions (ps_flags_t flags, struct ps_context *context) (PSTAT_NUM_THREADS | PSTAT_SUSPEND_COUNT | PSTAT_THREAD_BASIC) /* Those flags that need the msg port, perhaps implicitly. */ -#define PSTAT_USES_MSGPORT (PSTAT_MSGPORT | PSTAT_THREAD_WAITS) +#define PSTAT_USES_MSGPORT \ + (PSTAT_MSGPORT | PSTAT_THREAD_WAIT | PSTAT_THREAD_WAITS) /* Return true when there's some condition indicating that we shouldn't use PS's msg port. For this routine to work correctly, PS's flags should @@ -448,7 +449,7 @@ summarize_thread_waits (struct procinfo *pi, char *waits, size_t waits_len, } /* Advance NEXT_WAIT to the next wait string. */ - next_wait += strnlen (next_wait, left); + next_wait += strnlen (next_wait, left) + 1; } } @@ -492,15 +493,11 @@ char * get_thread_wait (char *waits, size_t waits_len, unsigned n) { char *wait = waits; - while (n && wait) + while (n-- && wait) if (wait >= waits + waits_len) wait = 0; else - { - wait = memchr (wait, '\0', waits_len - (wait - waits)); - if (wait) - wait++; - } + wait += strnlen (wait, waits + waits_len - wait) + 1; return wait; } @@ -579,7 +576,7 @@ proc_stat_set_flags (struct proc_stat *ps, ps_flags_t flags) PSTAT_MSGPORT. */ #define MP_MGET(flag, precond, call) \ ({ error_t err = MGET (flag, (precond) | PSTAT_MSGPORT, call); \ - if (err) suppress_msgport (); \ + if (err == EMACH_RCV_TIMED_OUT) suppress_msgport (); \ err; \ }) @@ -654,11 +651,11 @@ proc_stat_set_flags (struct proc_stat *ps, ps_flags_t flags) &ps->thread_wait, &ps->thread_rpc); have |= PSTAT_THREAD_WAIT; } - else if ((have & PSTAT_NUM_THREADS) && ps->num_threads > 2) - /* More than 2 threads (1 user thread) always results in this - value for the process's thread_wait field. For the 2 thread - case, we should have fetched thread_waits info and hit the - previous case. */ + else if ((have & PSTAT_NUM_THREADS) && ps->num_threads > 3) + /* More than 3 threads (1 user thread + libc signal thread + + possible itimer thread) always results in this value for the + process's thread_wait field. For fewer threads, we should + have fetched thread_waits info and hit the previous case. */ { ps->thread_wait = "*"; ps->thread_rpc = 0; |