MAINTAINING THE EXECUTION HISTORY OF A TASK
Tracking the execution history of the task set is useful for reviewing how tasks were scheduled after execution has completed. A user can view more detailed timing statistics such as when a job was scheduled, for how long, and how a job completed for any task since the SRMS system started.
Each task (task_struct structure) contains a task_history
structure named execHistory as specified in the srms.h header
file. The task_history structure contains a pointer to an array of job_exec_history
structures. The length of this array is defined by the MAX_HISTORY value
which is set to 500 by default in srms.h. Each entry in this array pertains
to one instance that a job gets scheduled. For example, if a job gets preempted 10 times
before its period completes, then the execution history of that job will occupy 10 entries
in the array. The value of MAX_HISTORY means that the scheduler will record
the execution history of the first 500 times that the task gets scheduled. After 500, the
array wraps back to zero, so results may be misleading. The programmer should modify this
value depending on the intended use of the system.
Memory storage for this array gets allocated when a task registers with the system for
the first time. The function initialize_task() is called from set_SRMS_rtparams()
to reserve space for MAX_HISTORY entries in the task's execution history
array. Also, each task_history structure contains an unsigned integer value
called last_index which points to the first unused index in the array.
Initially, this value is zero.
Each time a job gets scheduled, the SRMS scheduler
begins record keeping in a new entry in the execHistory array starting at the
index pointed to by last_index. Just before a job get scheduled, its start
time (relative to the SRMS scheduler
start time) is recorded using Win32 API function timeGetTime(). Also, the
time remaining in the task's budget and the execution time remaining are recorded as well.
Next, the scheduler releases control of the processor to the job. When the it resumes, the
scheduler immediately records the job's end time with timeGetTime(). It
also uses Window's higher-resolution counter to more accurately compute the total time
that the job spent executing and records that value in the dJobElapsed field.
Once completed, the last_index value is incremented. At each job's deadline,
more record keeping is performed on the job's periodic performance with the help of the record_job_results()
function. The status field is filled with a character indicating the
completion status of a job. This value could be one of four characters depending on
if the job met its guaranteed deadline (*), missed its guaranteed deadline (=), met a non-guaranteed
deadline (+), or missed a non-guaranteed deadline (-). Once finished with record keeping
for the last job, the scheduler tries to admit the task's next job by calling admit_next_job().
This function contributes to the job's execution history by recording any timing
discrepancy between when a job should have been ready and the actual current time using timeGetTime().
It also records the amount of time that the SRMS scheduler wasted while waiting for a task
to reply with its next job's expected execution time. This is stored in the communication_wait
field of the job_exec_history structure. Next, the admit and reject functions
fill the admit_reject entry with an 'A' or an 'R'
to indicate whether a job is admitted or rejected.
All of this information gets processed by the export_history() function
after the user selects 'Export Task History' from the File menu. It creates a tab
delimited text file, whose default name is 'history.doc' as defined in srms.h.
The function reformats the information neatly into a table and presents more insight into
the execution of the task set. The example below presents a sample of an exported task
history. Values in the 'Period' column reflects the beginning of a task's
period in milliseconds. If a job gets preempted during execution, then the next time
that the job is scheduled, this column's value displays a dash '-' indicating that the job
is still executing in the same period. 'Disc' is the discrepancy in milliseconds between
when the task should have been ready and when it was actually ready, according to the SRMS
scheduler. 'Start' and 'End' display the times recorded for the
start and end of that job's portion of execution. 'Exec' shows the job's
execution requirement while 'ExLeft' shows how much the job needs to execute
before reaching its execution requirement. 'LeftOvr' reflects how much time
gets passed on to this job from the excess time in the budgets of higher priority tasks.
The 'A/R' column tells whether a job is accepted or rejected. If dual
priority is enabled, then this column also indicates whether a job is scheduled at a high
or low priority compared to other real-time tasks. The 'RealElap'
column displays how much real time elapsed between when the SRMS scheduler released the
processor and when the scheduler regained the processor. The final column 'Stat'
displays the completion status of the job, as described above.
One more final note, the export_history() function outputs the execution
history of all tasks that were at one point active and registered since the SRMS
application started. It first outputs execution histories for all currently active
and registered tasks (found in the task_list) and then traverses the
unregistered task list (unregistered_task_list) for any tasks that previously
unregistered.
E:\Project\task1\Debug\task1.exe
Process 60, Thread 189
Period = 1000 msec
QoS achieved = 88.24, minimum QoS requirement = 80.
Met Deadlines = 15, Missed Deadlines = 2
Met Guaranteed Deadlines = 9, Missed Guaranteed Deadlines = 0
Total Guaranteed Deadlines = 9
| Period | Disc | Wait | Start | End | Exec | ExLeft | Budget | LftOvr | A/R | RealElap | Stat |
0 |
1 |
0 |
3 |
323 |
320 |
320 |
361 |
0 |
A |
319.639 |
* |
| 1000 | 1 | 0 | 1607 | 1920 | 312 | 312 | 41 | 0 | R | 313.102 | + |
| 2000 | 0 | 0 | 2000 | 2313 | 312 | 312 | 361 | 0 | A | 312.213 | * |
| 3000 | 2 | 1 | 3002 | 3299 | 296 | 296 | 48 | 0 | R | 296.561 | + |
| 4000 | 1 | 1 | 4002 | 4299 | 296 | 296 | 361 | 0 | A | 296.738 | * |
| 5000 | 1 | 1 | 5914 | 6001 | 279 | 279 | 64 | 0 | R | 86.2668 | - |
| 6000 | 2 | 1 | 6003 | 6282 | 279 | 279 | 361 | 0 | A | 279.378 | * |
| 7000 | 2 | 1 | 7002 | 7305 | 302 | 302 | 81 | 0 | R | 302.586 | + |
| 8000 | 1 | 1 | 8002 | 8305 | 302 | 302 | 361 | 0 | A | 302.53 | * |
| 9000 | 1 | 1 | 9001 | 9142 | 140 | 140 | 58 | 0 | R | 140.067 | + |
| 10000 | 1 | 1 | 10002 | 10143 | 140 | 140 | 361 | 0 | A | 139.926 | * |
| 11000 | 1 | 0 | 11543 | 11856 | 312 | 312 | 221 | 0 | R | 312.827 | + |
| 12000 | 2 | 1 | 12002 | 12315 | 312 | 312 | 361 | 0 | A | 312.25 | * |
| 13000 | 2 | 1 | 13002 | 13299 | 296 | 296 | 48 | 0 | R | 296.648 | + |
| 14000 | 1 | 1 | 14002 | 14299 | 296 | 296 | 361 | 0 | A | 296.617 | * |
| 15000 | 1 | 1 | 15914 | 16000 | 280 | 280 | 64 | 0 | R | 86.266 | - |
| 16000 | 1 | 1 | 16002 | 16283 | 280 | 280 | 361 | 0 | A | 280.119 | * |
| 17000 | 2 | 1 | 17002 | 17308 | 305 | 305 | 80 | 0 | R | 305.715 |
---------------------------------------------------------------------------------
E:\Project\task2\Debug\task2.exe
Process 132, Thread 96
Period = 2000 msec
QoS achieved = 100., minimum QoS requirement = 75.
Met Deadlines = 8, Missed Deadlines = 0
Met Guaranteed Deadlines = 7, Missed Guaranteed Deadlines = 0
Total Guaranteed Deadlines = 8
| Period | Disc | Wait | Start | End | Exec | ExLeft | Budget | LftOvr | A/R | RealElap | Stat |
0 |
2 |
0 |
323 |
759 |
435 |
435 |
1413 |
0 |
A |
435.31 |
* |
| 2000 | 0 | 0 | 2313 | 2768 | 455 | 455 | 977 | 0 | A | 455.446 | * |
| 4000 | 2 | 1 | 4299 | 4774 | 474 | 474 | 1413 | 0 | A | 474.495 | * |
| 6000 | 3 | 1 | 6282 | 6777 | 494 | 494 | 938 | 0 | A | 494.562 | * |
| 8000 | 2 | 1 | 8305 | 8860 | 554 | 554 | 443 | 0 | R | 554.758 | + |
| 10000 | 2 | 1 | 10143 | 10697 | 554 | 554 | 1413 | 0 | A | 553.988 | * |
| 12000 | 2 | 0 | 12315 | 12769 | 454 | 454 | 859 | 0 | A | 454.437 | * |
| 14000 | 2 | 1 | 14299 | 14774 | 474 | 474 | 1413 | 0 | A | 474.498 | * |
| 16000 | 2 | 1 | 16283 | 16778 | 494 | 494 | 938 | 0 | A | 494.562 |
---------------------------------------------------------------------------------
E:\Project\task3\Debug\task3.exe
Process 190, Thread 167
Period = 5000 msec
QoS achieved = 100., minimum QoS requirement = 70.
Met Deadlines = 3, Missed Deadlines = 0
Met Guaranteed Deadlines = 3, Missed Guaranteed Deadlines = 0
Total Guaranteed Deadlines = 4
| Period | Disc | Wait | Start | End | Exec | ExLeft | Budget | LftOvr | A/R | RealElap | Stat |
0 |
3 |
1 |
759 |
1001 |
847 |
847 |
3605 |
0 |
A |
241.747 |
|
| - | - | 0 | 1001 | 1607 | 847 | 605 | 3605 | 0 | 605.112 | * | |
| 5000 | 1 | 0 | 5001 | 5914 | 912 | 912 | 2757 | 0 | A | 912.194 | * |
| 10000 | 2 | 0 | 10697 | 11001 | 846 | 846 | 1844 | 0 | A | 303.718 | |
| - | - | 0 | 11002 | 11543 | 846 | 542 | 1844 | 0 | 541.901 | * | |
| 15000 | 1 | 0 | 15001 | 15914 | 912 | 912 | 998 | 0 | A | 912.06 |
---------------------------------------------------------------------------------