-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask.h
executable file
·66 lines (41 loc) · 1.72 KB
/
task.h
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
/* Header File for RTS project */
/* --- Include guard --- */
#ifndef TASK_H_INCLUDED_
#define TASK_H_INCLUDED_
/* --- Standard Libraries --- */
#include <stdio.h>
#include <pthread.h>
#include <semaphore.h>
#include <time.h>
#include <string.h>
/* --- Definitions --- */
#define THREAD_MAX_NUM 6
/* --- Project functions --- */
struct task_par {
int arg; /* task argument */
long wcet; /* in microseconds */
int period; /* in milliseconds */
int deadline; /* relative (ms) */
int priority; /* in [0,99] */
int dmiss; /* n. of deadline misses */
struct timespec at; /* next activation time */
struct timespec dl; /* absolute deadline */
};
/* Task Management */
void set_task_params(struct task_par *tp, int arg, int per, int dl, int prio);
void set_period (struct task_par *tp);
void wait_for_period (struct task_par *tp);
void time_add_ms (struct timespec *t, int ms);
int time_cmp (struct timespec t1, struct timespec t2);
void eval_period(struct task_par *tp, int* arr_tp, int* sel_t, int t_idx, int *change_flag);
void time_copy (struct timespec *td, struct timespec ts);
int deadline_miss (struct task_par *tp);
void select_thread_tp(int* sel_t, int* tp_arr, int* sel_t_old_tp, int t_idx);
void cancel_thread_tp(int* sel_t, int* tp_arr, int* sel_t_old_tp);
void modify_thread_tp(int* sel_t, int* tp_arr, int val);
int thread_create (struct task_par *tp, struct sched_param *sp, pthread_attr_t att, pthread_t *tid, void* task);
int mutex_create (pthread_mutex_t mux, pthread_mutexattr_t matt, int prot, int ceiling);
/* Utilities */
void shift_and_append (double *array, int size, double new_element);
void write_to_file (const char* filename, const char* text, int toappend);
#endif /* TASK_H_INCLUDED_ */