Consider a computer system with multiple shared resource types, with one instance per resource type. Each instance can be owned by only one process at a time. Owning and freeing of resources are done by holding a global lock (L). The following scheme is used to own a resource instance: function OWNRESOURCES(Resource R) Acquire lock L / / a global lock if R is available then Acquire R Release lock L else if R is owned by another process P then Terminate P, after releasing all resources owned by P Acquire R Restart P Release lock L end if end if end function Which of the following choice(s) about the above scheme is/are correct?

Consider a computer system with multiple shared resource types, with one instance per resource type. Each instance can be owned by only one process at a time. Owning and freeing of resources are done by holding a global lock (L). The following scheme is used to own a resource instance: function OWNRESOURCES(Resource R) Acquire lock L / / a global lock if R is available then Acquire R Release lock L else if R is owned by another process P then Terminate P, after releasing all resources owned by P Acquire R Restart P Release lock L end if end if end function Which of the following choice(s) about the above scheme is/are correct? Correct Answer The scheme may lead to starvation., The scheme may lead to live-lock., The scheme ensures that deadlocks will not occur.

Concept:

Livelock A situation in which two or more processes continuously change their states in response to changes in the other process(es) without doing any useful work.

Consider the following example 

Process 0 Process 1

flag = true;
while(flag){
    flag=false;
    /*delay*/
     flag=true;
}
  /* CRITICAL SECTION */
flag=false;

 

flag = true;
while (flag) {
    flag = false;
    /*delay */;
    flag = true;
}
/* CRITICAL SECTION*/;
flag = false;

In this example, if you see both the processes just changing states of their flag variable and none of them can enter into the critical section provided mutual exclusion is satisfied. 

Note:
*Assume that preemption does not occur in executing the statement of inside while loops in the above example.

Explanation:

- OWNRESOURCES(R) function does the following tasks

acquire lock L

  • If R is available

acquire resource R 
release lock L

  • If R is not available , it is already acquired by a process P

Terminate P and release all resources owned by P.
acquire R.
Restart P
Release L

Option 1: The scheme may lead to starvation.

this is correct.

Let's take an example consider 2 processes (P, Q1)  initially no other process currently in the System. First Q1 executes OWNRESOURCES(R) 

  • Q1 acquires L
  • Q1 acquires R
  • Q1 Release L

Now as soon as Q1 finishes Q2 arrives and executes the same 3 tasks and completes then as soon as Q2 finishes Q3 arrives and so on process Q's keep arriving in the system and the process P never gets to execute.

so Starvation possible.

Option 2: The scheme may lead to live-lock.

Let's take an example consider 2 processes (P, Q)  initially no other process currently in the System. First P executes OWNRESOURCES(R)

  • P acquires L
  • P acquires R
  •  Release L

immediately after Releasing L, P gets preempted Q starts OWNRESOURCES(R) 

  • Q acquires L
  • Terminate P and release all resources owned by P.
  • acquire R.
  • Restart P
  • Release L

immediately after Releasing L, Q gets preempted P starts OWNRESOURCES(R) 

  • P acquires L
  • Terminate Q and release all resources owned by Q.
  • acquire R.
  • Restart Q
  • Release L

and so on the same thing will repeat itself.

This is not Deadlock right. This is Livelock.

Option 3: The scheme ensures that deadlocks will not occur.

This statement is correct as Deadlock not possible. because even if there circular waiting exists one process simply terminates the other processes which hold the resources.

so no hold and wait, so Deadlock will not occur.

Option 4: The scheme violates the mutual exclusion property.

This statement is not correct because every process has to go through the function OWNRESOURCES(R) to own resource and even if a Resource is owned by another process then it will get terminated and restarted; at a time no 2 processes can own a single resource. So Mutual exclusion property is satisfied.

Related Questions

The following are the conditions for selecting list of a suitable candidates to be called for interview after the written test for the recruitment is conducted/ organized for management-level persons of a multi-national company. For providing accounting services and sales the candidate must (a) be holding a graduation in basic science with 65% or above or B.E degree with 55% and above marks (b) have passed the written test with 70% or above marks (c) the age must be in the group 25 to 30 yrs as on 1/4/18 (d) have experience in an accounting firms for three yrs and diploma in accounting with 60% or above marks (e) be presently drawing CTC of 6 Lakhs per annum and above In case the applicant who satisfies all other terms above except 1) at (a) above, then be referred as Junior Accountant 2) at (d) & (e) above then be referred as Trainee-Accountant Satisfying all the above with experience of 5 yrs then be referred as senior-Accountant Satisfying all the above criteria (a-e) with CA/ ICWA/ MBA (Finance) then be refereed as manager (Accounts) Read all the above information and answer the following question: Radha Mohan has done her graduation in physics with 58% of marks. She has passed the written examination with 76% of marks. She is 27 yrs as on June 2018. She has the experience in the accounting company for four years with salary of 7 Lakhs per annum. She also has passed diploma in accounting with 61% of marks. She may be referred for the position of:
The following are the conditions for selecting list of a suitable candidates to be called for interview after the written test for the recruitment is conducted/ organized for management-level persons of a multi-national company. For providing accounting services and sales the candidates must (a) be holding a graduation in basic science with 65% or above or B. E degree with 55% and above marks (b) have passed the written test with 70% or above marks (c) the age must be in the group 25 to 30 years as on 1/4/18 (d) have experience in an accounting firms for three years and diploma in accounting with 60% or above marks (e) be presently drawing CTC of 6 Lakhs per annum and above In case the applicant who satisfies all other terms above except 1) at (a) above, then be referred as Junior Accountant 2) at (d) & (e) above then be referred as Trainee-Accountant Satisfying all the above with experience of 5 years then be referred as senior-Accountant Satisfying all the above criteria (a-e) with CA/ ICWA / MBA (Finance) then be refereed as manager (Accounts) Read all the above information and answer the following question Shravani has passed H. SC with 72% of marks. She has done diploma in accountancy with 62% of marks. She was working with an organization in the field of accounting in the field of accounting from 4 years and was drawing CTC of 6.5 Lakhs presently. She is 28yrs as on July 2018. She may referred for the position of:
You are the administrator of Windows 2000 Server network. On each server you format a separate system partition and a separate boot partition as NTFS. Several months later you shut down one of the computers for maintenance. When you try to restart the computer you receive the following error message "NTLDR is missing, press any key to restart". You want to install a new NTLDR file on the computer but you do not want to loose any settings you made since the installation. What should you do?