| 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 youre building a multiprocessor?
No, I replied, were building a system to support multiple processes, not multiple processors.
Whats the difference?
A process is just like a task, I answered. Were building a system to support multiple tasks, not multiple hardware processors.
After a moment of silence, Ray said, Then why dont you just call them tasks? From that day on, we did.
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.
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
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
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 dont physically move; they logically move. All TDEs exist in the AS/400s 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.
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 |