-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateTaskInstances.c
50 lines (43 loc) · 1.29 KB
/
createTaskInstances.c
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
/*
* Author: Akhil Tarikere
* Date: 9/3/20
*
* Pre-Condition: Given a set of tasks
*
*
* Post-Condition: Creates and initialises the various jobs of that task that will be created for that hyperperiod.
*
*/
#include <stdio.h>
#include <stdbool.h>
#include "functionPeriodic.h"
/*
* Fills in the details of the array of various instances of the tasks based on the task details.
* Also, takes care of the tasks that have been split.
*/
void
createTaskInstances(Task *tasks, TaskInstance *jobs, int frameSize, int hyperperiod, int numTasks, int numJobs)
{
int jobIndex = 0;
for (int i = 0; i < numTasks; ++i) // Iterates over tasks.
{
tasks[i].numInstances = hyperperiod / tasks[i].period;
for (float j = 0; j < hyperperiod; j += tasks[i].period) // Iterates over the period of a task.
{
// Calculating the startFrame and maxFrame.
int startFrame = (int)j / frameSize;
int maxFrame = (int)(j + tasks[i].deadline) / frameSize;
if ((int)j % frameSize != 0)
startFrame++;
jobs[jobIndex].startFrame = startFrame;
jobs[jobIndex].maxFrame = maxFrame;
jobs[jobIndex].taskNum = i;
jobs[jobIndex].splitNum = -1;
jobs[jobIndex].wcet = tasks[i].wcet;
jobs[jobIndex].instanceNum = j / tasks[i].period;
jobs[jobIndex].alive = true;
jobIndex++;
}
}
return;
}