117k views
4 votes
Describe the general strategy behind deadlock prevention, and give an example of a practical deadlock prevention method.

Multi-programming (or multi-tasking) enables more than a single process to apparently execute simultaneously. How this can be achieved on a uni-processor?]

User Calden
by
6.7k points

1 Answer

3 votes

Answer:

In multi-programming, you use semaphore constructs to protect shared resources. Your program thread or process will block if you want to claim a semaphore when another thread or process has it claimed.

Generally you need to keep the code scope of the claimed semaphore (a.k.a. the critical section) as small as possible, and also, prevent claiming another semaphore within a given critical section.

User ColinMc
by
6.9k points