0

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?
user567879
  • 5,139
  • 20
  • 71
  • 105

2 Answers2

2

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.

unwind
  • 391,730
  • 64
  • 469
  • 606
0

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

ahmed
  • 51
  • 1
  • 4