Previous Topic: DC Programming TechniquesNext Topic: Returning to a Higher-level Program


Passing Program Control

DC provides program management facilities that allow you to pass control either between programs in a single task thread or from task to task. Using these program management functions, you can:

Levels of Program Control

The figure below shows levels of programs in a task. TASKA invokes Program A, which calls Program B expecting return of control. Program B passes control laterally to Program C, which then returns control to Program A. When Program A is finished, it returns control to DC specifying that TASKX should be the next task invoked on that logical terminal.

                               Next task code 'TASKX'
                            ┌─ - - - - - - - - - - - - - - - - ─┐

                            │                                   │
           DC
───────────┬────────────────▲───────────────────────────────────┼──────────────
           │   TASKA        │                                   │   TASKX
           │                                                    │
           │                │                                   │
           │                                                    │
  ┌────────▼───────┐        │                           ┌───────▼───────┐
  │                │                                    │               │
  │   Program A    │        │                           │  Program D    │
  │   (level 1)    │                                    │               │
  │                ◄────────┼──────────┐                │               │
  │                │        │          │                │               │
  │                │                   │                │               │
  └────────┬────┬──┘        │          │                └───────────────┘
           │                           │
           │    │           │          │
           │                           │
           │    └─ - - - - ─┘          │
           │                           │
  ┌────────▼───────┐           ┌───────┴───────┐
  │                │           │               │
  │   Program B    │           │  Program C    │
  │   (level 2)    │           │  (level 2)    │
  │                ├───────────►               │
  │                │           │               │
  │                │           │               │
  └────────────────┘           └───────────────┘