Hi, I am definitly a kernel newbie so don't take my answers too seriously :) However, I think "current->pid" points to the user process currently executing (that is, currently used by the scheduler.). See http://www.xml.com/ldd/chapter/book/ch02.html - it has a short section about "The Current Process". I also think that a kernel module doesn't have a process ID since it is not a userspace process, but is inserted directly into the kernel (insmod) and lives there as all other kernel code do. I do however think it is possible for a kernel module to create it's own process ID. I would guess it already has direct access to the task structure (living in kernel space can be sweet but dangerous) so it can just add itself to it, or maybe there is other smarter better ways to do it than modifying it manually. If you do a "ps afx" you will see quite a few "kernel processes". A typical listing may look something like: PID TTY STAT TIME COMMAND 1 ? S 0:04 init 2 ? SW 0:00 [keventd] 3 ? SWN 0:00 [ksoftirqd_CPU0] 4 ? SWN 0:00 [ksoftirqd_CPU1] 5 ? SW 0:00 [kswapd] 6 ? SW 0:00 [bdflush] 7 ? SW 0:00 [kupdated] 8 ? SW 0:00 [mdrecoveryd] 14 ? SW 0:00 [scsi_eh_0] 16 ? SW 0:00 [scsi_eh_1] 19 ? SW 0:00 [kjournald] 92 ? SW 0:00 [khubd] 188 ? SW 0:00 [kjournald] 189 ? SW 0:00 [kjournald] 190 ? SW 0:00 [kjournald] 667 ? S 0:00 syslogd -m 0 672 ? S 0:00 klogd -x ... Those surrounded by [] lives in kernelspace, and has a process ID (pid) assigned to them. Beeing a kernel newbie this also makes me wonder why the have process IDs. I sure hope it isn't possible to kill the ksoftirqd_CPU0 :) So I would be glad if anyone could explain to me why they have process IDs. Has it something to do with scheduling? regards, Christian Vik Kernel Newbie -----Opprinnelig melding----- Fra: kernelnewbies-bounce@nl.linux.org [mailto:kernelnewbies-bounce@nl.linux.org]Pa vegne av Zwane Mwaikambo Sendt: 27. mai 2002 12:49 Til: Paolo Perego Kopi: KernelNewbies Emne: Re: Pid lkm On Mon, 27 May 2002, Zwane Mwaikambo wrote: > On 27 May 2002, Paolo Perego wrote: > > > init_module() { > > printk(KERN_INFO "insmod pid is %d\n", current->pid); > > } > > ... and what does all that mean when the code is compiled into the > kernel? > > Modules and PIDs bear no relation. Sorry Paolo, i messed up my To: CC: etc, the email wasn't supposed to be destined for you. Regards, Zwane Mwaikambo -- http://function.linuxpower.ca -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/