Hi, So how do you create threads in linux, ie threads that share the same address space. ?, Does the function kernel_thread do the job ? -Devesh On Apr 1, 2005 10:45 AM, lk <linux_kernel@xxxxxxxxx> wrote: > |I have a query about linux process and thread model. > |Every process has a 8KB of kernel stack, out of which > |some 960 bytes are reserved for task_struct. Now, > |task_struct uniquely identifies a process. > > Correct, for Linux process and threads are identical and every process (or > thread) has its own task_struct. every process is a child to some other > process except for init. threads differs only in the sense that the share > process address space. > > |That means,if any kernel thread of currently running process > |wants to access task_struct of the process, then it > |has to retrieve the corresponding task_struct by > |manipulating esp register, since task_struct lies at > |the bottom of the stack area allocated to every > |process. Now, above scenario is only possible if all > |the kernel threads of currently running process share > |the same kernel stack area allocated to the process. > |Is this true that kernel threads share kernel stack > |area allocated to a process? > > since every process has its own task_strct and hence own kernel stack. if a > thread wants to access its parent process's task struct it should make use > of task_struct->parent. > > regards > lk > > > -- > Kernelnewbies: Help each other learn about the Linux kernel. > Archive: http://mail.nl.linux.org/kernelnewbies/ > FAQ: http://kernelnewbies.org/faq/ > > -- Devesh Agrawal ============== The program is absolutely right; therefore the computer must be wrong. ----------------- How an engineer writes a program: Start by debugging an empty file... ---------------------- Systems programmers are the high priests of a low cult. - R. S. Barton -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/