In the Modern Operating Systems Text! In figure 6-1 the resources are returned i
ID: 3818278 • Letter: I
Question
In the Modern Operating Systems Text! In figure 6-1 the resources are returned in the reverse order of their acquisition. Would giving them back in the order be just as good? Figure 6.1 is on page 438 of the Modern Operation Systems fourth edition textbook...""I started my query off with the text. but this is a clarification post for anonymous""
Figure 6.1 is as such!!!
(a) (b)
typedef int semaphore; typedef int semaphore;
semaphore resource_1; semaphore resource_1
semaphore resource_2
void process_A(void) { void process_A(void){
down(&resource_1); down(&resource_1);
use_resource_1(); dowm(&resource_2);
up(&resource_1); use_both_resources();
} up(&resource_2);
up(&resource_1);
}
The question is about Deadlocks and Resouce Acquisition
Explanation / Answer
Answer:
In the question given above we have been given two examples. In the first example we have been given a semaphore which has a defined resource 1 which can be used by first setting its mutex down and then using the resource and after resource is utilized the mutex is set to up. Similarly in the second situation where we have given two instances of resources where both the resouces are first set down and after making the use of both the resources consecutively we will set the mutex up.
So from above we can simply say that semaphore is used widely in operating systems where it can be used for acquisition of resources.