-
Notifications
You must be signed in to change notification settings - Fork 0
/
task_0.c
54 lines (39 loc) · 1.08 KB
/
task_0.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
51
52
#include <stdio.h>
#include <stdbool.h>
#include <time.h>
#include "zos.h"
#include "tasks.h"
extern volatile int sw1;
extern volatile int sw2;
extern volatile int sw3;
float time_from(float start) {
return ((float)clock()-start)/CLOCKS_PER_SEC;
}
ZOS_TASK_START(task_0)
//declare local variables:
static float start;
static float end;
static int i;
//end local variables, Task initialization:
ZOS_TASKINIT
//initialize local variables if needed:
start = (float)clock();
//end initialization
printf("Task0 - BLK0\n");
//block0
ZOS_WAITFOR(sw1)
//printf("tsk0 cond 1 satisfied -");
printf("Task0 - BLK1\n");
//block1
ZOS_WAITFOR(sw2)
//printf("tsk0 cond 2 satisfied -");
printf("Task0 - BLK2\n");
//block2
start = (float)clock();
ZOS_WAITFOR(time_from(start)>1)
printf("Task0: After wait\n");
printf("Task0: Clock: %f\n",time_from(start));
//printf("tsk0 cond 3 satisfied -");
printf("Task0 - BLK3\n");
//block3
ZOS_TASK_END