-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRM_DM_Scheduler.cpp
54 lines (43 loc) · 1.4 KB
/
RM_DM_Scheduler.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* RM_DM_Scheduler.cpp
*
* Created on: Mar 14, 2013
* Author: ashish
*/
#include<iostream>
#include<list>
#include "Scheduler.h"
#include "Config.h"
using namespace std;
int RM_DM_Scheduler::start_RM_Scheduler(void)
{
float utilization=calculateUtilization();
if(utilization == 0.0){cout<<"\n\nError: Utilization: "<<utilization<<"cannot continue..!"<<endl; return -1;}
if(utilization>0.68 && TaskList->size()>=4){cout<<"\n\nError: Utilization: "<<utilization<<" not schedulable by RM"<<endl;return -1;}
int startTime=0, endTime=calculateHyperperiod();
int currTime = startTime;
if(!endTime){cout<<"\n\nError: Hyperperiod: "<<endTime<<endl;return -1;}
cout<<"\n\nHyperperiod: "<<endTime<<endl;
TASK *taskToSchedule = NULL;
while(currTime<endTime)
{
updateReadyTasks(TaskList, currTime);
taskToSchedule = getRMHighestPriority(TaskList);
if(taskToSchedule->getTaskId() == 0)
cout<<"Time: "<<currTime<<" Tid: Slack "<<endl;
else
{
taskToSchedule->setCurrExecution(taskToSchedule->getCurrExecution()+1);
cout<<"Time: "<<currTime<<" Tid: "<<taskToSchedule->getTaskId()<<" Exe: "<<taskToSchedule->getCurrExecution()<<endl;
if(taskToSchedule->getCurrExecution()==taskToSchedule->getExecution())
{
taskToSchedule->setStatus(idle);
taskToSchedule->resetCurrExecution();
taskToSchedule = NULL;
}
checkDeadlineMiss(TaskList, currTime);
}
currTime++;
}
return 0;
}