Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Computer science overview class: Can various solutions to the critical section p

ID: 3627748 • Letter: C

Question

Computer science overview class: Can various solutions to the critical section problem cause deadlock? I need to validate or challenge this assertion: "The various solutions to the critical section problem can cause deadlock." If I don't agree with the assertion as stated, I need to restate the assertion in a manner that correctly reflects the relationship between critical sections and deadlocks.



I am quite confident that not all of "the various solutions" can result in deadlock. What I'm wondering is if there are solutions to the critical section problem that increase the risk of deadlock. For example, in trying to rule out mutual exclusion, can that result in deadlock, if care is not taken? I'd like to have an illustrative example of a critical section problem with solutions that can result in deadlock, and others that don't. (not so much code, but a more general example of two or more processes with critical sections, etc. Of course, any solution to the critical section problem that increases risk of deadlock wouldn't count (in my eye, anyway) as a good solution! Any help would be greatly appreciated!



Keep in mind, this is an intro course, one chapter on OS (Brookshear)...we've covered briefly the definitions of critical section, deadlock, the conditions that must simultaneously hold for deadlock to occur, briefly touched on use of semaphores for critical section problem (though it seems that mutex might be the correct concept here)...Examples need to be pretty down to earth.



Thanks again!

Explanation / Answer

This is a very interesting topic but I am surprised that your book didn't delve more into the reasoning behind deadlock. What book are you currently using..? Well here is some food for thought.... We know that critical sections - are sections of code being run by at least two processes that require some degree of cooperation between the process. Cooperation is just making sure the sections don't overlap.. Enforcing the following rules--> mutual exclusion, progress, and bounded waiting.(sure this is in your book.) **Bounded waiting is a rule, but if the low priority thread (operation) is in the critical section, while the high priority thread is spinning (waiting) this can end up causing a deadlock. ****An approach for implementing synchronization that avoids disabling interrupts is to use a shared lock variable to allow only one process to enter a critical section at a time. No process is allowed to enter a critical section if another process has locked access by setting the shared variable lock=TRUE. ----using a shared lock variable also has its risks. Once a thread enters a while loop with the lock set to TRUE, there no way it can be interrupted to allow another thread to change the lock to FALSE. ****Another approach is to assure that critical sections don't overlap is to disable interrupts whenever either process enters one of its critical sections. All further interrupts are disabled until P1(Process 1) finishes its critical section. ---- The problem is, is that important interrupts may be missed if the critical sections are large!. This also makes it possible for a critical section to hang the computer by getting into an infinite loop.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote