I use the kernel threads inside a module. Basically my task is to take a driver from a flat memory OS to linux. In the flat memory OS the driver was not attached to the IO system and all the processing was done in 3 tasks. In linux there is no escape from attaching to the Io system but to keep the changes minimum I replace those RTOS tasks into linux kernel threads. -----Original Message----- From: kernelnewbies-bounce@nl.linux.org [mailto:kernelnewbies-bounce@nl.linux.org] On Behalf Of Jan Hudec Sent: Wednesday, June 30, 2004 3:29 PM To: aksingh@hss.hns.com Cc: Anupam Kapoor; Anandraj; kernelnewbies@nl.linux.org Subject: Re: kernel threads On Wed, Jun 30, 2004 at 15:01:24 +0530, aksingh@hss.hns.com wrote: > so what are the differences between a kernel module and kernel threads, as Kernel MODULE and kernel THREAD are completely distinct things. I assume you meant between a kernel thread and a process. Well, a kernel thread is a process, that has no user-space code and only runs in kernel. > you said kernel threads can be scheduled, pre-empted and all.that is one > Whats the utility of kernel threads, do drivers generally use them or if I > put it in a better way, when should someone think of using kernel threads > in his/her modules? You use kernel thread in a driver, if you need to do some work in process context, but not in a syscall. Briefely looking on my system, there is some 20 kernel threads running. Some of them, I am not sure what they do. Among the ones I have at least some idea what they do are: ksoftirqd: This runs the task_queues. kswapd0: IIRC this thread does the memory aging and initiates swapping. aio: This polls for the aio request. reiserfs: This does the delayed operations in reisterfs. IIRC flushing dirty nodes is one. (there are also events, kblockd, khelper and kseriod, but I don't know what these do) rpciod: This provides RPC for the NFS client and server. lockd: This is the NFS lock daemon. It keeps track of files locked over NFS. nfsd: This is the nfs server. It does the actual IO requested over NFS. There is actualy 8 of these. The first few of them are spawned by kernel proper, the NFS ones are spawned by the nfsd module. ------------------------------------------------------------------------ ------- Jan 'Bulb' Hudec <bulb@ucw.cz> -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/