title: Benchmark for the context switches in linux scheduler
body: <p>I have an assignment to design a benchmark for the linux scheduler in C, more precisely to "determine how the underlying architecture handles context switches, without looking at the details of the implementation."</p>
  
  <p>Based on an article I found on the linux journal, I have designed a benchmark that measures the time it takes to spawn a process (fork/exec) and to create a thread (fork).</p>
  
  <p>Now I want to test the time it takes to switch process and thread, with the instruction sched_yield. I thought of creating multiple threads/processes and having them all call sched_yield. The first thread/process to call sched_yield would measure the time and divide it by the number of processes (I assume that all other processes call sched_yield before the first process resumes execution) to get an aproximation of the time per context switch.</p>
  
  <ul>
  <li>Does this benchmark make sense?</li>
  <li>Would it make sense to study the time per context switch with different numbers of threads, or is it theoretically constant?</li>
  <li>Is there a better way to design the benchmark?</li>
  </ul>