[ci skip] includes: detabify/dewhitespace rts/Hpc.h
[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://ghc.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, W_ stack_size);
26
27 void scheduleWaitThread (/* in */ StgTSO *tso,
28 /* out */ HaskellObj* ret,
29 /* inout */ Capability **cap);
30
31 StgTSO *createGenThread (Capability *cap, W_ stack_size,
32 StgClosure *closure);
33 StgTSO *createIOThread (Capability *cap, W_ stack_size,
34 StgClosure *closure);
35 StgTSO *createStrictIOThread (Capability *cap, W_ 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 // The number of Capabilities that are not disabled
61 extern nat enabled_capabilities;
62
63 #if !IN_STG_CODE
64 extern Capability MainCapability;
65 #endif
66
67 //
68 // Change the number of capabilities (only supports increasing the
69 // current value at the moment).
70 //
71 extern void setNumCapabilities (nat new_);
72
73 #endif /* RTS_THREADS_H */