[GHC] #8400: Migrate the RTS to use libuv (or libev, or libevent)
GHC
ghc-devs at haskell.org
Sat Jan 13 22:26:58 UTC 2018
#8400: Migrate the RTS to use libuv (or libev, or libevent)
-------------------------------------+-------------------------------------
Reporter: schyler | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Runtime System | Version:
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: 635, 7353 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by dobenour):
I have an idea for how to implement this:
* Each `Capability` contains a `uv_loop_t` as well as a pointer to a list
of threads that are blocked waiting on C callbacks to fire. Since
initializing a `uv_loop_t` can fail due to OS resource exhaustion, such as
too many open files, the RTS checks that initializing succeeded before a
capability can run Haskell code.
* Each Capability owns a pool of C structures
{{{#!C
typedef struct StgCCallbackInfo {
StgTSO *BlockedThread; /* The thread that is blocked waiting for the
callback */
StgWord refcount; /* Reference count */
void *user; /* Arbitrary C data */
} StgCCallbackInfo;
}}}
This list is a GC root. The members of this pool are in pinned memory,
so they can safely be referenced by C code
* The RTS exports C functions
{{{#!C
/**
* Allocates a C callback info struct, or NULL if we run out of memory.
*/
StgCCallbackInfo *rts_newCCallbackInfo(Capability *c, StgTSO *t, void
*user);
/**
* Wakes up the thread pointed to by the given `StgCCallbackInfo`.
*/
void rts_wakeupThread(struct StgCCallbackInfo *ptr);
/**
* Increments the reference count on the `StgCCallbackInfo`.
*/
void rts_callback_incref(struct StgCCallbackInfo *ptr);
/**
* Decrements the reference count.
*/
void rts_callback_decref(struct StgCCallbackInfo *ptr);
}}}
which can be used to manipulate these structures
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8400#comment:24>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list