Interview Question






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

depend how the process goes to "sleep", and how to define "sleep"
1. OS switch process routinely, if we call those processes not running on the CPU as sleeping, that those processes would hold most of the resources they have even after they sleep: File, socket,mutex-guard resources, etc. One exception might be the physical memory where a process reside when running, might not be occupied by this process any more if it's "sleeping" and is swapped out to outer storage (like disk) by OS. (OS take back the physical memory of the process forcedly)
2. Some process would actively put himself to "sleep" and yield to other process,
reason of this yielding is that this process is waiting for some resource which is not immediately available, or some signal from hardware or other process, under above circumstances, the process will be "nice" to give out the CPU, before that, the process might nicely give out some resources, especially some mutex-guard resources, but that depends on how the process is coded.

- Ouyang October 18, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

generally inorder to release some resources only we will put process into sleep state

- karthik October 18, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

ouyang,thank you for your explanation. Similarly to what I have guessed :) Where did you get those information? I found it hard to prepare for os questions. For algorithm, you can read CLR textbook and then you get the idea how to copy with most algorithm textbooks. However, for os questions, I really had no idea when it gets into details. Hope you can give me some instructions. Thank you very much!

- yang October 19, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@Ouyang:
Nice explanation. Thanks.

- xin hua October 19, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Absolutely clear explanation ouyang. But i have a doubt that until a process exits, it holds the resources required for its existence. So a process releases those resources which it had acquired to carry out user program instructions while going to sleep

- dinesh November 22, 2009 | 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