TimeLinux1

Wednesday, April 20, 2011

Linux: A closer look - 2

... continued ...

-In linux, processes are created using the fork system call.
-fork creates an exact replica of the parent. The new process is called the child.
-initially the parent and child are exact copies but later they can generate distinct private memory image and variables.
-the parent is aware of the child process and the child knows about its parents pid.
-when the child process terminates it passes a status mesg to parent.
-processes can talk to each other via one of two ways -either pipes or signals. This is called interprocess comm.
-traditionally, processes are resource containers and threads are units of execution within a process. (Go here for a detailed discussion on process and threads)
-in 2000, linux introduced a new system call called 'clone' that blurred the differences between processes and threads.
-the 'clone' system call is not part of any other flavor of Unix.
-what clone did is that it made the resources comprising a process -eg: open files, signal handlers, etc specific to threads.
-in other words, what used to be hitherto common to all threads within a process, now became specific to individual threads.
-also traditionally each process in Unix is identified by a pid and all threads of that process share it.
-with the advent of clone call, linux introduced and identifier call 'task identifier' or tid.
-the tid is a basically a thread identifer.
-so if the clone system call is used to create a new process it will have a new pid and one/more new tids, sharing nothing with its parent pid.
-note, that the parent will have knowledge of both the new pid and tids.
-on the other hand, if the clone system call is used to create a new thread, it will have the same pid as parent but new tids.

... continued ...

No comments:

Post a Comment