You are on page 1of 2

V.

Evaluate my Learnings
Name:_____________________ _____________________________Score:_________________ Course/
Section____ _______Schedule:___ ___Date Submitted:___ ___

1. Explain why Windows and Linux implement multiple locking mechanisms. Describe the circumstances under
which they use spinlocks, mutex locks, semaphores, and condition variables. In each case, explain why the
mechanism is needed.
Windows and Linux operating systems use multiple locking mechanisms for the reason that there are
different types of locking mechanisms used depending on the application need. Spinlocks are used in
multiprocessor systems which have threads that are able to run in a busy-loop. On the other hand,
mutex locks are utilized in locking resources and commonly used with a spinlock on multiprocessor
machines while semaphores and condition variables are useful for synchronization of resource that is
held for a long period of time (opposite of spinlocks where resource is held for a short period of time).

2. Describe how deadlock is possible with the dining-philosophers problem.


The dining philosophers’ problem has a possibility of deadlock because the philosophers don’t speak to
each other. The deadlock can happen when each philosopher holds a chopstick on their left hand (or
right); with the given situation, everyone will just wait for the other chopstick endlessly causing a ‘cycle
of unwarranted requests’.

3. Explain the difference between signaled and non-signaled states with Windows dispatcher objects.
The difference between signaled and non-signaled states in Windows dispatcher objects is that an
object in signaled state is available and when it tries to acquire a thread, it will not be blocked. At the
time the lock is acquired, the object will be in non-signaled state but when the lock is released, it comes
back to being in signaled state.

4. Assume val is an atomic integer in a Linux system. What would be the value of val after the following operations
have been completed? atomic set(&val,10); atomic sub(8,&val); atomic inc(&val); atomic inc(&val); atomic
add(6,&val); atomic sub(3,&val);
At first, the value of val is 10, then 8 is subtracted (10-8 = 2), after that, there are two atomic inc(&val)
thus adding to 1s (2 + 1 + 1 = 4). Next, 6 is added with atomic add (4 + 6 = 10) and lastly, 3 is subtracted
at atomic sub (10 – 3 = 7) so the final value of val is 7.

5. Using the banker’s algorithm, determine whether or not each of the following states is unsafe. If the state is
safe, illustrate the order in which the threads may complete. Otherwise, illustrate why the state is unsafe.
a. Available = (0, 3, 0, 1)

1
b. Available = (1, 0, 0, 2)

a. The states are unsafe for the reason that only processes T 2, T1 and T3 are able to finish.

b. The states are safe since processes T 1, T2 and T3 are able to finish and also the processes T0 and T4 after
them.

6. Can a system detect that some of its threads are starving? If you answer “yes,” explain how it can. If you answer
“no,” explain how the system can deal with the starvation problem.
A system can detect that some of its threads are starving by creating a rule where the process that has
been waiting for the longest time is given priority to have the resources. With that, the system will know
which process is being starved and is given a resource to stop it from starving.

You might also like