#include "GetTime.h"
+BEGIN_RTS_PRIVATE
+
/*
Definition of a Task
--------------------
Task, and OS threads that enter the Haskell RTS for the purposes of
making a call-in are also Tasks.
- The relationship between the number of tasks and capabilities, and
- the runtime build (-threaded, -smp etc.) is summarised by the
- following table:
-
- build Tasks Capabilities
- ---------------------------------
- normal 1 1
- -threaded N N
+ In the THREADED_RTS build, multiple Tasks may all be running
+ Haskell code simultaneously. A task relinquishes its Capability
+ when it is asked to evaluate an external (C) call.
- The non-threaded build has a single Task and a single global
- Capability.
-
- The THREADED_RTS build allows multiple tasks and mulitple Capabilities.
- Multiple Tasks may all be running Haskell code simultaneously. A task
- relinquishes its Capability when it is asked to evaluate an external
- (C) call.
-
- In general, there may be multiple Tasks for an OS thread. This
- happens if one Task makes a foreign call from Haskell, and
- subsequently calls back in to create a new bound thread.
+ In general, there may be multiple Tasks associated with a given OS
+ thread. A second Task is created when one Task makes a foreign
+ call from Haskell, and subsequently calls back in to Haskell,
+ creating a new bound thread.
A particular Task structure can belong to more than one OS thread
over its lifetime. This is to avoid creating an unbounded number
// Requires: sched_mutex.
//
void initTaskManager (void);
-void stopTaskManager (void);
-void freeTaskManager (void);
+nat freeTaskManager (void);
// Create a new Task for a bound thread
// Requires: sched_mutex.
// mainly for stats-gathering purposes.
// Requires: sched_mutex.
//
+#if defined(THREADED_RTS)
+// In the non-threaded RTS, tasks never stop.
void workerTaskStop (Task *task);
+#endif
// Record the time spent in this Task.
// This is called by workerTaskStop() but not by boundTaskExiting(),
//
INLINE_HEADER Task *myTask (void);
-// After a fork, the tasks are not carried into the child process, so
-// we must tell the task manager.
-// Requires: sched_mutex.
-//
-void resetTaskManagerAfterFork (void);
-
#if defined(THREADED_RTS)
// Workers are attached to the supplied Capability. This Capability
setMyTask(task);
}
+END_RTS_PRIVATE
+
#endif /* TASK_H */