Multithreading on retrocomputers

COORDINATE THE PROTOTHREADS

Protothreads are threads that run in a cooperative multithreading context. Protothreads voluntarily relinquish control once the current operation is over. More precisely, the scheduler passes control to another thread only in three cases:

  1. at the end of the thread;
  2. when it explicitly cedes control;
  3. when passing into the waiting state.

The first case occurs when the function ends, arriving at the MR_PTI_END annotation. The second case is triggered by the MR_PTI_YIELD call, which we have already in the previous chapter.

The third, more interesting case occurs when one of the wait functions is called:

These functions are useful as they allow to implement more or less complex forms of cooperation and / or synchronism.

Move to BLOCKING AND NON-BLOCKING FUNCTIONS.