Consider a web server that allows members of the department to update web pages.
ID: 3878508 • Letter: C
Question
Consider a web server that allows members of the department to update web pages. A web page may consist of several files. Frequently files are common to several web pages (i.e. only one copy of the logo image is stored on the web server, but it appears on many web pages). Updating a web page requires locking all of the files that appear on the web page. When the updates are done, all files are unlocked.
how can this system be designed so that it will not deadlock.The solution should be on how to avoid deadlock on a programming level using pthreads not on a network level.
Explanation / Answer
Here is the solution, do give me a thumbs up if this helps!
Not more than one thread should have access to a particular resource.
Multiple requests for a resource must be granted to the one with finite time.
A thread that has exclusive access to a resource must release it in finite time.
Thread should not consume processor while waiting for a resource.
Deadlock holds true only if all these conditions hold true :
Thread shave exclusive access to resources and they cannot be removed from the thread.
Threads hold resources while waiting for another resource to be granted.
There is a cycle fo threads, each waiting for a resource from the next thread.
Thus, a deadlock may be prevented by weakening one or more of the above conditions.