On Fri, May 8, 2009 at 7:34 PM, Mulyadi Santosa <[email protected]>wrote:
> On Fri, May 8, 2009 at 4:42 PM, Chetan Nanda > > >I am still confused, as every thread will be having its own register set > and > > this set will get stored in its 'tast_struct' at each context switch and > at > > next run registers will get populated from corresponding 'task_struct'. > > > > So how these variable will get shared between different threads? I am > > missing any basic thing? > > The original poster use pthreads, and pthreads are created by using > CLONE_VM flag of clone() syscall. That means, they're sharing task > struct, process address space etc. > AFAIK, each thread or process in kernel has its own 'task_struct'. It is not shared with any other thread though several elements of this, like signal_struct, fs_struct, may be shared with other threads in system. Now at every context switch all processor registers (called hardware context of a thread) get stored in task_struct. Thus each thread will be having a local copy of all processor registers. Thus there will not be any race condition in program posted by original poster. CMIMW Thanks, Chetan Nanda > > regards, > > Mulyadi. >
