Interview Question
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!
depend how the process goes to "sleep", and how to define "sleep"
- Ouyang October 18, 20091. 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.