Training
×

Multi-threading example:

Pay attention to this slide!!! This is the basis for pre-emptive threads.
Dwell on this slide because it will form the foundation for real-time programming.
So why do we claim that multi-threading makes programming easier? Take this example system:
  • action 1 is required when input signal x is high
  • action 2 must be performed every 10 msec
  • action 3 must be done every 35 msec
This could be programmed by a 1 msec cycle; every cycle we check the input signal and if high, we do action 1; every 10th cycle we do action 2; every 35th cycle we do action 3. Typically, we waste a lot of time just checking. With multi-threading this is reduced to three independent threads each with their own events.