0% found this document useful (0 votes)
22 views

OSQUIZ

Counting semaphore primitives are a good concurrency mechanism because they can be initialized, incremented, and decremented. Their value can range unlimited and they control access to resources that have multiple instances. They allow N processes to access a shared resource simultaneously, improving performance over binary semaphores which only allow one process at a time. Counting semaphores differ from binary semaphores in that they can have values other than just 1 or 0. They control access to resources with multiple instances, whereas binary semaphores only allow one process in the critical section. The semWaitB and semSignalB functions in Figure 2 are used to decrement/increment the semaphore value and add/remove processes from

Uploaded by

Orange Shelly
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

OSQUIZ

Counting semaphore primitives are a good concurrency mechanism because they can be initialized, incremented, and decremented. Their value can range unlimited and they control access to resources that have multiple instances. They allow N processes to access a shared resource simultaneously, improving performance over binary semaphores which only allow one process at a time. Counting semaphores differ from binary semaphores in that they can have values other than just 1 or 0. They control access to resources with multiple instances, whereas binary semaphores only allow one process in the critical section. The semWaitB and semSignalB functions in Figure 2 are used to decrement/increment the semaphore value and add/remove processes from

Uploaded by

Orange Shelly
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

In your perspective, what makes counting semaphore primitives a good concurrency


mechanism?

Because it can initialize, increment, and decrement, counting semaphore primitives are a good
concurrency mechanism, in my opinion. Its value can be applied throughout an unlimited range.
It controls access to a resource that has several instances of it. The system performs better than
the binary semaphores because N processes can use the crucial region, which is a resource. This
characteristic makes the counting semaphore a suitable concurrency method.

2. How does the structure of counting semaphore primitives differ from binary semaphore
primitives?

Because counting semaphores can have count values other than just 1 and 0, their structure is
different from that of binary semaphores. In contrast to the binary semaphore, which only
contains the numbers 0 and 1, it controls access to a resource that has numerous instances. It
only permits one process at a time to enter the crucial area.
3. Briefly explain the purpose of the semWaitB and semSignalB functions in Figure 2.

- SemWaitB's objective was to accept the procedure and assess its worth. If the value is 1, it will
be decreased until it is 0 and added to the queue. The process is stalled and will loop until the
next process is initiated if the value is 0.
- semWaitB function's job was to pass the process to semSignalB. The process will be added to
the ready list and run soon if it has a value of 0. The process will be eliminated from the queue if
its value is 1 and will remain there until its value is 0.
4. Based on Figures 1 and 2, which semaphore structure is easier to implement and why?

Because it just has two integer values—1 and 0—the binary semaphore is easier to create than
the counting semaphore. One process at a time is the only one that can access the vital area. As
a result, managing and implementing it is simpler.
5. Deduce at least one (1) characteristic of a monitor based on Figure 3. Elaborate on your
answer.
A monitor is an instance of a class that many threads can safely use, as seen in Figure 3. The
procedures of a monitor are executed mutually exclusive. As a result, one thread can run a
monitor method simultaneously. The creation of method content and engagement with the
monitor are made easier by this mutual exclusion strategy.

6. Would you agree that a monitor,


as a concurrency mechanism, can
support process synchronization?
Why or
why not?
6. Would you agree that a monitor, as a concurrency mechanism, can support process
synchronization? Why or why not?

Since a monitor's methods are all run with mutual exclusion, as was said in response to question
4, I agree that a monitor may provide process synchronization. Users do not need to
comprehend how the synchronization code in the monitor works because it is concentrated in
one place. The quantity of processes has no impact on the code. It only applies to the processes
that I want it to.

You might also like