5db5cb7bd8908c8b763a6efba3eb948c65bbc5ef
[ghc.git] / includes / rts / Threads.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team 1998-2009
4 *
5 * External API for the scheduler. For most uses, the functions in
6 * RtsAPI.h should be enough.
7 *
8 * Do not #include this file directly: #include "Rts.h" instead.
9 *
10 * To understand the structure of the RTS headers, see the wiki:
11 * http://hackage.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
12 *
13 * ---------------------------------------------------------------------------*/
14
15 #ifndef RTS_THREADS_H
16 #define RTS_THREADS_H
17
18 #ifdef HAVE_SYS_TYPES_H
19 #include <sys/types.h>
20 #endif
21
22 //
23 // Creating threads
24 //
25 StgTSO *createThread (Capability *cap, nat stack_size);
26
27 void scheduleWaitThread (/* in */ StgTSO *tso,
28 /* out */ HaskellObj* ret,
29 /* inout */ Capability **cap);
30
31 StgTSO *createGenThread (Capability *cap, nat stack_size,
32 StgClosure *closure);
33 StgTSO *createIOThread (Capability *cap, nat stack_size,
34 StgClosure *closure);
35 StgTSO *createStrictIOThread (Capability *cap, nat stack_size,
36 StgClosure *closure);
37
38 // Suspending/resuming threads around foreign calls
39 void * suspendThread (StgRegTable *, rtsBool interruptible);
40 StgRegTable * resumeThread (void *);
41
42 //
43 // Thread operations from Threads.c
44 //
45 int cmp_thread (StgPtr tso1, StgPtr tso2);
46 int rts_getThreadId (StgPtr tso);
47
48 #if !defined(mingw32_HOST_OS)
49 pid_t forkProcess (HsStablePtr *entry);
50 #else
51 pid_t forkProcess (HsStablePtr *entry)
52 GNU_ATTRIBUTE(__noreturn__);
53 #endif
54
55 HsBool rtsSupportsBoundThreads (void);
56
57 // The number of Capabilities
58 extern unsigned int n_capabilities;
59
60 #if !IN_STG_CODE
61 extern Capability MainCapability;
62 #endif
63
64 //
65 // Change the number of capabilities (only supports increasing the
66 // current value at the moment).
67 //
68 extern void setNumCapabilities (nat new);
69
70 #endif /* RTS_THREADS_H */