-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpseudocode
88 lines (76 loc) · 1.66 KB
/
pseudocode
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
Real-Time Operating Systems
4 threads managed with Semaphores (Priority Ceiling Policy)
PSEUDO-CODE by Simone Contorno
FUNCTION main
SET threads priority (lower period, higher priority)
COMPUTE WCET for each task
COMPUTE Blocking Time for each task
COMPUTE U and Ulub
CHECK schedulability
SET attributes of each task
SET Priority Ceiling to the Semaphores
COMPUTE next arrival time of each task
CREATE threads
WAIT for all threads
PRINT missed deadlines for each thread
END
FUNCTION task1_1
WRITE into T1T2
END
FUNCTION task1_2
WRITE into T1T4
END
FUNCTION thread1
FOR number of executions
LOCK mutex1
CALL task1_1
UNLOCK mutex1
LOCK mutex2
CALL task1_2
UNLOCK mutex2
SLEEP until the next arrival time
COMPUTE next arrival time
ENDFOR
END
FUNCTION task2_1
READ from T1T2
END
FUNCTION task2_2
WRITE into T2T3
END
FUNCTION thread2
FOR number of executions
LOCK mutex3
CALL task2_2
UNLOCK mutex3
LOCK mutex1
CALL task2_1
UNLOCK mutex1
SLEEP until the next arrival time
COMPUTE next arrival time
ENDFOR
END
FUNCTION task3
READ from T2T3
END
FUNCTION thread3
FOR number of executions
LOCK mutex3
CALL task3
UNLOCK mutex3
SLEEP until the next arrival time
COMPUTE next arrival time
ENDFOR
END
FUNCTION task4
READ from T1T4
END
FUNCTION thread4
FOR number of executions
LOCK mutex2
CALL task4
UNLOCK mutex2
SLEEP until the next arrival time
COMPUTE next arrival time
ENDFOR
END