Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
84 views2 pages

Course: CPCS-361 (Operating System-1) : Project

1) The fork system call creates a copy of the calling process, known as the parent, and returns the process ID of the new child process to the parent. 2) Both the parent and child processes continue execution from the point immediately after the fork call, allowing parallel execution. 3) The child process is an identical copy of the parent process except for having a unique process ID and parent process ID.

Uploaded by

Shuaib Qureshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views2 pages

Course: CPCS-361 (Operating System-1) : Project

1) The fork system call creates a copy of the calling process, known as the parent, and returns the process ID of the new child process to the parent. 2) Both the parent and child processes continue execution from the point immediately after the fork call, allowing parallel execution. 3) The child process is an identical copy of the parent process except for having a unique process ID and parent process ID.

Uploaded by

Shuaib Qureshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Solution:

http://www.cs.uregina.ca/Links/class-info/330/Fork/fork.html

Course: CPCS-361 (Operating System-1)


Project: System Calls and Inter process Communication
Note: Last date of submission of project is next week before the class timing.
Late submission is not allowed.
Project Documentation should contain;
1) Algorithm Steps
2) Flow Chart
3) Complete Code
4) Screen shots of the results
Project Description:
In computing, when a process forks, it creates a copy of itself. More generally, a fork in a
multithreading environment means that a thread of execution is duplicated, creating a child thread
from the parent thread.
The fork system call does not take an argument.
The process that invokes the fork() is known as the parent and the new process is called the child.
If the fork system call fails, it will return -1.
If the fork system call is successful, the process ID of the child process is returned in the parent
process and a 0 is returned in the child process.
When a fork() system call is made, the operating system generates a copy of the parent process
which becomes the child process.
The operating system will pass to the child process most of the parent's process information.
However, some information is unique to the child process:
o The child has its own process ID (PID)

o The child will have a different PPID (Parent Process ID) than its parent
o System imposed process limits are reset to zero
o All recorded locks on files are reset
o The action to be taken when receiving signals is different

For example;
int main(void)
{
printf("Hello \n");
fork();
printf("bye\n");
return 0;
}

Hello - is printed once by parent process.


bye - is printed twice, once by the parent and once by the child
If the fork system call is successful, a child process is produced that continues execution at the point
where it was called by the parent process.
After the fork system call, both the parent and child processes are running and continue their
execution at the next statement in the parent process.
A summary of fork() return values follows:

fork_return > 0: this is the parent

fork_return == 0: this is the child

fork_return == -1: fork () failed and there is no child.

You might also like