/docs/internals/task_states.txt

http://github.com/kilim/kilim · Plain Text · 49 lines · 34 code · 15 blank · 0 comment · 0 complexity · 181bb18e6689895d8285d2add4d750cb MD5 · raw file

  1. See task_states.pdf
  2. Explanation of states:
  3. new: start not called
  4. ready: task.start()/resume() called. Task is in the
  5. scheduler q or has been taken out of it and handed to
  6. the thread. Note that task.running = true (doesn't reflect
  7. the 'running' state below)
  8. running: stack is resumed. task runs normally to completion
  9. or until Task.pause/yield/exit is called.
  10. pausing: pause called with a PauseReason object
  11. pauseReason can be user-defined. Predefined ones are
  12. YieldReason, TaskDoneReason, Empty_MsgAvListener,
  13. Full_SpcAvListener etc.
  14. Task.running remains true until it moves to paused state.
  15. paused: waiting for a message.
  16. Task.running = false /\ Task.pauseReason.isValid()
  17. done : task.execute() returned normally or with an unchecked exception
  18. or Task.exit() called
  19. ====================================================================
  20. Messages and task scheduling
  21. What happens when a message arrives in each of the above states?
  22. new: no scheduling on msgs. start() explicitly schedules the task whether
  23. or not there are mailboxes.
  24. ready:
  25. running:
  26. no scheduling necessary when msg is put into mbox; task will rcv
  27. the message on get() The distinction between ready and running is
  28. not really important from a scheduling or message interaction
  29. perspective.
  30. pausing: no scheduling yet, because the task is still unwinding,
  31. But after the task is fully unwound, it'll be scheduled again if there
  32. are messages in an mbox that caused that task to pause in the first
  33. place.
  34. paused: Schedule the task.