Reference no: EM133220383
Question 1.
A parent process fork()s a child process to compute a boolean result. The child process computes the result, and wants to send one of two values (either 0 or 1) back to the parent. Can this be done with signals? If so, how? If not, why not?
Question 2.
A paret process fork()s a child process to compute a complicated result. The child process computes the result, and wants to send an object (e.g. C struct instance or C++ class instance) back to the parent. Can this be done with signals? If so, how? If not, why not?
Question 3.
Why is it important to have a SIGCHLD handler for most parent processes that fork()s child processes?
What should the SIGCHLD handler do?
Question 4.
Why is the following:
while ( !object.isReady() )
pthread_cond_wait(&cond,&mutexLock);
a better idea than just:
if ( !object.isReady() )
pthread_cond_wait(&cond,&mutexLock);
Question 5.
Thread routines look like void* threadRoutine (void* vPtr). Why do they take type void*?
Why do they return type void*?
Question 6.
Why do pthread_cond_t conditions exist?
They are not mutual exclusion, that is done by pthread_mutex_t locks. So,what problem do they solve?