Part II: Binary Semaphore struet binary_semaphorel enum (zero, one) value; queueType queue; void semlaitB (binary_semaphore s) if (s.value -- one) s.value - zero; else ( /* place this process in s.queue /; /* block this process */: void semsignalB (semaphore s) if (s.queue is empty()) - one: s.value else i /* remove a process P from s.queue */; /* place process P on ready list */: Figure 2. A simple program structure of binary semaphore primitives. Questions: 3. Briefly explain the purpose of the semWaitB and semSignalB functions in Figure 2.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 21SA
icon
Related questions
Question
Part II: Binary Semaphore
struct binary_semaphore
enum (zero, one} value;
queueType queue;
void semwaitB (binary_semaphore s)
if (s.value -- one)
s.value - zero;
else {
/* place this process in s.queue */;
/* block this process */:
void semsignalB (semaphore s)
if (s.queue is empty ())
s.value - one;
else {
/* remove a process P from s.queue
/* place process P on ready list */;
Figure 2. A simple program structure of binary semaphore primitives.
Questions:
3. Briefly explain the purpose of the semWaitB and
semSignalB functions in Figure 2.
4. Based on Figures 1 and 2, which semaphore
structure is easier to implement and why?
Transcribed Image Text:Part II: Binary Semaphore struct binary_semaphore enum (zero, one} value; queueType queue; void semwaitB (binary_semaphore s) if (s.value -- one) s.value - zero; else { /* place this process in s.queue */; /* block this process */: void semsignalB (semaphore s) if (s.queue is empty ()) s.value - one; else { /* remove a process P from s.queue /* place process P on ready list */; Figure 2. A simple program structure of binary semaphore primitives. Questions: 3. Briefly explain the purpose of the semWaitB and semSignalB functions in Figure 2. 4. Based on Figures 1 and 2, which semaphore structure is easier to implement and why?
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Stack
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning