ANONYMOUS wrote:
> I have been experimenting with different command-files with the sample solution and have a few questions regarding the wait system call. I understand that if wait is called when there are no child processes left, the process will be put back on the ready queue. In the sample solution, if there are no processes in the ready queue, the process that called wait is still put back into the ready queue and then back into running consuming a total of 15 usecs. Is this what is meant to happen? I had assumed that if there were no processes in the ready queue, the process that called wait would just keep running until the time quantum is reached. (It seemed terribly inefficient to move the process off the running state just to put it back in again).
The decision to determine if the 'waiting' process has any children to wait for is made by the OS.
The OS requires the use of the CPU to execute code to make that decision.
The process invoking the 'wait' needs to be placed somewhere so that the OS can get the CPU.
There is an analogous situation when a process exhausts its timequantum and there's no other process to take its place (that can be determined by looking only at the count of Ready processes). At present (in the sample) that 'exhausted' process stays on the CPU for a new timequantum but, maybe for consistency, it too should be moved to Ready and then back to Running. Thinking on it, but I'm leaning toward a simple solution, rather than one that strives for maximum efficiency of our simulated system.