Preemption a haskell thread inside a Transaction

Rodrigo Duarte rmduarte at
Wed Jun 26 13:42:13 UTC 2019

I am trying to modify the GHC rts so that every time a transaction fails to
commit, instead of automatically restart it,
I want to preempted and add it to the end of the task queue of its HEC.

The problem is, when I try to call  yield at the point of the
 ATOMICALLY_FRAME code where the transaction is restarted,
I get this error message:

>>Main: Control.Concurrent.STM.atomically was nested
>>Main: thread blocked indefinitely in an MVar operation

The point in the code of PrimOps.cmm I try to put my code is as below.

1074   /* Transaction was not valid: try again */
1075        ("ptr" trec) = ccall stmStartTransaction(MyCapability() "ptr",
1076                                                 NO_TREC "ptr");
1077        StgTSO_trec(CurrentTSO) = trec;
1079 /* call yield function here */
            Capability_context_switch(MyCapability()) = 1 :: CInt;
            jump stg_yield_noregs();
            /*                          */
1080        jump stg_ap_v_fast
1081            // push the StgAtomicallyFrame again: the code generator is
1082            // clever enough to only assign the fields that have
1083            (ATOMICALLY_FRAME_FIELDS(,,info_ptr,p1,p2,
1084                                     code,frame_result))
1085            (code);

My doubts are:
    Is it possible to make a preemption at that point in the
ATOMICALLY_FRAME code?. If it is possible, how do I proceed?

Thanks for the attention.
Best regards.

*Rodrigo M. Duarte*
Bacharelado em Engenharia de Computação
LUPS - Laboratory of Ubiquitous and Parallel Systems
Computação de Alto Desempenho Sustentável
Universidade Federal de Pelotas - UFPel

[image: image_png_part?hl=pt&part=2&thumb=1]

*Antes de imprimir este e-mail pense em sua responsabilidade e compromisso
com o Meio Ambiente. **Só imprima se for realmente necessário. *

*Before printing this e-mail consider its responsibility and commitment to
the environment. Only print if it is really necessary. *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list