answersLogoWhite

0

AllQ&AStudy Guides
Best answer

contct to damit for this.

This answer is:
Related answers

contct to damit for this.

View page

Priority inversion is a situation where in lower priority

tasks will run blocking higher priority tasks waiting for

resource (mutex). For ex: consider 3 tasks. A, B and C, A

being highest priority task and C is lowest. Look at

sequence of context swaps

A goes for I/O . unlocks mutex.

C was ready to run. So C starts running. locks mutex

B is ready to run. Swaps out C and takes mutex.

A is ready to run. but A is blocked as mutex is locked by B.

but B will never relinqishes the mutex as its higher

priority than C.

The solution to priority inversion is Priority inheritance.

View page

The uses of a mutex can indeed be described, however some of the more notable uses are that of cleaning and disinfecting area so that germs can not be spread from area to area.

View page

#define CHAIRS 5 /* # chairs for waiting customers */

typedef int semaphore; /* use your imagination */

semaphore customers = 0; /* # of customers waiting for service */

semaphore barbers = 0; /* # of barbers waiting for customers */

semaphore mutex = 1; /* for mutual exclusion */

int waiting = 0; /* customer are waiting (not being cut) */

void barber(void)

{

while (TRUE) {

down(&customers); /* go to sleep if # of customers is 0 */

down(&mutex); /* acquire access to "waiting' */

waiting = waiting - 1; /* decrement count of waiting customers */

up(&barbers); /* one barber is now ready to cut hair */

up(&mutex); /* release 'waiting' */

cut_hair(); /* cut hair (outside critical region */

}

}

void customer(void)

{

down(&mutex); /* enter critical region */

if (waiting < CHAIRS) { /* if there are no free chairs, leave */

waiting = waiting + 1; /* increment count of waiting customers */

up(&customers); /* wake up barber if necessary */

up(&mutex); /* release access to 'waiting' */

down(&barbers); /* go to sleep if # of free barbers is 0 */

get_haircut(); /* be seated and be served */

} else {

up(&mutex); /* shop is full; do not wait */

}

}


View page

Multi-threading in c sharp is a system with different tutorial. Like: interaction between threads, producer, using thread pool and using mutex objects.

View page
Featured study guide
📓
See all Study Guides
✍️
Create a Study Guide
Search results