summaryrefslogtreecommitdiff
path: root/includes/rts/Threads.h
blob: e6844a322763838b41339a0256543b8d4fadd488 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* -----------------------------------------------------------------------------
 *
 * (c) The GHC Team 1998-2009
 *
 * External API for the scheduler.  For most uses, the functions in
 * RtsAPI.h should be enough.
 *
 * Do not #include this file directly: #include "Rts.h" instead.
 *
 * To understand the structure of the RTS headers, see the wiki:
 *   http://ghc.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Includes
 *
 * ---------------------------------------------------------------------------*/

#ifndef RTS_THREADS_H
#define RTS_THREADS_H

#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif

// 
// Creating threads
//
StgTSO *createThread (Capability *cap, W_ stack_size);

void scheduleWaitThread (/* in    */ StgTSO *tso,
                         /* out   */ HaskellObj* ret,
                         /* inout */ Capability **cap);

StgTSO *createGenThread       (Capability *cap, W_ stack_size,
			       StgClosure *closure);
StgTSO *createIOThread        (Capability *cap, W_ stack_size,
			       StgClosure *closure);
StgTSO *createStrictIOThread  (Capability *cap, W_ stack_size,
			       StgClosure *closure);

// Suspending/resuming threads around foreign calls
void *        suspendThread (StgRegTable *, rtsBool interruptible);
StgRegTable * resumeThread  (void *);

//
// Thread operations from Threads.c
//
int    cmp_thread      (StgPtr tso1, StgPtr tso2);
int    rts_getThreadId (StgPtr tso);

#if !defined(mingw32_HOST_OS)
pid_t  forkProcess     (HsStablePtr *entry);
#else
pid_t  forkProcess     (HsStablePtr *entry)
    GNU_ATTRIBUTE(__noreturn__);
#endif

HsBool rtsSupportsBoundThreads (void);

// The number of Capabilities
extern unsigned int n_capabilities;

// The number of Capabilities that are not disabled
extern nat enabled_capabilities;

#if !IN_STG_CODE
extern Capability MainCapability;
#endif

//
// Change the number of capabilities (only supports increasing the
// current value at the moment).
//
extern void setNumCapabilities (nat new);

#endif /* RTS_THREADS_H */