0 votes 0 votes if there is no allocation sequence that allows the processes to finish executing, then the system is in an unsafe state. This is not equivalent to the "If the system is in an unsafe state, then there is no allocation sequence that allows the processes to finish executing Operating System deadlock-prevention-avoidance-detection + – Gurdeep Saini asked Nov 3, 2018 • edited Dec 15, 2018 by Gurdeep Saini Gurdeep Saini 2.2k views answer comment Share Follow See all 12 Comments See all 12 12 Comments reply Vikas Verma commented Nov 3, 2018 reply Follow Share Yeah, true. 0 votes 0 votes Gurdeep Saini commented Nov 3, 2018 reply Follow Share is safe state my lead to dead lock ? 0 votes 0 votes Vikas Verma commented Nov 3, 2018 reply Follow Share No, never. 0 votes 0 votes Gurdeep Saini commented Nov 3, 2018 reply Follow Share thanks @vikas verma 0 votes 0 votes kumar.dilip commented Nov 3, 2018 reply Follow Share @Gurdeep Saini https://cs.stackexchange.com/questions/45145/why-unsafe-state-not-always-cause-deadlock 1 votes 1 votes Gurdeep Saini commented Nov 3, 2018 reply Follow Share yaa can anybody give the example that when a process in unsafe state and have no deadlock .i tried to find the example but not found all of tham given only theory 0 votes 0 votes kumar.dilip commented Nov 3, 2018 reply Follow Share Bro , Open that link , you will find the example. 0 votes 0 votes MiNiPanda commented Nov 5, 2018 reply Follow Share @Gurdeep Saini Total resources=12 Process Max Need Current Allocation Need Available=Total-∑(Current Allocation) P1 10 5 5 12-(10)=2 P2 4 2 2 P3 9 3 6 P2's need can be satisfied by the available resources. After P2 finishes it will release all its resources that it previously held. Now available will be 2+2=4. With these 4 resources neither of P1 nor P3's Need can be satisfied. This system will be in unsafe state. Why not deadlock? To answer that first we should know what actually does Max Need mean. It is the maximum no. of resources that a process might need. It doesn't mean that the process will need all those "max need" no. of resources for all the time. Maybe process P1 currently needs only 2 resources and doesn't want another 5 at this moment. Just think that if all the processes needed their respective Max need resources to complete execution at time t1 then why is the OS not allocating all the 4 instances at the beginning to P2 only or 10 resources to P1 or 9 resources to P3 at once? Why is it allocating by parts? This is because the processes have requested for resources in that manner. This implies that the processes do not need the max no. of resources at all instances. We need to understand that a process’s Need is not same as process’s Request. Here a situation might arise when P1 and P3 request for 5 and 6 resources respectively. In that case deadlock will arise as the available resources won't be enough for them. But we cannot guarantee that they will surely make such requests. It is one of the possibilities. It might also happen that P3 releases some resources after some time. Then those can be allocated to P1 if it requests. Since there is always a chance of deadlock we say that it is unsafe. We can check if the system is in deadlock if we are given the Request matrix of processes instead of Need matrix. For multiple instances of resource type, we need to run Deadlock detection Algo which takes Request matrix as one of it’s input data. My understandings are based on : https://cs.stackexchange.com/questions/55432/confusion-in-bankers-algorithm-how-resources-are-allocated https://cs.stackexchange.com/questions/45145/why-unsafe-state-not-always-cause-deadlock 3 votes 3 votes Gurdeep Saini commented Nov 5, 2018 reply Follow Share @minipanda thank a lot lot lot 1 votes 1 votes kumar.dilip commented Nov 5, 2018 reply Follow Share If the system is in safe state It is guaranteed that There will not be Deadlock or There might be at least any sequence that may cause Deadlock ???? 1 votes 1 votes Gurdeep Saini commented Nov 5, 2018 reply Follow Share @dilip If the process is in a safe state, it will never lead to deadlock. If the process is in an unsafe state, it may or may not lead to deadlock. 1 votes 1 votes kumar.dilip commented Nov 5, 2018 reply Follow Share I know. I am asking There might be any sequence or not For which There will be deadlock in safe state ?? 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes If the process is in a safe state, it will never lead to deadlock. If the process is in an unsafe state, it may or may not lead to deadlock. Kunal Kadian answered Nov 3, 2018 Kunal Kadian comment Share Follow See 1 comment See all 1 1 comment reply Gurdeep Saini commented Nov 3, 2018 reply Follow Share cam anybody give the example that when a process in unsafe state and have no deadlock .i tried to find the example but not found all of tham given only theory 0 votes 0 votes Please log in or register to add a comment.