process 0 ("swapper")

Valdis.Kletnieks at vt.edu Valdis.Kletnieks at vt.edu
Fri Feb 15 15:51:46 EST 2013


On Fri, 15 Feb 2013 22:24:29 +0200, Kevin Wilson said:

> #if defined(CONFIG_SMP)
> 	sprintf(idle->comm, "%s/%d", INIT_TASK_COMM, cpu);
> #endif
> ...
> #define INIT_TASK_COMM "swapper" in include/linux/init_task.h
>
> Two questions:
> 1) why does this  #if defined(CONFIG_SMP) here ? shouldn't we name
>    it swapper also in non SMP mode ?

That code is entered once per CPU as the CPU is started up.  And that %d
doesn't make much sense in single-processor mode.

> 2) Is there a reason that we do not see it with ps aux  (and also not
> under proc; there is no /proc/0).

/bin/ps just pretty-prints stuff out of /proc - so you don't see it with
ps because you don't have a /proc/0.  And that's because in fs/proc/base.c
we see this code in proc_pid_lookup:

        tgid = name_to_int(dentry);
        if (tgid == ~0U)
                goto out;

In other words, if you ask for pid 0, it bails and doesn't return anything.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 865 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130215/190bfb5f/attachment.bin 


More information about the Kernelnewbies mailing list