NunoLava1998 wrote:
Roman wrote:
And..?
i like cats i had nothing to say after what i said [...]
Unless this is a direct translation of an idiom from some other language, then I assume you are referring to the English language pun, "like cats, it goes without saying" (based on the general disdain cats seem to show to human endeavors, leaving in the middle of being petted and so forth). That usually is meant to imply that the implications of something were obvious, which, well... the fact that Roman asked that indicates it might not have been so obvious after all.
As for the solution, that is going to depend on the OS itself - it isn't something any canned response will give.
Usually, the solution in a multitasking system is to provide a system call that requests that the scheduler halt the running process and place it in the wait queue until after a given period of time. How you would implement that is entirely dependent on your scheduler design, and even if we had access to it (you
do have it in a publicly accessible offsite version control repo,
right? If not, then shame on you, drop everything and do that now), we could not and would not give you the solution because at that point it would become
our OS project, not yours.
For the case where all processes are waiting, you would normally have a dummy no-op process, called the null process, which on an x86 CPU can often be just:
Code:
pause_loop:
sti
hlt
jmp short pause_loop
Assuming that the interrupts are set (hence the first instruction), then any new interrupt will trap to the scheduler, and if some other process is now schedulable, it will go to that, otherwise, it returns to the loop at the JMP instruction.
Note that this depends on the interrupt handlers and the scheduler being in place
first. This approach will
not work inline to a process, as it will hang the process - the whole point is for the null process to hang itself, you see, and if you insert this loop into some other code you will never break out of it. It also is not sufficient for a multi-core system, as you would need a null process for each core.