Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For a project at my university I am researching ways to trace, log and manipulate the process scheduling of certain processes. I would like to launch an number of applications, everyone in a single process. At first I would like to trace and log their scheduled execution. But at the next step I would like to manipulate their scheduled execution in order to prefer a single process in it's first $n execution.

Does someone know an existing approach to realize this (for instance a modified sched.h)?

share|improve this question
I'm a little confused by the "number of applications" and "single process" bit. How are multiple applications occupying a single task? – Bratchley May 6 '13 at 12:28
Also, what platform is this on? – Bratchley May 6 '13 at 12:28
Joe, you are right. The single process part is a little bit redundant.I am developing under OSX 10.8 but the destination platform will be a normal debianstyle linux. – arbyter May 6 '13 at 13:38
What are you trying to trace? Context switches? Between processes or between threads of the same process? What kinds of modifications do you want to make to the scheduler? Are you doing this on OSX or Linux (the tools are likely to be very different)? – Gilles May 7 '13 at 1:40

To keep track you can use getcpu or sched_getcpu (ideas from this question), but there isn't any signals realted to the scheduling so it might be a bit hard to keep track of that directly on the code.

Another not much elegant solution is find this information in the /proc/$PID "files"

To control where the CPU affinity check hwloc , taskset or control for runtime control: sched_setaffinity

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.