Ending a hart

The p_jalr zero, ra, t0 instruction (or p_ret in short) ends a hart.
An ending hart has one of the four following behaviours:
  • play_arrowwait for a resume address (ra==0 and current hart==join hart),
  • play_arrowend (ra==0 and current hart!=join hart),
  • play_arrowend and send a resume address (ra!=0),
  • play_arrowexit (ra==0 and t0==-1),

In the following example, the first p_jalr zero, ra, t0 in core 0, hart 0 waits for a resume address (the hart is not ended). The second p_jalr zero, ra, t0 in core 0, hart 1 ends the hart. The third return in core 1, hart 0 ends the hart and sends the join resume address to core 0, hart 0 which is restarted. The last return at the end of core 0, hart 0 exits.