Professional Documents
Culture Documents
2TSI
Assignment 3
2. There are certain books that divide resources to certain types such as
preemptable resources, non-preemptable resources, exclusive resource and
shared resources. What does all these different types of resources mean and
give at least ONE (1) example for each resource types.
Preemptable resource
o Resource that can be taken away from a process e.g. CPU can
be taken away from processes in user space
Non-preemptable resource
o Taking it away will cause processes to fail e.g. Disk, files
Exclusive resource
o Only one process at a time can use it e.g. loudspeaker,
processor
Shared resource
o Can be used by multiple processes e.g. memory, bandwidth
4. Give examples of deadlock that you may encounter while using your personal
computer.
Deadlocks may occur when two or more queries are run on
a database. Transactional databases lock active records, preventing
other queries from accessing them. If a process cannot access a
locked record, a database deadlock may occur.
5. List all FOUR (4) characterizations or conditions that are necessary to achieve
deadlock.
Mutual Exclusion - At least one resource must be held in a non-
sharable mode(exclusive resource); If any other process requests this
resource, then that process must wait for the resource to be released.
Hold and Wait - A process must be simultaneously holding at least
one resource and waiting for at least one resource that is currently
being held by some other process.
No preemption - Once a process is holding a resource ( i.e. once its
request has been granted ), then that resource cannot be taken away
from that process until the process voluntarily releases it.
Circular Wait - There must be a circular chain of two or more
processes, each waiting for a resource held by the previous member
of the chain. E.g: A set of processes { P0, P1, P2, . . ., PN } must exist
such that every P[ i ] is waiting for P[ ( i + 1 ) % ( N + 1 ) ]. ( Note that
this condition implies the hold-and-wait condition, but it is easier to
deal with the conditions if the four are considered separately. )
Allocation Need
R1 R2 R1 R2
P1 0 1 1 0
P2 1 0 0 0
P3 1 0 0 1
P4 0 1 0 0
The answer same as in 6 = just to make sure students know that questions
could be the other way round
P1 3 0 2 0 2 0 3 2 2
P2 3 0 2 6 0 0 9 0 2
P3 2 1 1 0 1 1 2 2 2
P4 0 0 2 4 3 1 4 3 3