Microsoft Interview Question for Developer Program Engineers






Comment hidden because of low score. Click to expand.
5
of 5 vote

I think it would be n*k-n+1....

- import_neo November 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

correct!!

- abc November 06, 2010 | Flag
Comment hidden because of low score. Click to expand.
2
of 2 votes

so basically if there can be deadlock if none of the process have the required resources, i.e. if each have (k-1)...meaning total n*(k-1)..now even if there is 1 more resource, there can t be deadlock....so minimum requirement is n*(k-1)+1 = n*k-n+1

- abc November 06, 2010 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Why its n*k-n+1 could the people commented explain, please.

I think its "None of the above".
* If there is only one resource there is no question of deadlock.
* If there are k instances of the resource and each instance need to be locked to access it then it is equivalent to having more than one resource.
* If there are more than one resource that each needs locking then, I don't think its number of resources or its need-to-be-locked instances dictates the deadlock scenario. The program should avoid the deadlock. For e.g. There are 2 processes and 2 resources process 1 locked resource 1 and waiting for resource 2, while process 2 has locked resource 2 and waiting for resource 1. How does the number of instances or resources avoid the deadlock scenario?

- Kannan November 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Wow they gave you multiple choice, just like a homework assignment. Coincidence huh?

- Anonymous November 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

i copied dis ques from someone's blog..
may b MS dint ask dis..bt i thot i shud share d question

- dev November 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

even i think so..

- dev November 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@kannan its like n*k-n resources are required so that each process can have one less than the resource instance they require.. but still deadlock can occur as each process depend upon other process for one resource instance ..if we provide n*k-n+1 resource instances than the deadlock condition will never occur.

- import_neo November 06, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Thanks for the explanation.
So I guess there will be resource manager who will figure out which resources are already acquired and when a process asks for a resource it grants access to a non-acquired resource if possible.

- Kannan November 08, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

this is not correct take this example there 2 processes and 2 resource types R1 & R2 each process requires 10 of each type. now according tho answer above 19 resources of each type are sufficient to avoid dead lock but it's incorrect dead lock can occur if p1 acquires 10 R1 and 9 R2 and p2 acquires 9 R1 & 10 R2 there is a dead lock.so above answer is wrong plz some one give me correct answer i opted n*k in my exam i couldn't any other option better than this.

- Anonymous November 24, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

There is only one resource. k instance of which is needed by each of the processes.

- Anil December 31, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

i also agree with that..

- sushantmax88 November 08, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

would depend upon whether they can be preempted or not. if can be preempted, then we just need only k instance of resources .if there is non preemption than we need n*(k-1) +1 ;

- Anonymous November 16, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

you can simply find out by putting the arbitrary small values of n & k. Suppose you take 2 & 2. You will find only 2 option gives the cirrect answer

- skagrawal10 November 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Shouldn't ordering the resources fix the deadlock?
All processes lock the resources in one order that all of them agree upon.
Hence we require only k resources.

Comments/suggestions welcome!

- Rohith Menon November 26, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Agree with this answer. We can have a system without deadlock if the number of instances of the resource is just 'k' and every process has a priority associated with it. We'll have new issues to handle now - starvation! - but, it is deadlock free now.

- Anil December 31, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

well the deadlock can be avoided using banker's algorithm. Its scheduling algorithm, preemption and the number of resources that dictates the deadlock.
Cases will differ based on the discussion and requirements.

- Anonymous January 28, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Answer will depend on language of question...if it is asked like find no. Of. Resources sothat deadlock should never occur...-> it will require n*(k-1)+1 nmber of resources..
Otherwise bankers algo will give the safe sequences and according to that only ' k' number of resources

- Anonymous November 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

what would be if we have three processes P(x), P(y), and P(z); and each one has maximum demands on a resource of single type 3,5 and 4 respectively. What is the minimum number of resources I need in order to ensure the system is deadlock free?

- John Wong December 14, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Correct Answer is : N*K -(N-1).

- Rajan February 22, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Correct Answer is : N*K - (N - 1) [or] (Total Number Process * Total Number of Resource ) - (Total Process -1 )

Let me prove my formulae

For Ex: There are 3 process and each require 2 resources to complete the task. So the Minimum number of resource which guarantee the dead lock free is 4.(Source : Tata McGraw Hill Book)

Formula: 3*2 - (3-1) = 6-2 = 4


For Ex: There are 5 process and each require 2 resources to complete the task. So the Minimum number of resource which guarantee the dead lock free is 6.(Source : Again Tata McGraw Hill Book)

Formula: 5*2 - (5-1) = 10-4 = 6

Hence the proof..!

- Rajan February 22, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

what if there are 3 processes and each need 3 resources
in that case i think the answer should be 5
but the formula gives 7...

- furqan khan March 13, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

what if there are 3 processes and each need 3 resources
in that case i think the answer should be 5
but the formula gives 7.....

- furqan khan March 13, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

((((Cant understand the logic of the first answer
can u explain again))))

- anjali April 29, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

minimum requiement scenario process deadlock

any one give answers

- gokulraj January 28, 2016 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More