Danny's Tech: Where West and East Intersect

Wednesday, January 17, 2007

Micro-Programs and cooperative scheduling

It used to be that OS used to time share several programs running on a CPU by forcing a context switch over microseconds (or other small time intervals). But the problem with a timed context switch is that there is an overhead of setting and handling an interrupt and then resuming after that interrupt.

What if programs could be compiled into "micro" units (a spin-off of the micro-kernel idea) so that there is no need to interrupt any program: Each micro-program will run at most xyz time units/cycles so that it will let go of the CPU in a fair way. The beauty of this is multi-fold:
  1. OS only does context switch: no need to force a stop and try to recover by restarting the interrupted process
  2. Easier to distribute the program across multiple cores.
  3. Easier to synchronize with other micro-programs -- because a micro-program ends ready to switch (give up its CPU slice), it can be stopped and synchronized with other micro-programs waiting on the same event, etc.
  4. Easier to distribute the micro-program on non-uniform multi-processor systems since each micro-program are self contained.
Obviously the standard code to force timesharing still has to be around to deal with non-conformant programs but the scheduler can be biased to give higher priority to well behaved micro-programs so that there is disincentive(s) for status quo.

Copyright 2007, DannyHSDad, All Rights Reserved.

Labels: , ,