Applies To:
  • CitectSCADA 1.xx, 2.xx, 3.xx, 4.xx, 5.xx

Summary:
When you do a Page Task in the Kernel, it list the Citect tasks running and their states. What do the states specifically mean? 

Solution:
The following states are used for Citect Kernel Tasks:

FREE This Task Control Block has not been allocated to a task and is currently free.

CURR The task is currently executing CPU cycles.

READY The task is ready to run, but is waiting for the current task to finish its time slice before executing.

SLEEP The task is sleeping for a time period. Once the time period completed the task will change into the ready state.

WAIT The task is blocked waiting on a semaphore. The task will wait indefinitely in this state until the semaphore is signalled and moves to the READY state.

SUSP The task has been put into the suspended state. It will block indefinitely in this state until another task resumes this task into the READY state.

DODGY The task is in a undefined state due to a software fault.

Tasks are first created in the suspended state. This allows the creator of the task to have control over the task before is starts executing any instructions. When the creator task is ready it will then resume the new task into the READY state. Once in the ready state that task will compete for CPU resources with all other tasks in the READY state. The Citect Kernel uses a round robin scheduler with 3 levels or priority and task pre-emption for scheduling. This is a very simple scheduler which gives excellent real-time deterministic response. Depending on how busy your Citect system is, there may be none or many tasks in the ready state. The kernel schedules a task in the ready state to run by placing it in the current state and executing its code. There can only be one task in the current state as the primary Citect scheduler runs on a single CPU only. The task will execute until it exhausts it's allocated time slice, is pre-empted by a higher priority task, is placed into a blocking state or is killed.

The three scheduling priority levels are High, User and Low. The priories are assigned by the Citect developers and cannot be changed by customers. The Citect real time tasks like the I/O Server and it's sub systems run at High priority. Most tasks run at User priority and back ground tasks like printing run at Low priority.

Tasks may also put themselves to sleep for a fixed time period (for example for 1 second). After the time period has expired the kernel will place the tasks back into the ready state. Tasks may also wait on semaphores and be put into the wait state. Tasks stay in the wait state until another task signals the semaphore. Once the semaphore is signalled the kernel will change the state from wait to ready to allow the task to run. Task may also use the suspend and resume to control the executing of other tasks similar to using semaphores.

The tasks change state very, very quickly. Small lightly loaded systems will have 1000's of task state changes a second. As the Page Task window will refresh once a second, you will not see most of these state changes. The best way to see if a task is running is if the Count property is incrementing. For example the "Anm.Animate" task may show in the Page Task as:

U Anm.Animate 6 sleep user 1.8 0.000 0.008 0.000 177

This task is in the sleep state. As the count (177) is incrementing you know it is running at some time. This task will sleep for 250 ms, then wakeup and be put into the READY state. When it is scheduled to run it will go into the CURR state and then be placed back into the sleep state. If you computer is lightly loaded you will see this task almost always in the SLEEP state. This is because it will execute so quickly and go back into the sleeping state. If your computer is highly loaded you will see this task and maybe several others in the READY state waiting for the CPU to execute. The Page Task display is updated by a Citect Kernel task, so when this task is updating the display of Page Task it is the task which is running. Because of this, you will only ever see the 'Show.task' as the current task. You will never see any other task in the current state, but you can tell they are executing because the Count property is incrementing.

If you press and hold down down on the spacebar, the Page Task window will update at the key press repeat rate (default of 20 per second), so you can see more task changes.

 

Keywords:
 

Attachments