Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Context Switching Latency

    Hi Friends,

    I want to measure the context switching latency of the OS System call(like semaphore).
    can any one suggent me how can i measure the latency? Is there any third party
    tools or any source code avaliable for measuring the context switching latency.

    Thanks in advance.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Latency will vary, depending upon many, many factors such as I/O, kernel locks, scheduling of other processes, etc. As a result, any such characterization must be done over many calls in order to average them out, and must be done on a minimally busy system if you want to get MINIMUM latency figures. IE, a system with no GUI, no active networking, no active disc I/O, and only your testing processes running. If you have all the normal cruft running (GUI, network, disc I/O, etc) then you will get a nominal latency figure, which will be more realistic, but less accurate. Am I making any sense here?

    So, as for tools to do this, there are timing functions you can call before/after your kernel call, as well as the normal system profiler. To get minimal context switch time, create your own loadable kernel module that handles an ioctl() call and just returns to the caller. The caller will doe some stuff, set a timer, make the ioctl() call, read the timer, and go back to doing some "stuff" like making some fork()/exec() calls to force the kernel to put your process out of context/cache, before going back to your set-timer/ioctl/read-timer functions. You do this a LOT of times (many, many thousands), accumulating and averaging out the time your ioctl took.That will give you a reasonable figure for what your average kernel context switch latency would be for the current load. You can then do this under various load conditions (no load, moderate load, heavy load w/ GUI operations) and can draw a nice graph showing how context switch latency varies with load. Ok?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts