0

suppose the time it takes to switch between user and kernel modes is t1 and to switch between two processes is t2.Which is greater t1 or t2?

1
  • Homework? If it is, please be up front about that. Commented Feb 13, 2011 at 18:31

3 Answers 3

4

I think t2 is always larger, because process switch happens via kernel mode.

Sign up to request clarification or add additional context in comments.

Comments

3

Theoretically it depends on the platform. In practice, a switch from one process to another typically goes from the original process to kernel mode, then the kernel decides which process to schedule next, then there's a switch from kernel mode to user mode running the second process.

As such, switching from one process to another includes a switch from user- to kernel-mode, plus more, so it'll be slower.

Comments

0

It depends on the platform. You should profile yours.

1 Comment

You might try making a simple system call in a loop and seeing how fast that is. Then run a program which calls sched_yield() a lot and see how that goes (how much time until it gets control back). I think you could learn something this way, with some refinements. That said, your answer about t2 being longer in general seems intuitively sensible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.