wait system call | os cs8461 | 4th sem of cse | operating system lab | QT

Опубликовано: 03 Ноябрь 2024
на канале: Quick Through
463
13

operating system laboratory for cse engineering playlist
   • Operating System  

Exp# 2b wait system call
Date:
Aim
To block a parent process until child completes using wait system call.
wait()
The wait system call causes the parent process to be blocked until a child terminates.
When a process terminates, the kernel notifies the parent by sending the SIGCHLD signal to
the parent.
Without wait, the parent may finish first leaving a zombie child, to be adopted by init process
Algorithm
1. Create a child process using fork system call.
2. If return value is -1 then
a. Print "Process creation unsuccessfull"
3. Terminate using exit system call.
4. If return value is 0 then
a. Suspend parent process until child completes using wait system call
b. Print "Parent starts"
c. Print even numbers from 0–10
d. Print "Parent ends"
5. If return value is 0 then
a. Print "Child starts"
b. Print odd numbers from 0–10
c. Print "Child ends"
6. Stop