Lab 5
Lab 5
F2022266697
Output:
1
We can distinguish child and parent processes because fork () returns 0 inside the child
process and returns a positive integer inside the parent process
Example #2
Output:
2
What is Exit System Call?
The call to exit () terminates the calling process without executing the rest code which is after
the exit () function
Syntax:
Example:
3
Output:
4
It returns (an int) from main
Example # 1
Output:
Lab Task
1. Call fork () system call three times in a process and display a msg. What will be the
output and also explain your output? i.e how many childrens are created and what
trend they are following. How many child process will be created if fork () is called
four times?
5
Output
6
2. Print first 5 odd numbers through child process. Parent process must wait for the child
process then after 2 seconds delay pddarent process should display first 5 prime
numbers.
Output
7
Task 3