Question
With the system calls kill(), pause() and wait() we can synchronize processes that access the same data. This happens because kill() wakes up simultaneously all
With the system calls kill(), pause() and wait() we can synchronize processes that access the same data. This happens because kill() wakes up simultaneously all the processes that wait for a signal. However, a signal does not have any dedicated memory space from the system. Thus, if a process loses a signal there is no way to trace it back. This is a danger for the system. For example, there is a case that a process waits for a signal that was sent before that process could execute the signal() or pause() system calls. In that case the process would wait for a signal that was lost and it will never be sent again. On the contrary, the wait() system call, is more convenient. wait() returns 1 if a child process has already finished. Otherwise, it waits for the SIGCHLD. Check the code below and decide if we can use it for synchronizing processes. Can we guarantee that it would work forever without any synchronization issues?
p r e vi o u s = s i g n a l ( r e s p o n s e s i g n a l , o ni n t r ) ;
i f ( f o r k ( ) == 0 ) pause ( ) ;
e l s e {
s i g n a l ( r e s p o n s e s i g n a l , p r e vi o u s ) ;
k i l l ( pid , r e q u e s t s i g n a l ) ;
w ai t (& s t a t u s ) ;
} . . . . . .
o ni n t r ( ) {
e x i t ( 1 ) ;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started