Question: We are creating a C program with the following process synchronization behavior. This synchronization process continues forever. Please choose the proper statements for the lines
We are creating a C program with the following process synchronization behavior. This synchronization process continues forever. Please choose the proper statements for the lines through Each statement should be one of the following statements: points
apause
bkill ppid SIGUSR
ckill cpid SIGUSR
dkill gcpid SIGUSR
ekill pid SIGUSR
falarm
galarm
hraiseSIGUSR
Parent Process
SIGUSR SIGUSR
Child
SIGUSR
SIGUSR
Grand Child
synchro example for kill
#include #include #include #include
int ntimes ; int ntimes; int ntimes;
int main
pidt ppid, cpid, gcpid, pid;
void pactionint cactionint gcactionint; static struct sigaction pact, cact, gcact;
pact.sahandler paction; sigactionSIGUSR &pact, NULL;
switchcpid fork case : error
signal!
perrorsynchro; exit;
case : grandchild gcact.sahandler gcaction;
sigactionSIGUSR &gcact, NULL; cpid getppid; infinite for loop for exchanging
for;;
perrorsynchro; exit;
case : child
switchgcpid fork case : error
sleep; ; ;
default : child cact.sahandler caction;
sigactionSIGUSR &cact, NULL; ppid getppid; infinite for loop for exchanging signal!
for;;
sleep;
parent!!
infinite for loop for exchanging signal!
for;;
; sleep; ;
void pactionint sig
printfParent caught signal with ntimes #d
ntimes;
void cactionint sig
printfChild caught signal with ntimes #d
ntimes;
void gcactionint sig
printfGrand Child caught signal with ntimes #d
ntimes;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
