adplus-dvertising
frame-decoration

Question

The semaphore variables full, empty and mutex are initialized to 0, n and 1, respectively. Process P1 repeatedly adds one item at a time to a buffer of size n, and process P2 repeatedly removes one item at a time from the same buffer using the programs given below. In the programs, K, L, M and N are unspecified statements.

 P1
while (1) {     K; P(mutex); Add an item to the buffer; V(mutex);     L; } P2 while (1) {    M; P(mutex); Remove an item from the buffer; V(mutex);     N; }

The statements K, L, M and N are respectively

a.

P(full), V(empty), P(full), V(empty)

b.

P(full), V(empty), P(empty), V(full)

c.

P(empty), V(full), P(empty), V(full)

d.

P(empty), V(full), P(full), V(empty)

Answer: (d).P(empty), V(full), P(full), V(empty)

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. The semaphore variables full, empty and mutex are initialized to 0, n and 1, respectively. Process P1 repeatedly adds one item at a time to a buffer of size n, and process...

Similar Questions

Discover Related MCQs

Q. Consider a non-negative counting semaphore S. The operation P(S) decrements S, and V(S) increments S. During an execution, 20 P(S) operations and 12 V(S) operations are issued in some order. The largest initial value of S for which at least one P(S) operation will remain blocked is ________.

Q. In the working-set strategy, which of the following is done by the operating system to prevent thrashing?

1.It initiates another process if there are enough extra frames.
2.It selects a process to suspend if the sum of the sizes of the working-sets exceeds the total number of available frames.

Q. Processes P1 and P2 use critical_flag in the following routine to achieve mutual exclusion. Assume that critical_flag is initialized to FALSE in the main program.

get_exclusive_access ( ) { if (critical _flag == FALSE) { critical_flag = TRUE ; critical_region () ; critical_flag = FALSE; } }

Consider the following statements.
i. It is possible for both P1 and P2 to access critical_region concurrently.
ii. This may lead to a deadlock.
Which of the following holds?

Q. An operating system implements a policy that requires a process to release all resources before making a request for another resource. Select the TRUE statement from the following:

Q. If the time-slice used in the round-robin scheduling policy is more than the maximum time required to execute any process, then the policy will

Q. Consider the following C code for process P1 and P2. a=4, b=0, c=0 (initialization)
P1 P2
if (a < 0) b = 10;
c = b-a; a = -3;
else
c = b+a;
If the processes P1 and P2 executes concurrently (shared variables a, b and c), which of the following cannot be the value of ‘c’ after both processes complete?

Q. Which of the following is NOT a valid deadlock prevention scheme?

Q. More than one word are put in one cache block to

Q. Consider Peterson’s algorithm for mutual exclusion between two concurrent processes i and j. The program executed by process is shown below.

repeat
flag [i] = true;
turn = j;
while ( P ) do no-op;
Enter critical section, perform actions, then exit critical
section
flag [ i ] = false;
Perform other non-critical section actions.
until false;

For the program to guarantee mutual exclusion, the predicate P in the while loop should be.

Q. Which combination of the following features will suffice to characterize an OS as a multi-programmed OS?

(a) More than one program may be loaded into main memory
at the same time for execution.
(b) If a program waits for certain events such as I/O,
another program is immediately scheduled for execution.
(c) If the execution of program terminates, another program
is immediately scheduled for execution.

Q. Consider the following statements with respect to user-level threads and kernel supported threads

i. context switch is faster with kernel-supported threads
ii. for user-level threads, a system call can block the
entire process
iii. Kernel supported threads can be scheduled independently
iv. User level threads are transparent to the kernel

Which of the above statements are true?

Q. The minimum number of page frames that must be allocated to a running process in a virtual memory environment is determined by

Q. Consider a small two-way set-associative cache memory, consisting of four blocks. For choosing the block to be replaced, use the least recently used (LRU) scheme. The number of cache misses for the following sequence of block addresses is 8, 12, 0, 12, 8

Q. Suppose that we have an ordered file with one million records, stored on a disk. The block size is 2048b, records are of fixed size and are unspanned. The record length is 256b., then what is the number of blocks required for the data file.

Q. Let the ordering key field of the file is 10 bytes long and a block pointer is 6 bytes long and a primary index has been constructed for the file. Then to search a record using index how many block access are required??

Q. Memory, also called random access memory, or RAM

Q. CPU scheduling takes place when