Starting from:
$30

$24

Operating System Lab 04 Solution

Lab Activity




Activity 1)




Write a program that accomplish the following purpose:




Call the system call to create the child process and store the value returned from the call.



If the returned value is less than zero,



Print ‘Unsuccessful Child Process Creation”. ii. Terminate using exit system call



If the return value is greater than zero



Add a wait system call so that the parent would wait for child process to complete.



Make a loop that prints even numbers from 1 - 10



Print “Parent Ends”



If the return value is equal to zero



Print the parent ID



Make a loop that prints odd numbers from 1 - 10 iii. Print “Child Ends”



Stop






Activity 2)




Write a program to declare a counter variable initialized by zero. After fork() system call two processes will run in parallel both incrementing their own version of counter and print numbers 1 -5 . After printing numbers child process will sleep for three second, then print process id of its grandparent and terminates by invoking a gedit editor. Meanwhile, its parent waits for its termination.







Activity 3)




Write a program which creates processes 4 processes for parallel programming. Each parent will wait for the termination of its child.







Main process


Process P1 waiting for


Process p2 waiting for


Process p3 runs a bash












p2


p3


command























Activity 4)




Google execl(), execlp() system call and study more about it than what is written in the manual.

https://www.mkssoftware.com/docs/man3/execl.3.asp




Activity 5)




Implement the following 9 tree structure. Each node must print its name and PID.

e.g. I am Process A and my PID is 2453

More products