Question: The int sem _ trywait ( sem _ t * sem ) operation blocks if ( a ) the semaphore value > 0 (

The "int sem_trywait (sem_t *sem)" operation blocks if
(a) the semaphore value >0
(b) the semaphore value =0
(c) it never blocks
(d) None of the above
Which of the following CORRECT about the sem_init function shown below.
int sem_init(sem_t *sem, int pshared, unsigned int value);
(a) It is used to initialize both named and unnamed semaphores and to assign the value
specified by the "value" parameter to the semaphore.
(b) It is used to initialized named semaphores only and to assign the value specified by the
"value" parameter to the semaphore.
(c) the pshared variable is used to specify whether the semaphore can be used within the
calling process only or it can be used by multiple processes.
(d)(b) and (c)
(e) None of the above
In the pseudo-code blow, what initial values of the semaphores S and Q will cause the two pro-
cesses to alternate in executing their printf statements such that the output is A , B, A, B, A , B, A , B,...
(a)S=0,Q=0
(b)S=1,Q=1
(c)S=0,Q=1
(d)S=1,Q=0
(e) None of the above
 The "int sem_trywait (sem_t *sem)" operation blocks if (a) the semaphore

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!