* process 0 ("swapper")
@ 2013-02-15 20:24 Kevin Wilson
2013-02-15 20:51 ` Valdis.Kletnieks at vt.edu
0 siblings, 1 reply; 5+ messages in thread
From: Kevin Wilson @ 2013-02-15 20:24 UTC (permalink / raw)
To: kernelnewbies
Hi,
I see that the idle process (process 0) , is called "swapper".
init_idle() in kernel/sched/core.c:
...
#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 ?
2) Is there a reason that we do not see it with ps aux (and also not
under proc; there is no /proc/0).
- 1) no process 0; processes start from "1".
- 2) following command gives nothing:
ps aux | grep -i swapper
rgs,
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread
* process 0 ("swapper")
2013-02-15 20:24 process 0 ("swapper") Kevin Wilson
@ 2013-02-15 20:51 ` Valdis.Kletnieks at vt.edu
2013-02-16 16:48 ` Kevin Wilson
0 siblings, 1 reply; 5+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2013-02-15 20:51 UTC (permalink / raw)
To: kernelnewbies
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* process 0 ("swapper")
2013-02-15 20:51 ` Valdis.Kletnieks at vt.edu
@ 2013-02-16 16:48 ` Kevin Wilson
2013-02-16 17:43 ` anish kumar
2013-02-17 2:03 ` Valdis.Kletnieks at vt.edu
0 siblings, 2 replies; 5+ messages in thread
From: Kevin Wilson @ 2013-02-16 16:48 UTC (permalink / raw)
To: kernelnewbies
Hi,
> 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.
Are you sure that this is what it cjecks?
~0U is not 0 but -1;
for example, try:
printf("%d\n",~0U );
printf("%x\n",~0U );
printf("%x\n",-1 );
and you get:
-1
ffffffff
ffffffff
rgs
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread
* process 0 ("swapper")
2013-02-16 16:48 ` Kevin Wilson
@ 2013-02-16 17:43 ` anish kumar
2013-02-17 2:03 ` Valdis.Kletnieks at vt.edu
1 sibling, 0 replies; 5+ messages in thread
From: anish kumar @ 2013-02-16 17:43 UTC (permalink / raw)
To: kernelnewbies
On Sat, 2013-02-16 at 18:48 +0200, Kevin Wilson wrote:
> Hi,
>
> > we see this code in proc_pid_lookup:
> >
> > tgid = name_to_int(dentry);
> > if (tgid == ~0U)
> > goto out;
It is the error case when name can't be converted to integer i.e.
name is wrong.
> >
> > In other words, if you ask for pid 0, it bails and doesn't return anything.
>
> Are you sure that this is what it cjecks?
>
> ~0U is not 0 but -1;
right
>
> for example, try:
> printf("%d\n",~0U );
> printf("%x\n",~0U );
> printf("%x\n",-1 );
> and you get:
> -1
> ffffffff
> ffffffff
> rgs
> Kevin
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
^ permalink raw reply [flat|nested] 5+ messages in thread
* process 0 ("swapper")
2013-02-16 16:48 ` Kevin Wilson
2013-02-16 17:43 ` anish kumar
@ 2013-02-17 2:03 ` Valdis.Kletnieks at vt.edu
1 sibling, 0 replies; 5+ messages in thread
From: Valdis.Kletnieks at vt.edu @ 2013-02-17 2:03 UTC (permalink / raw)
To: kernelnewbies
On Sat, 16 Feb 2013 18:48:52 +0200, Kevin Wilson said:
> ~0U is not 0 but -1;
-ENOCAFFEINE.
You'd think that after having done kernel-level C programming since the days
of SunOS 3.1.5 and BSD 4.2 I'd k know better. ;)
-------------- 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/20130216/674bdbd6/attachment.bin
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-02-17 2:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-15 20:24 process 0 ("swapper") Kevin Wilson
2013-02-15 20:51 ` Valdis.Kletnieks at vt.edu
2013-02-16 16:48 ` Kevin Wilson
2013-02-16 17:43 ` anish kumar
2013-02-17 2:03 ` Valdis.Kletnieks at vt.edu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.