station
station

Reputation: 7145

Context switch in CPU

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?

Upvotes: 0

Views: 218

Answers (3)

Jerry Coffin
Jerry Coffin

Reputation: 490048

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.

Upvotes: 3

Andrey
Andrey

Reputation: 60065

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

Upvotes: 4

John Zwinck
John Zwinck

Reputation: 249123

It depends on the platform. You should profile yours.

Upvotes: 0

Related Questions