Re: how long does a single context switch take ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



What do you mean by a context switch?
There are several terms that are sometimes confused with a context switch:
1. Mode switch: The switch between user mode and kernel mode that occurs,
for example, at the beginning and end of a system call
2. Address-space switch: Before a thread becomes active, it needs its
address space to be set as the current one (if it not already is). On the
x86, this happens by setting the cr3 register and flushing the TLB.
3. The classic, OS course, context switch: This signifies the switch between
two processes, and may include multilple mode switches and an address-space
switch.

I'm not sure there is an easy way to measure #3, as it probably varies
considerably depending on the scenario. The same goes for #2, as the cost
of TLB flushes cannot be determined a-priori, and depends on how many TLB
faults result from the switch.
As for #1, this is more manageable. I have taken some measurements in the
past by comparing a calculation that is performed entirely in user space,
vs. the same computation alternating between modes.

Elad

Ramagudi Naziir wrote:

> Hi all -
> 
> I am looking for a rule of thumb regarding the time it takes
> to context switch in linux (any other OS comparison would be interesting
> too) on a modern hardware (x86 is probably the most interesting, but
> other numbers might be handy too if anyone has them).
> 
> Thank you for any help on the matter !
> naziir
> 
> --
> To unsubscribe from this list: send an email with
> "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
> Please read the FAQ at http://kernelnewbies.org/FAQ



--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux