Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

04 Quiz 1

Platform Technology

Instructions: Analyze the given concurrency mechanism figures and answer the corresponding questions
for each type. Use 3-5 sentences in answering. (6 items x 5 points)

Part I: Counting Semaphore


Questions:

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


mechanism?
- As an overall semaphore, counting semaphore is also acknowledged. It only allows the
initialization, increment, and decrement operations, all of which are atomic, to be
performed. The process is blocked by the increment action, whereas it is unblocked by the
decrease operation. With semaphore, you can initialize more process resources because the
value has an unrestricted domain.

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

- Because the counting semaphore can complete the job more quickly than the binary
semaphore, I realized that the two primitives were different. While binary semaphore is straightforward,
the word binary only has two possible values: 0 and 1. He can carry out various activities that binary
semaphore cannot due to the words "count" and "universal semaphore."

Part II: Binary Semaphore


Questions:

2. Briefly explain the purpose of the semWaitB and semSignalB functions in Figure 2.
- The semaphore's value is decreased by one via the semWaitB procedure. The semaphore is
decremented once its value rises over zero. The semSignalB function will carry out a SIGNAL
action on the supplied semaphore. To be more precise, if the process's value is zero (zero), it
will be halted and unable to move on. However, if the process value is 1, the process will
carry on. In semSignalB, the semaphore value is set to 1, but it is blank in semSignalA. If not,
one is added to the queued processes for the ready list. For instance, the process must be
set to 1 in order to process a request if the queue is empty.

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

- My opinion is that the binary semaphore is easier to use than the counting semaphore. due to
binary semaphore's limited support for 0 and 1 values. The binary semaphore value can only be either 0
or 1, so to speak. The wait action is successful when the semaphore is equal to 1, and the signal
operation is successful when the semaphore is equal to 0.

Part III: Monitor


Questions:

5. Deduce at least one (1) characteristic of a monitor based on Figure 3. Elaborate on your
answer.

- The line for entering processes, which is where the process makes its grand entrance, is one of
a monitor's properties. Without this property, the process cannot enter the monitor, and the monitor
concurrency does not exist.

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

- Yes, as mutual exclusion within programming language processes is carried out using the
monitor. Although the processes running outside the monitor are unable to access its internal variables,
they are able to call its procedures. Additionally, only one process at a time can run the monitors' code.
As a result, monitors make parallel programming easier to manage and less error-prone than
semaphore-based approaches.

You might also like