Asynchronous Transfer of Control

From Suhrid.net Wiki
Jump to navigationJump to search

Intro

  • An ATC is where the point of execution of one SO is changed by the action of another SO.
  • Therefore an SO may be executing on 1 method and through no action of its own, find itself executing in another method.
  • Controversial:
    • Complicates language semantics.
    • Makes it difficult to write correct code as it may be interfered with.
    • Increases complexity of the RTJVM.
    • Slow down code which does not use the feature.

Requirements for ATC

  • Fundamental requirement is for a thread to respond quickly to a condition detected by another thread.
  • Error recovery: To support coordinated error recovery between real-time threads.
    • Where several threads are performing a computation, an error detected by one thread needs to be quickly and safely communicated to other threads.
  • Mode changes: Where changes between modes are expected but cannot be planned.
    • A fault may lead to aircraft abandoning take off and entering emergency mode.
    • An accident in a manufacturing plant may required mode change to shutdown the plant.
    • Threads must be quickly and safely informed that the mode in which they are operating has changed and they now need to perform different sets of actions.
  • Scheduling using partial/imprecise computations: Many algos whose accuracy depends on how much time has been allocated to their calculation, when times up thread must be interrupted to stop refinement of result.
  • User Interrupts - Users may want to cancel current operation because they have detected an error condition and want to start again.

How to solve

  • Polling - Polling for notifications is too slow.
  • Aborts - Destroy the thread and allow another thread to perform some recovery. However destroying thread can be expensive and may be an extreme response. This can also leave system in inconsistent state (monitor locks may not be released)
  • Therefore a control form of ATC is required.

RTSJ Basic Model