04 Activity 1 - ARG
Donmarc Gonzales BSIT 302
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
1. In your perspective, what makes counting semaphore primitives a good
concurrency mechanism?
It is possible to employ threads and their associated processes with certainty by using
semaphore primitives like wait () and post () to count semaphore primitives. It helps
to make sure that under typical conditions, none of the procedures fail. Semaphores
function to guarantee that every process is correct in every state and that no
duplication is implemented or otherwise because every application tends to have
threads with their own dedicated processes.
2. How does the structure of counting semaphoreprimitives differ from binary
semaphore primitives?
Mutual exclusion is present in Binary Semaphores but is absent from Counting
Semaphores. They use various methods to process numbers. The primary difference
is that Binary manages the mutex whereas Semaphores manage the signaling
(mutual exclusion). Binary prevents many threads from accessing the crucial area,
while counting semaphore does.
Part II: Binary Semaphore
3. Briefly explain the purpose of the semWaitB and semSignalB functions in
Figure 2.
The execution of a semaphore lock action is caused by the Sem wait function, which
locks certain semaphore circumstances. As illustrated in Figure 2, two variables are
started inside the struct and are completed in the if statement inside procedure 1
semWaitB. The conditions are blocking and adding the process to a queue. While
semSignalB acquires a process action involving the removal of a process from the
queue and the addition of a freshly created process to the ready list. In conclusion,
semSignalB is in charge of the process instance in the queue, whereas semWaitB is
in charge of process blocking and placement.
4. Based on Figures 1 and 2, which semaphorestructure is easier to implement and
why?
A binary semaphore is easier to implement. A binary semaphore can be used by a
single thread to talk to another thread. concurrent resource access necessitates the
use of increasingly complex algorithms for priority execution. While N processes
are carried out by Counting Semaphore, which also permits the execution of
additional tasks. Figure 1 depicts the application of counting semaphores.
incrementing and decreasing values as well as adding and removing processes from
the queue. This opens up the crucial sector to more duties and procedures. Figure 2
shows how to implement process locking. Only two values—1 and 0—can be used
for each job at a time to perform a sort close/open action.
Part III: Monitor
5. Deduce at least one (1) characteristic of a monitor based on Figure 3. Elaborate on
your answer
It's a phrase used to define the characteristics of approaches that carry out mutual
exclusion. A thread always performs procedures in a logical sequence because
mutual exclusion prevents race conditions (the appearance of multiplexed
unmanageable events). the capacity to hold off on acting until a condition (or block)
becomes untrue. Therefore, the execution technique is important if we look at the
monitor structure in figure 3. Anyone in the urgent line is given priority in the
process status. However, in other situations, the wait states, such as c1 and cn, need
c1 to continue existing until its requirements are satisfied. Depending on which
procedure occurs first, the first two conditions will be blocked, and the last one will
do the same. For processing in order to fill the urgent vacancy, procedure K is
available. situation before a new process is launched and before the old one is
prepared to end.
6. Would you agree that a monitor, as a concurrency mechanism, can support process
synchronization? Why or why not?
It is impossible to exaggerate the significance of synchronization in regard to
concurrency techniques. Because monitoring is provided by programming
languages, achieving mutual exclusion between processes is one feasible goal.
ensuring the consistency of all shared data and executing collaborative
processes. Having said that, it is essential that each process be carried out
methodically in order to prevent racial bias or inconsistent data.