lkml.org 
[lkml]   [1998]   [Mar]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: PATCH for 2.1.88: display of current->status
On Mon, Mar 02, 1998 at 10:33:33AM +0100, Andreas Schwab wrote:
> With the new encoding of current->status the display of the task state in
> various parts of the kernel is broken, making it look like the state is
> invalid. Here is a patch:
>
> --- linux-2.1.88/fs/binfmt_elf.c.~3~ Wed Feb 11 20:07:15 1998
> +++ linux-2.1.88/fs/binfmt_elf.c.~4~ Tue Feb 17 14:27:57 1998
> @@ -1217,8 +1217,9 @@
> notes[1].type = NT_PRPSINFO;
> notes[1].datasz = sizeof(psinfo);
> notes[1].data = &psinfo;
> - psinfo.pr_state = current->state;
> - psinfo.pr_sname = (current->state < 0 || current->state > 5) ? '.' : "RSDZTD"[current->state];
> + i = current->state ? ffz(~current->state) + 1 : 0;
> + psinfo.pr_state = i;
> + psinfo.pr_sname = (i < 0 || i > 5) ? '.' : "RSDZTD"[i];

I have no knowledge of this code, but if this naming and the one used
below should match, shouldn't the string be "RSDZTW" (W as last
character).?

astor

> psinfo.pr_zomb = psinfo.pr_sname == 'Z';
> psinfo.pr_nice = current->priority-15;
> psinfo.pr_flag = current->flags;
> --- linux-2.1.88/fs/proc/array.c.~1~ Wed Jan 28 19:11:04 1998
> +++ linux-2.1.88/fs/proc/array.c Tue Feb 17 16:20:14 1998
> @@ -611,7 +611,7 @@
> static inline char * task_state(struct task_struct *p, char *buffer)
> {
> #define NR_STATES (sizeof(states)/sizeof(const char *))
> - unsigned int n = p->state;
> + unsigned int n = p->state ? ffz(~p->state) + 1 : 0;
> static const char * states[] = {
> "R (running)",
> "S (sleeping)",
> @@ -763,14 +763,15 @@
> char blocked_str[sizeof(sigset_t)*2+1];
> char sigign_str[sizeof(sigset_t)*2+1];
> char sigcatch_str[sizeof(sigset_t)*2+1];
> - char state;
> + int state;
>
> if (!tsk)
> return 0;
> - if (tsk->state < 0 || tsk->state > 5)
> + state = tsk->state ? ffz(~tsk->state) + 1 : 0;
> + if (state < 0 || state > 5)
> state = '.';
> else
> - state = "RSDZTW"[tsk->state];
> + state = "RSDZTW"[state];
> vsize = eip = esp = 0;
> if (tsk->mm && tsk->mm != &init_mm) {
> struct vm_area_struct *vma = tsk->mm->mmap;
> --- linux-2.1.88/kernel/sched.c.~4~ Sat Feb 14 08:51:26 1998
> +++ linux-2.1.88/kernel/sched.c Tue Feb 17 14:19:03 1998
> @@ -1453,11 +1453,13 @@
> static void show_task(int nr,struct task_struct * p)
> {
> unsigned long free = 0;
> + int state;
> static const char * stat_nam[] = { "R", "S", "D", "Z", "T", "W" };
>
> printk("%-16s %3d ", p->comm, (p == current) ? -nr : nr);
> - if (((unsigned) p->state) < sizeof(stat_nam)/sizeof(char *))
> - printk(stat_nam[p->state]);
> + state = p->state ? ffz(~p->state) + 1 : 0;
> + if (((unsigned) state) < sizeof(stat_nam)/sizeof(char *))
> + printk(stat_nam[state]);
> else
> printk(" ");
> #if ((~0UL) == 0xffffffff)
>


astor

--
Alexander Kjeldaas, Guardian Networks AS, Trondheim, Norway
http://www.guardian.no/

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 13:41    [from the cache]
©2003-2011 Jasper Spaans