rts: Add api to pin a thread to a numa node but without fixing a capability
[ghc.git] / rts / RaiseAsync.h
1 /* ---------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 1998-2006
4 *
5 * Asynchronous exceptions
6 *
7 * --------------------------------------------------------------------------*/
8
9 #ifndef RAISEASYNC_H
10 #define RAISEASYNC_H
11
12 #define THROWTO_SUCCESS 0
13 #define THROWTO_BLOCKED 1
14
15 #ifndef CMINUSMINUS
16
17 #include "BeginPrivate.h"
18
19 StgTSO* raiseAsync (Capability *cap,
20 StgTSO *tso,
21 StgClosure *exception,
22 rtsBool stop_at_atomically,
23 StgUpdateFrame *stop_here);
24
25 void throwToSingleThreaded (Capability *cap,
26 StgTSO *tso,
27 StgClosure *exception);
28
29 void throwToSingleThreaded_ (Capability *cap,
30 StgTSO *tso,
31 StgClosure *exception,
32 rtsBool stop_at_atomically);
33
34 void throwToSelf (Capability *cap,
35 StgTSO *tso,
36 StgClosure *exception);
37
38 void suspendComputation (Capability *cap,
39 StgTSO *tso,
40 StgUpdateFrame *stop_here);
41
42 MessageThrowTo *throwTo (Capability *cap, // the Capability we hold
43 StgTSO *source,
44 StgTSO *target,
45 StgClosure *exception); // the exception closure
46
47 uint32_t throwToMsg (Capability *cap,
48 MessageThrowTo *msg);
49
50 int maybePerformBlockedException (Capability *cap, StgTSO *tso);
51 void awakenBlockedExceptionQueue (Capability *cap, StgTSO *tso);
52
53 /* Determine whether a thread is interruptible (ie. blocked
54 * indefinitely). Interruptible threads can be sent an exception with
55 * killThread# even if they have async exceptions blocked.
56 */
57 INLINE_HEADER int
58 interruptible(StgTSO *t)
59 {
60 switch (t->why_blocked) {
61 case BlockedOnMVar:
62 case BlockedOnSTM:
63 case BlockedOnMVarRead:
64 case BlockedOnMsgThrowTo:
65 case BlockedOnRead:
66 case BlockedOnWrite:
67 #if defined(mingw32_HOST_OS)
68 case BlockedOnDoProc:
69 #endif
70 case BlockedOnDelay:
71 return 1;
72 // NB. Threaded blocked on foreign calls (BlockedOnCCall) are
73 // *not* interruptible. We can't send these threads an exception.
74 default:
75 return 0;
76 }
77 }
78
79 #include "EndPrivate.h"
80
81 #endif /* CMINUSMINUS */
82
83 #endif /* RAISEASYNC_H */