Questions on the RTS C API regarding threads and tasks
marlowsd at gmail.com
Thu Nov 12 11:24:53 UTC 2015
On 04/11/2015 19:12, Nicola Gigante wrote:
> I’m new on this list, congratulations to everyone for
> the great work that you’re doing on GHC!
> I apologize if this is not the right list where to ask the following
> questions. Please point me to the correct list or IRC channel
> I’m part of a small group of people who is going to work
> on a project that seems to need low-level handling of haskell
> I’ve started delving into the ghc runtime API to understand
> if everything we need is exposed to the world or if we
> have to modify the runtime itself (which I would avoid if possible).
> I have a few questions about the functions that the runtime
> exports to the C world regarding the manipulation of tasks:
> - Fundamentally, is there a way for a C function called by a foreign call
> to suspend the haskell thread that called it, to be resumed later
> when appropriate? I see that the runtime has a concept of
> “blocking queue”, but I also see that the functions that work on
> blocking queues are not exported. I can manage a queue of TSOs myself,
> but then I need a way to put in sleep the task indefinitely up to a wake signal.
> In other words, can I sleep and awake haskell threads from a C function
> called by a foreign call?
When you call a C function from Haskell, the Haskell thread that called
it *is* suspended, until the C call returns. So I'm not sure exactly
what it is you want to do - maybe you could describe in more detail?
> - I see the “suspendThread” and “resumeThread” functions exist in include/rts/Threads.h
> Are these the functions that I need for the point above? My main concern is
> that the comments in the source code for suspendThread say that these
> functions are used in case of a CCall, and put the thread in a specific queue,
> so they seems to have more specific role than what the name might suggest.
> - Also, I’m unable to find what a StgRegTable is
> (which is taken as argument by suspendThread).
> Thank you in advance for your help,
> ghc-devs mailing list
> ghc-devs at haskell.org
More information about the ghc-devs