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 #pragma once
16 
17 #if defined(HAVE_SYS_TYPES_H)
18 #include <sys/types.h>
19 #endif
20 
21 //
22 // Creating threads
23 //
24 StgTSO *createThread (Capability *cap, W_ stack_size);
25 
26 void scheduleWaitThread (/* in    */ StgTSO *tso,
27                          /* out   */ HaskellObj* ret,
28                          /* inout */ Capability **cap);
29 
30 StgTSO *createGenThread       (Capability *cap, W_ stack_size,
31                                StgClosure *closure);
32 StgTSO *createIOThread        (Capability *cap, W_ stack_size,
33                                StgClosure *closure);
34 StgTSO *createStrictIOThread  (Capability *cap, W_ stack_size,
35                                StgClosure *closure);
36 
37 // Suspending/resuming threads around foreign calls
38 void *        suspendThread (StgRegTable *, bool interruptible);
39 StgRegTable * resumeThread  (void *);
40 
41 //
42 // Thread operations from Threads.c
43 //
44 int     cmp_thread                       (StgPtr tso1, StgPtr tso2);
45 int     rts_getThreadId                  (StgPtr tso);
46 void    rts_enableThreadAllocationLimit  (StgPtr tso);
47 void    rts_disableThreadAllocationLimit (StgPtr tso);
48 
49 #if !defined(mingw32_HOST_OS)
50 pid_t  forkProcess     (HsStablePtr *entry);
51 #else
52 pid_t  forkProcess     (HsStablePtr *entry)
53     GNU_ATTRIBUTE(__noreturn__);
54 #endif
55 
56 HsBool rtsSupportsBoundThreads (void);
57 
58 // The number of Capabilities.
59 // ToDo: I would like this to be private to the RTS and instead expose a
60 // function getNumCapabilities(), but it is used in compiler/cbits/genSym.c
61 extern unsigned int n_capabilities;
62 
63 // The number of Capabilities that are not disabled
64 extern uint32_t enabled_capabilities;
65 
66 #if !IN_STG_CODE
67 extern Capability MainCapability;
68 #endif
69 
70 //
71 // Change the number of capabilities (only supports increasing the
72 // current value at the moment).
73 //
74 extern void setNumCapabilities (uint32_t new_);
75