how does fork() copy threads of a process in multi-processor (SMP)

lalit mohan tripathi lalit.tripathi at gmail.com
Thu Mar 10 10:05:19 EST 2011


I've a general question:  In Multiprocessor (Multi-Core) (SMP)
environment how does  fork system call  (do_fork() related code)
maintain the synchronization in case the threads of a process are
running on different processors?  E.g. it can happen that the fork()
is called by cpu-0 thread and other thread of same process is
executing on cpu-1.

I can see that copy of the process is made by do_fork() code in
fork.c.  Can anyone give more details how the concurrency issue gets
handled e.g. how  PC and Regs are of cpu-1 thread get copied without
any race condition in SMP / multiprocessor system?

Thanks in advance



More information about the Kernelnewbies mailing list