You are on page 1of 2

Name: Marlon M.

Famis
Section: BSIT 301
Part I: Counting Semaphore
1. In your perspective, what makes counting semaphore primitives a good concurrency mechanism?
 Using semaphore primitives like wait () and post () to count semaphore primitives allows for
definitive use of threads and their processes. It assists in ensuring that all processes do not fail
under normal circumstances. Because every application tends to have threads with their own
dedicated process, semaphores operate to ensure that every process is correct in each state and
that no duplication is implemented or otherwise.
2. How does the structure of counting semaphore primitives differ from binary semaphore
primitives?
 Mutual exclusion is not included in Counting Semaphores, but it is in Binary Semaphores. They
process numbers in different ways. The main distinction is that Semaphores handle the signaling
whereas Binary handles the mutex (mutual exclusion). Counting Semaphore allows for several
instances of threads to access the vital area, whereas binary does not.
Part II:

3. Briefly explain the purpose of the semWaitB and semSignalB functions in Figure 2.
 The Sem wait function locks certain semaphore conditions, resulting in the execution of a
semaphore lock action. Two variables are initiated inside the struct and are done in the if
statement inside method 1 semWaitB, the conditions are of placing process in a queue and
blocking, as shown in Figure 2. While semSignalB obtains a process operation that involves
removing a process from the queue and adding a newly formed process to the ready list. To
summarize, semWaitB is responsible for process blocking and placement, while semSignalB is in
charge of the process instance in the queue
4. Based on Figures 1 and 2, which semaphore structure is easier to implement and why?
 The implementation of a binary semaphore is simpler. A single thread can use a binary
semaphore to communicate with another thread. access resources at the same time, requiring
more sophisticated algorithms for priority execution. While Counting Semaphore performs N
processes and allows for the execution of more activities. The implementation of Counting
Semaphores may be seen in Figure 1. Adding and deleting processes from the queue, as well as
incrementing and decrementing values. This enables more tasks and processes to gain access
to the vital sector. Figure 2 demonstrates process locking, with each value confined to only two
(1 and 0) that can conduct a sort close/open action for only one task at a time.
Part III: Monitor

5. Deduce at least one (1) characteristic of a monitor based on Figure 3. Elaborate on your answer.
 It's a term that describes properties of methods that use mutual exclusion to execute them.
Because mutual exclusion precludes race situations (the occurrence of multiplexed
unmanageable events), a thread executes methods in a logical order at all times. The ability to
wait for a condition (or block) to become false before acting. So, if we look at the monitor
structure in figure 3, the execution method is relevant. The process status is prioritized for
whoever is in the urgent queue. Other circumstances, however, the wait states, such as c1 and
cn, need c1 to remain until its criteria are met. (The first two conditions will be blocked depending
on which process comes first.) and the last one follows suit). Procedure k is ready for processing
in order to fill the urgent vacancy. state before the previous process is ready to terminate and
before a new one is started.
6. Would you agree that a monitor, as a concurrency mechanism, can support process
synchronization? Why or why not?
 The importance of synchronization in relation to concurrency mechanisms cannot be overstated.
Because monitoring is supported by programming languages, one conceivable purpose is to
achieve mutual exclusion between processes. Assuring that all shared data is kept consistently,
as well as collaborating process execution. Having said that, it is critical that each operation is
handled in a systematic manner in order to avoid race conditions or data inconsistency.

You might also like