Previous Table of Contents Next


I vividly recall one such discussion with Ray Klotz, our engineering manager, and his staff. I was explaining how, with the new structure, we would not be limited to just a few interrupt levels. We could support hundreds of processes, and each could have a different priority level. Each I/O device could even have its own priority, if we chose, because our system would support multiple processes.

Ray interrupted and said, “You mean you’re building a multiprocessor?”

“No,” I replied, “we’re building a system to support multiple processes, not multiple processors.”

“What’s the difference?”

“A process is just like a task,” I answered. “We’re building a system to support multiple tasks, not multiple hardware processors.”

After a moment of silence, Ray said, “Then why don’t you just call them tasks?” From that day on, we did.

Task Dispatching in the AS/400

Associated with each task in the AS/400 is a control block in memory called a task dispatching element (TDE). A TDE is the fundamental data structure on which the tasking support is built. Because it exists below the MI, the TDE structure is not visible above the MI. This data structure is not a system object, but it is an important component of some system objects. Later in this chapter, we examine an MI process and see how this system object incorporates a TDE. A TDE contains all the necessary information to control the execution of a task. A task is a program in execution, so the TDE has the responsibility to tie together the program and the status of the executing program.

The States of a Task

Any task in the system can be in one of four states. A state defines the eligibility of a task to run in the processor. Note that, from a terminology standpoint, a state can have more than one name. In this section, we use the SLIC names for each state. The four states are

•  Suspended — This is the state where a task starts or ends. In this state, a task is not able to run in the processor.
•  Ready — This is the state of a task that is ready to run in the processor but is not yet running. Outside of SLIC, this state is also called ineligible, meaning some other task is running instead of this task.
•  Running — This is the state of a running task. Outside of SLIC, it is also called the active state. In a single processor, only one task can be running at any instant of time.
•  Wait — This is the state where the task is waiting for something, usually I/O. A task is not able to run when in this state.

Figure 9.1 shows the four states of a task, along with the transitions that can occur between the states.


Figure 9.1  States of a Task

With four states, 12 possible transitions can occur between two states if all are allowed. In an AS/400, only six transitions are allowed. They are

•  Initiate Task (Suspended to Ready) — This transition occurs when work is started and a task moves to a state where it is ready to run.
•  Run Task (Ready to Running) — This transition moves the task into the running (active) state and is usually called dispatching the task.
•  Suspend Task (Running to Suspended) — When the work for a task is finished, the task moves to the suspended state.
•  Preempt Task (Running to Ready) — When a task has not completed and is moved back to the ready state, it is said to be preempted. This move implies that there are other tasks in the system that are more important (higher priority) and can preempt a running task.
•  Wait (Running to Wait) — If a running task initiates some operation that forces the task to wait for the operation to complete before it can continue, the task moves to the wait state. An I/O operation can force a task to wait.
•  Signal (Wait to Ready) — If the operation a task is waiting for completes, the task moves from the wait state to the ready (ineligible) state.

Anyone who has used the WRKSYSSTS (Work with System Status) command will recognize some of these transitions. The WRKSYSSTS display shows rates of the following transitions: active to wait, active to ineligible, and wait to ineligible. You use these values when you tune the activity level in a storage pool. Later in this chapter, we define activity levels and storage pools and show how they fit into the system.

The state in which a task exists is determined by the location of the TDE associated with the task. TDEs move about in the system — actually, they don’t physically move; they logically move. All TDEs exist in the AS/400’s memory. A TDE contains address fields that can link it to other data structures. When we talk about a TDE moving, we mean the addresses in the data structures are adjusted to logically move the TDE to another data structure. Inserting a TDE to a data structure is called enqueuing, and removing a TDE is called dequeuing. Enqueuing and dequeuing are the operations provided in the SLIC to link the addresses. These linking operations are very fast compared to physically moving the TDE.

Task Dispatching Queue

The TDEs for all tasks eligible to run in the processor at any given time are arranged in a data structure called a task dispatching queue (TDQ). A TDQ is implemented as a chained list in memory with the TDEs ordered in priority sequence, as shown in Figure 9.2. Each TDE contains a priority field that is used for this ordering. The TDE for the task with the highest priority is at the top in this ordering.


Figure 9.2  Task Dispatching Queue

The task dispatcher implemented in SLIC selects the TDE with the highest priority (the one on the top of the list) and gives it control of the processor. In this way, the top TDE is the one associated with the task currently running in the processor. All other TDEs on the TDQ are associated with tasks that are in the ready state. The currently running task continues to run until it has to give up control of the processor. Several events can cause this to happen. The running task may perform an operation that forces it to give up control. Waiting for an I/O operation is one example. When a task uses up its allocated time in the processor (called timeslice end), the task is also forced to give up control. The running task can be preempted by some higher-priority task, which is still another way that forces it to give up control. Whenever the running task gives up control, the next highest priority task on the TDQ gets control and becomes the running task. Thus, any TDE that is on the TDQ is by definition either in the running or the ready state.


Previous Table of Contents Next

Copyright © NEWS/400 Books