Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tsuna/contextswitch
Little micro-benchmark for Linux to test the cost of context switching and system calls
https://github.com/tsuna/contextswitch
Last synced: 16 days ago
JSON representation
Little micro-benchmark for Linux to test the cost of context switching and system calls
- Host: GitHub
- URL: https://github.com/tsuna/contextswitch
- Owner: tsuna
- License: gpl-3.0
- Created: 2010-11-15T05:10:42.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2016-06-22T18:59:56.000Z (over 8 years ago)
- Last Synced: 2024-08-03T19:09:11.935Z (3 months ago)
- Language: C
- Homepage: http://blog.tsunanet.net/2010/11/how-long-does-it-take-to-make-context.html
- Size: 23.4 KB
- Stars: 271
- Watchers: 20
- Forks: 82
- Open Issues: 3
-
Metadata Files:
- Readme: README
- License: COPYING
Awesome Lists containing this project
README
Little micro-benchmarks to assess the performance overhead of context
switching.timesyscall: Benchmarks the overhead of a system call.
timectxsw: Benchmarks the overhead of context switching between 2 processes.
timetctxsw: Benchmarks the overhead of context switching between 2 threads.
timectxswws: Benchmarks the overhead of context switching between 2 processes
using a working set of the size specified in argument.
timetctxsw2: Benchmarks the overhead of context switching between 2 threads,
by using a shed_yield() method.
If you do taskset -a 1, all threads should be scheduled on the
same processor, so you are really doing thread context switch.
Then to be sure that you are really doing it, just do:
strace -ff -tt -v taskset -a 1 ./timetctxsw2
Now why sched_yield() is enough for testing ? Because, it place
the current thread at the end of the ready queue. So the next
ready thread will be scheduled.
I also added sched_setscheduler(SCHED_FIFO) to get the best
performances.