Consider the code example for allocating and releasing processes shown below:
$#define MAX PROCESSES 255
int number of processes = 0;
/* the implementation of fork() calls this function */
int allocate process() {
int new pid;
if (number of processes == MAX PROCESSES)
return -1;
else {
/* allocate necessary process resources */
++number of processes;
return new pid;
}
}
/* the implementation of exit() calls this function */
void release process() {
/* release process resources */
--number of processes;
}$
a. Identify the race condition(s).
b. Assume you have a mutex lock named mutex with the operations $acquire()$ and $release()$. Indicate where the locking needs to be placed to prevent the race condition(s).
c. Could we replace the integer variable int number of processes = 0 with the atomic integer atomic t number of processes = 0 to prevent the race condition(s)?