/* * ResponseTimeAnalysis.cpp * * Created on: 07.11.2010 * Author: sven */ #include "ResponseTimeAnalysis.h" #ifndef GLOBAL_H_ #include "Global.h" #endif #include #include #include ResponseTimeAnalysis::ResponseTimeAnalysis() { // TODO Auto-generated constructor stub } ResponseTimeAnalysis::~ResponseTimeAnalysis() { // TODO Auto-generated destructor stub } bool ResponseTimeAnalysis::analyse(rms_queue& task_queue) { bool res = true; unsigned int task_count = 0; vector task_set(task_queue.size()); while(!task_queue.empty()) { Task* t = task_queue.top(); task_set[task_count++] = t; task_queue.pop(); } unsigned int c = 0; for(c=0;c higherPriorizedTasks(c); for(unsigned int j=0;jgetName() << " has " << higherPriorizedTasks.size() << " higher priorized tasks: "; for(unsigned int j=0;jgetName(); } cout << endl; unsigned int ri = t->getOrigC(); if (c == 0) { cout << "Response Time of Task " << t->getName() << " is " << ri << endl; continue; } do { unsigned int rii = t->getOrigC(); for(unsigned int j=0;j(ri)/static_cast(h->getOrigP())); double r = a*h->getOrigC(); // cout << "(Ri)/Tj*Cj = (" << ri << "/" << h->getOrigP() << ")*"<< h->getOrigC() << " = " << r << endl; rii += r; } // cout << "Ri = " << rii << endl; if(rii == ri) { break; } ri = rii; } while (1); cout << "Response Time of Task " << t->getName() << " is " << ri << endl; if (ri > static_cast(t->getOrigD()) ) { cout << "Response time of Task "<< t->getName() << " exceeds D:" << ri << ">" << t->getOrigD() << endl; res = false; break; } } return res; } void ResponseTimeAnalysis::calcOptimalStaticPriorities(task_set& tasks) { unsigned int N = tasks.size(); vector prios(N); for(unsigned int p=0;pgetName() << " with prio " << actPrio << endl; // find tasks with higher priority vector higherPrioTasks; unsigned int higherPrioTasksCounter = 0; for(unsigned int taskPrio=actPrio+1;taskPriogetName() << " to tasks with higher prio" <getOrigC(); if(higherPrioTasksCounter > 0) { do { int rii = candidate->getOrigC(); for(unsigned int k=0;k(ri)/static_cast(t->getOrigP())); double r = a*t->getOrigC(); rii += r; } if(rii == ri) { break; } ri = rii; } while(1); } // check response time OK = (ri <= candidate->getOrigD()); cout << "Response Time of Task " << candidate->getName() << " is " << ri << " with prio " << actPrio << endl; if(OK) { cout << "Task "<< candidate->getName() << " runs at prio " << actPrio << endl << endl; break; } else { cout << "Task "<< candidate->getName() << " cannot run at prio " << actPrio << endl; } } // inner for loop if(!OK) { cout << "Not schedulable! No task to run at prio " << actPrio << endl; break; } }// outer for loop if(OK) { cout << "Optimal priorities:" << endl; for(unsigned int c=0;cgetName() << endl; } } } } void ResponseTimeAnalysis::swap(vector& prios,int a,int b) { Task *taskA = prios[a]; Task *taskB = prios[b]; cout << "Swapping " << taskA->getName() << " ("<getName() << " (" <