You are on page 1of 2

Austria, Clarence jay D.

BSIT 201C

Task Performance Concurrency and Deadlocks


Part I: Counting Semaphore
1. In your perspective, what makes counting semaphore primitives a good concurrency
mechanism?
Semaphores are a fine-grained technique for regulating concurrency, and as such,
they have the potential for high performance at the cost of difficulty of usage. Race
situations are not only difficult to identify, but the mutual exclusion necessary to
eradicate them might result in deadlocks or starvation.
2. How does the structure of counting semaphore primitives differ from binary semaphore
primitives?
A Binary Semaphore is one with an integer value between 0 and 1. A counting
semaphore is a semaphore with several counter values. The value has an
unbounded range.
Part II: Binary Semaphore
3. Briefly explain the purpose of the semWaitB and semSignalB functions in Figure 2.
There are two functions in the binary semaphore code: semWaitB() and
semSignal() ().
The semWaitB() method is used to determine whether or not to enter the crucial
area. If the value is 1, it signifies that the crucial area is empty, and the operation
can begin by changing the value to 0. If it is 0, it must wait. When the process exits
the crucial part, the semSignalB() method is called. It returns the number 1 and
exits the section.
4. Based on Figures 1 and 2, which semaphore structure is easier to implement and why?
According to the two implementations, binary semaphore is simpler to construct
than counting semaphore. Because binary semaphore simply involves two
processes that are easily synchronized. However, counting semaphore has
numerous processes and is more complicated to construct than binary semaphore.
Part III: Monitor
5. Deduce at least one (1) characteristic of a monitor based on Figure 3. Elaborate on
your answer.
Mutual exclusion, in my opinion, is a programming language construct that
enforces mutual exclusion. A software package that comprises procedures, a
startup process, and local data. Local data is only accessible to the monitor's
procedures. A process can enter a monitor by activating one of its methods. Only
one process may be running in the monitor at any given time. Other processes that
try to launch a monitor procedure will fail. Mutual exclusion ensures that only one
process in the monitor is allowed to insert the shared data structure.
6. Would you agree that a monitor, as a concurrency mechanism, can support process
synchronization? Why or why not?
Every procedure in the monitor becomes a critical section for me, and any of the
strategies we've seen so far may be used to ensure that no other process can
enter any of the other functions while a process is in a CS. Monitors can, thus,
enable process synchronization.

You might also like