00001 00010 // =================================================================== 00011 // INCLUDES 00012 00013 #include "Task.hh" 00014 // =================================================================== 00015 00016 00017 00018 // =================================================================== 00019 Task::Task () { 00020 00021 // Initialize all of the data members to zero/null. 00022 task_ID = 0; 00023 process = NULL; 00024 parent_task = NULL; 00025 virtual_cycle_time = 0; 00026 virtual_instruction_time = 0; 00027 virtual_reference_time = 0; 00028 last_system_cycle_time = 0; 00029 last_system_instruction_time = 0; 00030 last_system_reference_time = 0; 00031 00032 } // Task::Task 00033 // =================================================================== 00034 00035 00036 00037 // =================================================================== 00038 void 00039 Task::mark_quanta_start (const timestamp_t system_cycle_time, 00040 const timestamp_t system_instruction_time, 00041 const timestamp_t system_reference_time) { 00042 00043 // Bump up the observed system time, but not the virtual time, as 00044 // this is the beginning of a quanta, and time passed since the last 00045 // observed system time was due to some other task. 00046 last_system_cycle_time = system_cycle_time; 00047 last_system_instruction_time = system_instruction_time; 00048 last_system_reference_time = system_reference_time; 00049 00050 } // Task::mark_quanta_start 00051 // =================================================================== 00052 00053 00054 00055 // =================================================================== 00056 void 00057 Task::mark_time (const timestamp_t system_cycle_time, 00058 const timestamp_t system_instruction_time, 00059 const timestamp_t system_reference_time) { 00060 00061 // How much time has passed since the last call to this method? 00062 timestamp_t cycle_time_passed = 00063 system_cycle_time - last_system_cycle_time; 00064 timestamp_t instruction_time_passed = 00065 system_instruction_time - last_system_instruction_time; 00066 timestamp_t reference_time_passed = 00067 system_reference_time - last_system_reference_time; 00068 00069 // Update the virtual time that has passed for this task, as this 00070 // method is called only when this task is scheduled. 00071 virtual_cycle_time += cycle_time_passed; 00072 virtual_instruction_time += instruction_time_passed; 00073 virtual_reference_time += reference_time_passed; 00074 00075 // Bump up the observed system time. 00076 last_system_cycle_time = system_cycle_time; 00077 last_system_instruction_time = system_instruction_time; 00078 last_system_reference_time = system_reference_time; 00079 00080 } // Task::mark_time 00081 // ===================================================================