A ret instruction may serve as a return if the function it ends was called with no fork (e.g. the second ret ending f after the call of f in main returns to a).
It may serve as a section end if the function it ends was called by a fork (e.g. the last ret after the calls to g).
The ra register holding the return address is transmitted from section to section with p_swcv ra,0/p_lwcv ra,0 pairs.
For example, address a which starts code portion (4) is sent to the last section ending f which allows the ret to return to a.
The section ending ret instructions are ended in-order in the processor.
In the example, this ensures that code portion (4) starts only after the ret ending f has been run, i.e. after all the calls to g are finished.
The execution order is (1), then 4 times (2) and (3) in any (but deterministic) interleaving, then (4).