When such a situation occurs, stack pointer is reset to top of the unfinished frames. Interestingly, a thread migration is just a combination of thread blocks and a resume. At this point, W temporarily blocks g and resumes f . Next f also temporarily blocks and resumes the parent of f . The parent of f passes the context of f to U through shared-memory and then restarts g .
U picks up the context of f and restarts it.
In general, to migrate a thread from W to U , W first blocks all frame above the migrating thread. Next W blocks the migrating thread too. W then restarts threads above the migrating thread. The migrating thread is picked up by U and restarted. This way, the migrating thread is pulled out from one stack and reconnected to another.