void TaskGraph::init(set<Task*> &initialized) { if (initialized.find(this) == initialized.end()) { initialized.insert(this); TaskIterator i = getAllTasks(); initTasks(i, initialized); } }
/* * Initializes a set of tasks. In order to support the modification of a task * graph during the initialization of its sub tasks, this method is recursive * and initializes the tasks after all the iterator elements have been found. * Without this the iterator over the sub tasks could become invalid if the set * of sub tasks is modified during the iteration (by the init method of one of * the sub tasks). */ void initTasks(TaskGraph::TaskIterator &i, set<Task*> &initialized) { if (i.hasNext()) { ptr<Task> t = i.next(); initTasks(i, initialized); t->init(initialized); } }
int main() { /* Initialize the task library */ initTasks(); /* Spawn Tasks */ /* WCET, period, deadline, phase= 0 */ spawnTask (&task0, 4000,800, 7,0); spawnTask (&task1, 4000,750, 21,0); spawnTask (&task2, 4000,1600,5,0); spawnTask (&task3, 4000,1000,25,0); spawnTask (&task4, 4000,600,16,0); spawnTask (&task5, 4000,1200,10,0); spawnTask (&task6, 3900,1100,27,0); spawnTask (&task7, 4000,1600,20,0); spawnTask (&idletask, 0,0,0,0); /* start scheduling and running the tasks */ Start(); return 0; }
//============================================================================== // Exported functions //============================================================================== void initApp(void) { initTasks(); }