Changeset 23329
- Timestamp:
- Mar 15, 2009, 11:13:18 AM (17 years ago)
- Location:
- trunk/Ohana/src/opihi/pantasks
- Files:
-
- 2 edited
-
CheckTasks.c (modified) (1 diff)
-
task_threads.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pantasks/CheckTasks.c
r15872 r23329 48 48 // add random offset between 0 and 5% of exec_period 49 49 // XXX this should be optional 50 fuzz = 0. 05*task[0].exec_period*drand48() + 1e-6*task[0].last.tv_usec;50 fuzz = 0.1*task[0].exec_period*drand48(); 51 51 task[0].last.tv_usec = 1e6*(fuzz - (int)fuzz); 52 52 task[0].last.tv_sec += (int) fuzz; -
trunk/Ohana/src/opihi/pantasks/task_threads.c
r15791 r23329 2 2 3 3 /** things related to CheckTasks **/ 4 void ResetTaskTimers (); 4 5 5 6 static int CheckTasksRun = FALSE; 6 7 7 8 void CheckTasksSetState (int state) { 9 if (state && !CheckTasksRun) { 10 ResetTaskTimers (); 11 } 8 12 CheckTasksRun = state; 9 13 } … … 51 55 // timeout. this enforces a certain granularity in the task creation, but prevents the task 52 56 // thread from driving the load up to silly levels. 57 58 // reset all of the task timers, with a bit of fuzz. this is called 59 // whenever we transition from 'stop' to 'run' 60 void ResetTaskTimers () { 61 62 Task *task; 63 struct timeval now; 64 float fuzz; 65 66 // get the current time 67 gettimeofday (&now, NULL); 68 69 // check all tasks 70 while ((task = NextTask ()) != NULL) { 71 task[0].last.tv_usec = now.tv_usec; 72 task[0].last.tv_sec = now.tv_sec; 73 74 // add random offset between 0 and 10% of exec_period 75 // XXX this should be optional 76 fuzz = 0.1*task[0].exec_period*drand48(); 77 task[0].last.tv_usec = 1e6*(fuzz - (int)fuzz); 78 task[0].last.tv_sec += (int) fuzz; 79 } 80 return; 81 }
Note:
See TracChangeset
for help on using the changeset viewer.
