I'm in the progress of implementing my bound threads proposal,
and I'm stuck in the depths of the RTS...
I've added a PrimOp,
bindThread# :: (State# RealWorld -> (# State# RealWorld, a #))
-> (State# RealWorld -> (# State# RealWorld, a #))
It even works... basically.
No under some circumstances, I have to return to the scheduler from the
middle
of the primop.
I just pushed an info pointer onto the stack, and R1 points to the IO
action argument.
I want to execute the IO action argument and then continue with
stg_unbindThreadzh_ret
(that part works), but only after returning to the scheduler once (that
I don't know how to do).
Could you give me a hint?
Cheers,
Wolfgang
P.S.: Here's a shortened version of the relevant code (inspired by
blockAsyncExceptions#):
FN_(bindThreadzh_fast)
{
FB_
/* Args: R1 :: IO a */
STK_CHK_GEN( 2/* worst case */, R1_PTR, bindThreadzh_fast);
// ...
Sp--;
Sp[0] = (W_)&stg_unbindThreadzh_ret_info;
if(...)
{
// here, I want to yield
}
else
{
// ...
}
#endif
Sp--;
JMP_(stg_ap_v_ret);
FE_
}
INFO_TABLE_RET( \
stg_unbindThreadzh_ret_info, \
stg_unbindThreadzh_ret_entry, \
MK_SMALL_BITMAP(0/*framesize*/, 0/*bitmap*/), \
0, 0, 0, RET_SMALL, , EF_, 0, 0 \
);
FN_(stg_unbindThreadzh_ret_entry)
{
FB_
//...
#ifdef REG_R1
Sp++;
JMP_(ENTRY_CODE(Sp[0]));
#else
Sp[1] = Sp[0];
Sp++;
JMP_(ENTRY_CODE(Sp[1]));
#endif
FE_
}
|