EmbLogic's Blog

fork

fork is an operation or a process which creates a copy of itself. It is usually a system call, implemented in the kernel. Fork is the primary method of process creation on Unix-like operating systems.

  • If fork() returns a negative value, the creation of a child process was unsuccessful.
  • fork() returns a zero to the newly created child process.
  • fork() returns a positive value, the process ID of the child process, to the parent. The returned process ID is of type pid_t defined in sys/types.h. Normally, the process ID is an integer. Moreover, a process can use function getpid() to retrieve the process ID assigned to this process.

Due to the fact that the CPU scheduler will assign a particular time to each process, the parent or the child process will run for some time.After the calling of system call FORK the program counter of both will run simultaneously.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>