The following code exhibits certain race conditions. Please…

The following code exhibits certain race conditions. Please identify them and rearrange the code to correct them.  If needed, you may add additional lines like pthread_mutex_lock, etc. #include #include #include pthread_mutex_t mutex;pthread_cond_t cond;int ready = 0; void* worker(void* arg) {    printf(“Worker thread waiting…\n”);    while (!ready) {        pthread_cond_wait(&cond, &mutex);    }    printf(“Worker thread proceeding!\n”);    return NULL;} void* signaler(void* arg) {    sleep(1);    printf(“Signaler thread signaling!\n”);    pthread_cond_signal(&cond);    ready = 1;    return NULL;} int main() {    pthread_t t1, t2;    pthread_mutex_init(&mutex, NULL);    pthread_cond_init(&cond, NULL);     pthread_create(&t1, NULL, worker, NULL);    pthread_create(&t2, NULL, signaler, NULL);        pthread_join(t1, NULL);    pthread_join(t2, NULL);     pthread_mutex_destroy(&mutex);    pthread_cond_destroy(&cond);        return 0;}

Consider the following set of processes, their CPU burst tim…

Consider the following set of processes, their CPU burst times, their arrival times, and their priorities (where a higher priority is better) ProcessID  CPUBurstTime ArrivalTime Priority P1 3 0 4 P2 5 2 2 P3 2 5 6 P4 4 7 5   (a) (4pts) Draw a Gantt Chart (timeline) for the task schedule that would be generated using a First-Come, First-Serve scheduler. Find the average waiting time. (b) (4pts) Draw a Gantt Chart (timeline) for the task schedule that would be generated using a preemptive priority scheduler. Find the average waiting time. (c) (4pts) Draw a Gantt Chart (timeline) for the task schedule that would be generated using a preemptive Shortest Job First scheduler(of Shortest Remaining Time first). Find the average waiting time.   The Gantt chart can be drawn as follows since we are taking the test online.   p1(startime-duration) p2(start time – duration)