Question
Problem 1.) How is the operating system able to resume a process where it left off? What structures and /or tables are used? Problem 2.)
Problem 1.) How is the operating system able to resume a process where it left off? What structures and /or tables are used?
Problem 2.) You are performing a design review of work done by a developer. In one section, he has a design that uses two semaphores to limits access to code that updates a global variable, turn to all but one process. Do you see any problems with his design?
Process 0 Process 1
---------- ----------
down(S); down(Q);
down(Q); down(S);
turn++; turn--;
up(S); up(Q);
up(Q); up(S);
Problem 3.) In the bounded buffer synchronous problem diagrammed below, identify the critical section(s). Explain why they are critical sections. Give an example of the flow of a race condition. Discuss where solutions are being or can be applied to prevent race conditions.
#define N 100 int count = 0; I* number of slots in the buffer / I* number of items in the buffer / void producervoid) int item; while (TRUE) { item = produce_item( ); if (count == N) sleep(); insert_item(item); count = count + 1; if (count == 1) wakeup(consumer); (* repeat forever +/ (* generate next item */ Iif buffer is fullgo to sleep +/ I put item in buffer +/ /increment count of items in buffer */ 1+ was buffer empty? +/ void consumer(void ) int item; while (TRUE) { I repeat forever +/ if (count e=0) sleep() ; / if buffer is empty, got to sleep +/ item = remove item( ); I+ take item out of buffer +/ count = count - 1 /decrement count of items in buffer / if (count == N 1) wakeup(producer); I x was buffer full? +/ consume_item(item); (* print item +/Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started