title: How does the scheduler know that a thread is blocked waiting for input?
body: <p>When a thread executing user code is waiting for input, how does the scheduler know to interrupt it or how does the thread know to call the scheduler, seeing as the average programmer of a simple single threaded application is unlikely to insert  sched_yield() everywhere. Does the compiler insert sched_yield() on optimisation or does the thread just spin lock until the general timer interrupt set by the scheduler fires, or does the user have to explicitly state wait(), sleep() functions in order for the context to switch?</p>
  
  <p>This question is especially relevant if the scheduler is not preemptive because then it <em>has</em> to call the scheduler when it is waiting for input for throughput to be effective, but I'm not sure how it does this.</p>