Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Making Databases Work The Pragmatic Wisdom Of Michael Stonebraker

Authors: Michael L. Brodie

1st Edition

1947487167, 978-1947487161

More Books

Students also viewed these Databases questions

Question

5. Develop a self-management module for a training program.

Answered: 1 week ago