user567879
user567879

Reputation: 5349

When do process switching takes place

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?

Upvotes: 0

Views: 289

Answers (2)

ahmed
ahmed

Reputation: 51

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

Upvotes: 0

unwind
unwind

Reputation: 400079

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.

Upvotes: 2

Related Questions