Threads.h 1.65 KB
Newer Older
1 2 3 4 5 6 7 8
/* ---------------------------------------------------------------------------
 *
 * (c) The GHC Team, 2006
 *
 * Thread-related functionality
 *
 * --------------------------------------------------------------------------*/

9
#pragma once
10

11
#include "BeginPrivate.h"
12

13 14
#define END_BLOCKED_EXCEPTIONS_QUEUE ((MessageThrowTo*)END_TSO_QUEUE)

15
StgTSO * unblockOne (Capability *cap, StgTSO *tso);
Ben Gamari's avatar
Ben Gamari committed
16
StgTSO * unblockOne_ (Capability *cap, StgTSO *tso, bool allow_migrate);
17

18 19
void checkBlockingQueues (Capability *cap, StgTSO *tso);
void tryWakeupThread     (Capability *cap, StgTSO *tso);
20
void migrateThread       (Capability *from, StgTSO *tso, Capability *to);
21 22 23 24

// Wakes up a thread on a Capability (probably a different Capability
// from the one held by the current Task).
//
Ben Gamari's avatar
Ben Gamari committed
25
#if defined(THREADED_RTS)
26 27 28 29 30 31 32
void wakeupThreadOnCapability (Capability *cap,
                               Capability *other_cap, 
                               StgTSO *tso);
#endif

void updateThunk         (Capability *cap, StgTSO *tso,
                          StgClosure *thunk, StgClosure *val);
33

Ben Gamari's avatar
Ben Gamari committed
34 35
bool removeThreadFromQueue     (Capability *cap, StgTSO **queue, StgTSO *tso);
bool removeThreadFromDeQueue   (Capability *cap, StgTSO **head, StgTSO **tail, StgTSO *tso);
36 37 38

StgBool isThreadBound (StgTSO* tso);

39
// Overflow/underflow
40
void threadStackOverflow  (Capability *cap, StgTSO *tso);
41
W_   threadStackUnderflow (Capability *cap, StgTSO *tso);
42

Ben Gamari's avatar
Ben Gamari committed
43
bool performTryPutMVar(Capability *cap, StgMVar *mvar, StgClosure *value);
Simon Marlow's avatar
Simon Marlow committed
44

Ben Gamari's avatar
Ben Gamari committed
45
#if defined(DEBUG)
46 47 48 49 50 51
void printThreadBlockage (StgTSO *tso);
void printThreadStatus (StgTSO *t);
void printAllThreads (void);
void printThreadQueue (StgTSO *t);
#endif

52
#include "EndPrivate.h"