I have this question in my exam and I want to know if my answer is correct.Consider the following program written in C language to implement a reader:// to simplify the exercise, are not checked the return values of calls to the operating system int main(int argc, char* argv[]) {     sem_t *sem_wrt;     int fd, readcount;     fd=shm_open(/readcount,O_RDWR|O_CREAT,S_IRUSR|S_IWUSR);     ftruncate(fd, sizeof(int));     readcount=mmap(0,sizeof(int),PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);     sem_wrt=sem_open(/write,O_CREAT ,0xFFFFFFFF,1);     while(1) {        readcount++;        if (readcount==1) sem_wait (wrt);        my_read();        (readcount)--;        if (readcount==0) sem_post (wrt);     } }After some time of using this program, it was found that the program only works properly when it is executed only by a process simultaneously.Change the code of the program in order to provide a solution to this problem.int main(int argc, char* argv[]) {     sem_t *sem_wrt;     int fd, readcount;     fd=shm_open(/readcount,O_RDWR|O_CREAT,S_IRUSR|S_IWUSR);     ftruncate(fd, sizeof(int));     readcount=mmap(0,sizeof(int),PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);     sem_wrt=sem_open(/write,O_CREAT ,0xFFFFFFFF,1);     //sem_mutex=sem_open(/mutex,O_CREAT ,0xFFFFFFFF,1);     while(1) {        //sem_wait(mutex);        readcount++;        if (readcount==1) sem_wait (wrt);        //sem_post(mutex);        my_read();        //sem_wait(mutex);        (readcount)--;        if (readcount==0) sem_post (wrt);        sem_post(mutex);     } }
Processes and semaphores in C
c