I am confused about the process switching between two processes. When a new process is created using fork, what are the general rules applicable for switching between processes. Is it only when one processes goes to idle state? I have few doubts

  1. What will happen when parent and child in both infinite loop and having only print instruction (no sleep method)
  2. What is the general rule?
有帮助吗?

解决方案

Most preemptive schedulers will, highly simplified, allocate a certain maximum time to each process.

When that time expires (for instance 10 ms), it will re-schedule so that other processes get some CPU.

If the timer doesn't expire before the process hits some other wait condition (such as doing I/O), it will re-schedule then, instead.

其他提示

When the quantum expires context switch occurs

When theresource.

When there is a system call triggered ==> not sure. re is an interrupt switching occurs

when another process/thread with higher priority comes in ready state, context switch triggered.

When your thread goes to blocked state by virtue of i/o or awaiting any other thread whcih share's the locked

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top