You are on page 1of 2

04 Quiz 1 - ARG

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


mechanism?

 For me, the main difference between the counting and binary semaphores is, the
binary semaphore allows only one process into the critical section and the counting
semaphore allows multiple processes. Because of this feature, the counting
semaphore gives better performance compared to binary semaphore. Based on this
perspective the counting semaphore primitives a good concurrency mechanism.

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

 For me, the binary semaphore contains only 2 values 0 and 1, but the counting
semaphore contains N values, and it allows N processes at a time. s, counting
semaphore does not have the mutual exclusion property. The binary semaphores
enter only one process at a time, so it has mutual exclusion property.

3. Briefly explain the purpose of the semWaitB and semSignalB functions in Figure 2.?

 In the binary semaphore code, it contains two functions, that are semWaitB() and
semSignalB().

 The semWaitB() function is used to check the condition to enter into the critical
section. It the value is 1 that means critical section is empty, so that process can
enter by changing the value to 0. If it is 0 then it has to wait. The semSignalB()
function is used to when the process coming out of the critical section. It makes the
value 1 and come out of the section.

4. Based on Figures 1 and 2, which semaphore structure is easier to implement and why?

 Based on the two implementations, Binary semaphore is easy to implement than the
counting semaphore. Because in binary semaphore only two processes are involved,
and it is easy to synchronize them. But in counting semaphore it contains many
processes and it is little difficult to implement than binary semaphore.
5. Deduce at least one (1) characteristic of a monitor based on Figure 3. Elaborate on your
answer.
 For me, mutual exclusion is a programming language concept that ensures mutual
exclusion. A piece of software that includes of procedures, an initialization process,
and local data. Only the monitor's procedures have access to local data. By
activating one of its methods, a process can enter a monitor. At any given moment,
only one process may be running in the monitor. Other processes that attempt to
invoke a monitor procedure will be thwarted. Mutual exclusion is guaranteed. only
one process is permitted in the monitor 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?
 For me, every method in the monitor becomes a critical section, and any of the
techniques 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. So yes, monitors can support
process synchronization.

You might also like