Question: Operating Systems Questions: In the readers/writers problem, explain what semaphores mutex and db do, and how they work in reader's and writer's processess, respectively HERE
Operating Systems Questions:
In the readers/writers problem, explain what semaphores mutex and db do, and how they work in reader's and writer's processess, respectively

HERE
typedef int semaphore; semaphore mutex1; semaphore db 1 int rc 0; /* use your imagination/ /* controls access to rc /controls access to the database/ /* # of processes reading or wanting to */ void reader(void) /* repeat forever/ /*get exclusive access to rc/ /one reader more now /* if this is the first reader ...*/ /release exclusive access to rc / access the data/ /* get exclusive access to rc*/ /*one reader fewer now /if this is the last reader / release exclusive access to rc/ * noncritical region / while (TRUE) down(&mutex); if (rc1) down(&db);/* this up(&mutex) read_data_base(); down(&mutex); rc rc 1 if (rc0 up(&db); up(&mutex) use_data read(); void writer(void) * repeat forever/ /* noncritical region /* get exclusive access/ *update the data*/ / release exclusive access while (TRUE) think up_data(); down(&db); write_data base(); up(&db) Figure 2-48. A solution to the readers and writers problem typedef int semaphore; semaphore mutex1; semaphore db 1 int rc 0; /* use your imagination/ /* controls access to rc /controls access to the database/ /* # of processes reading or wanting to */ void reader(void) /* repeat forever/ /*get exclusive access to rc/ /one reader more now /* if this is the first reader ...*/ /release exclusive access to rc / access the data/ /* get exclusive access to rc*/ /*one reader fewer now /if this is the last reader / release exclusive access to rc/ * noncritical region / while (TRUE) down(&mutex); if (rc1) down(&db);/* this up(&mutex) read_data_base(); down(&mutex); rc rc 1 if (rc0 up(&db); up(&mutex) use_data read(); void writer(void) * repeat forever/ /* noncritical region /* get exclusive access/ *update the data*/ / release exclusive access while (TRUE) think up_data(); down(&db); write_data base(); up(&db) Figure 2-48. A solution to the readers and writers
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
