Questions on the RTS C API regarding threads and tasks

Nicola Gigante nicola.gigante at gmail.com
Wed Nov 4 19:12:39 UTC 2015


Hi everybody,

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 
otherwise.

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 
threads.

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?

- 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,

Greetings,
Nicola


More information about the ghc-devs mailing list