diff options
| author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2007-09-18 12:23:43 -0400 |
|---|---|---|
| committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2007-09-18 12:23:43 -0400 |
| commit | 957ad72229186c5d21e44366f61d58a4dfa89bfe (patch) | |
| tree | 2284b3f2f4c1ed7c81ba0ccda720997fab4dab85 /include | |
| parent | 5760b6ad37c794a0dd5312206184d0b8ae8e8eda (diff) | |
Change liblitmus to have a more sane repository layout.
Diffstat (limited to 'include')
| -rw-r--r-- | include/edf-hsb.h | 10 | ||||
| -rw-r--r-- | include/litmus.h | 107 | ||||
| -rw-r--r-- | include/logformat.h | 112 |
3 files changed, 229 insertions, 0 deletions
diff --git a/include/edf-hsb.h b/include/edf-hsb.h new file mode 100644 index 0000000..0ac3d4f --- /dev/null +++ b/include/edf-hsb.h | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | #ifndef EDF_HSB_H | ||
| 2 | #define EDF_HSB_H | ||
| 3 | |||
| 4 | |||
| 5 | int set_hrt(int cpu, unsigned int wcet, unsigned int period); | ||
| 6 | int get_hrt(int cpu, unsigned int *wcet, unsigned int *period); | ||
| 7 | int create_be(unsigned int wcet, unsigned int period); | ||
| 8 | |||
| 9 | |||
| 10 | #endif | ||
diff --git a/include/litmus.h b/include/litmus.h new file mode 100644 index 0000000..88b0f0b --- /dev/null +++ b/include/litmus.h | |||
| @@ -0,0 +1,107 @@ | |||
| 1 | #ifndef LITMUS_H | ||
| 2 | #define LITMUS_H | ||
| 3 | |||
| 4 | #include <sys/types.h> | ||
| 5 | |||
| 6 | /* This flag is needed to start new RT tasks in STOPPED state */ | ||
| 7 | /* Task is going to run in realtime mode */ | ||
| 8 | #define CLONE_REALTIME 0x10000000 | ||
| 9 | |||
| 10 | typedef int (*rt_fn_t)(void*); | ||
| 11 | |||
| 12 | /* Litmus scheduling policies */ | ||
| 13 | typedef enum { | ||
| 14 | SCHED_LINUX = 0, | ||
| 15 | SCHED_PFAIR = 1, | ||
| 16 | SCHED_PFAIR_STAGGER = 2, | ||
| 17 | SCHED_PART_EDF = 3, | ||
| 18 | SCHED_PART_EEVDF = 4, | ||
| 19 | SCHED_GLOBAL_EDF = 5, | ||
| 20 | SCHED_PFAIR_DESYNC = 6, | ||
| 21 | SCHED_GLOBAL_EDF_NP = 7, | ||
| 22 | SCHED_CUSTOM = 8, | ||
| 23 | SCHED_EDF_HSB = 9, | ||
| 24 | SCHED_GSN_EDF = 10, | ||
| 25 | SCHED_PSN_EDF = 11 | ||
| 26 | } spolicy; | ||
| 27 | |||
| 28 | /* different types of clients */ | ||
| 29 | typedef enum { | ||
| 30 | RT_CLASS_HARD, | ||
| 31 | RT_CLASS_SOFT, | ||
| 32 | RT_CLASS_BEST_EFFORT | ||
| 33 | } task_class_t; | ||
| 34 | |||
| 35 | /* Task RT params for schedulers */ | ||
| 36 | /* RT task parameters for scheduling extensions | ||
| 37 | * These parameters are inherited during clone and therefore must | ||
| 38 | * be explicitly set up before the task set is launched. | ||
| 39 | */ | ||
| 40 | typedef struct rt_param { | ||
| 41 | /* Execution cost */ | ||
| 42 | unsigned long exec_cost; | ||
| 43 | /* Period */ | ||
| 44 | unsigned long period; | ||
| 45 | /* Partition */ | ||
| 46 | unsigned int cpu; | ||
| 47 | /* type of task */ | ||
| 48 | task_class_t cls; | ||
| 49 | } rt_param_t; | ||
| 50 | |||
| 51 | typedef int sema_id; /* ID of a semaphore in the Linux kernel */ | ||
| 52 | typedef int pi_sema_id; /* ID of a PI semaphore in the Linux kernel */ | ||
| 53 | typedef int srp_sema_id; /* ID of an SRP "semaphore" in the Linux kernel */ | ||
| 54 | |||
| 55 | typedef int pid_t; /* PID of a task */ | ||
| 56 | |||
| 57 | #define set_param(t,p,e) do{\ | ||
| 58 | (t).is_realtime=1;\ | ||
| 59 | (t).exec_cost=(e);\ | ||
| 60 | (t).period=(p);\ | ||
| 61 | }while(0); | ||
| 62 | |||
| 63 | /* scheduler modes */ | ||
| 64 | #define MODE_NON_RT 0 | ||
| 65 | #define MODE_RT_RUN 1 | ||
| 66 | |||
| 67 | spolicy sched_setpolicy(spolicy policy); | ||
| 68 | spolicy sched_getpolicy(void); | ||
| 69 | int set_rt_mode(int mode); | ||
| 70 | int set_rt_task_param(pid_t pid, rt_param_t* param); | ||
| 71 | int get_rt_task_param(pid_t pid, rt_param_t* param); | ||
| 72 | int prepare_rt_task(pid_t pid); | ||
| 73 | int tear_down_task(pid_t pid, int sig); | ||
| 74 | int reset_stat(void); | ||
| 75 | int sleep_next_period(void); | ||
| 76 | int scheduler_setup(int cmd, void* param); | ||
| 77 | int pi_sema_init(void); | ||
| 78 | int pi_down(pi_sema_id sem_id); | ||
| 79 | int pi_up(pi_sema_id sem_id); | ||
| 80 | int pi_sema_free(pi_sema_id sem_id); | ||
| 81 | int sema_init(void); | ||
| 82 | int down(sema_id sem_id); | ||
| 83 | int up(sema_id sem_id); | ||
| 84 | int sema_free(sema_id sem_id); | ||
| 85 | int srp_sema_init(void); | ||
| 86 | int srp_down(srp_sema_id sem_id); | ||
| 87 | int srp_up(srp_sema_id sem_id); | ||
| 88 | int reg_task_srp_sem(srp_sema_id sem_id, pid_t t_pid); | ||
| 89 | int srp_sema_free(srp_sema_id sem_id); | ||
| 90 | int get_job_no(unsigned int* job_no); | ||
| 91 | int wait_for_job_release(unsigned int job_no); | ||
| 92 | |||
| 93 | /* library functions */ | ||
| 94 | void init_litmus(void); | ||
| 95 | |||
| 96 | int create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, int period); | ||
| 97 | int __create_rt_task(rt_fn_t rt_prog, void *arg, int cpu, int wcet, | ||
| 98 | int period, task_class_t cls); | ||
| 99 | const char* get_scheduler_name(spolicy scheduler); | ||
| 100 | void show_rt_param(rt_param_t* tp); | ||
| 101 | task_class_t str2class(const char* str); | ||
| 102 | |||
| 103 | void enter_np(void); | ||
| 104 | void exit_np(void); | ||
| 105 | |||
| 106 | |||
| 107 | #endif | ||
diff --git a/include/logformat.h b/include/logformat.h new file mode 100644 index 0000000..3a74bf7 --- /dev/null +++ b/include/logformat.h | |||
| @@ -0,0 +1,112 @@ | |||
| 1 | #ifndef LOGFORMAT_H | ||
| 2 | #define LOGFORMAT_H | ||
| 3 | |||
| 4 | #include <linux/types.h> | ||
| 5 | |||
| 6 | #include "litmus.h" | ||
| 7 | |||
| 8 | typedef __u8 u8; | ||
| 9 | typedef __u32 u32; | ||
| 10 | typedef __u16 u16; | ||
| 11 | |||
| 12 | typedef enum { | ||
| 13 | ST_INVOCATION = 0, | ||
| 14 | ST_ARRIVAL = 1, | ||
| 15 | ST_DEPARTURE = 2, | ||
| 16 | ST_PREEMPTION = 3, | ||
| 17 | ST_SCHEDULED = 4, | ||
| 18 | ST_JOB_RELEASE = 5, | ||
| 19 | ST_JOB_COMPLETION = 6, | ||
| 20 | ST_CAPACITY_RELEASE = 7, | ||
| 21 | ST_CAPACITY_ALLOCATION = 8, | ||
| 22 | ST_LAST_TYPE = 8 | ||
| 23 | } trace_type_t; | ||
| 24 | |||
| 25 | typedef struct { | ||
| 26 | trace_type_t trace:8; | ||
| 27 | unsigned long long timestamp; | ||
| 28 | } trace_header_t; | ||
| 29 | |||
| 30 | |||
| 31 | typedef struct { | ||
| 32 | unsigned int is_rt:1; | ||
| 33 | unsigned int is_server:1; | ||
| 34 | task_class_t cls:4; | ||
| 35 | unsigned int budget:24; | ||
| 36 | u32 deadline; | ||
| 37 | |||
| 38 | pid_t pid; | ||
| 39 | } task_info_t; | ||
| 40 | |||
| 41 | typedef struct { | ||
| 42 | trace_header_t header; | ||
| 43 | unsigned long flags; | ||
| 44 | } invocation_record_t; | ||
| 45 | |||
| 46 | typedef struct { | ||
| 47 | trace_header_t header; | ||
| 48 | task_info_t task; | ||
| 49 | } arrival_record_t; | ||
| 50 | |||
| 51 | typedef struct { | ||
| 52 | trace_header_t header; | ||
| 53 | task_info_t task; | ||
| 54 | } departure_record_t; | ||
| 55 | |||
| 56 | typedef struct { | ||
| 57 | trace_header_t header; | ||
| 58 | task_info_t task; | ||
| 59 | task_info_t by; | ||
| 60 | } preemption_record_t; | ||
| 61 | |||
| 62 | typedef struct { | ||
| 63 | trace_header_t header; | ||
| 64 | task_info_t task; | ||
| 65 | } scheduled_record_t; | ||
| 66 | |||
| 67 | typedef struct { | ||
| 68 | trace_header_t header; | ||
| 69 | task_info_t task; | ||
| 70 | u16 period; | ||
| 71 | u16 wcet; | ||
| 72 | } release_record_t; | ||
| 73 | |||
| 74 | typedef struct { | ||
| 75 | trace_header_t header; | ||
| 76 | task_info_t task; | ||
| 77 | u16 period; | ||
| 78 | u16 wcet; | ||
| 79 | int tardiness; | ||
| 80 | } completion_record_t; | ||
| 81 | |||
| 82 | typedef struct { | ||
| 83 | trace_header_t header; | ||
| 84 | task_info_t task; | ||
| 85 | } cap_release_record_t; | ||
| 86 | |||
| 87 | typedef struct { | ||
| 88 | trace_header_t header; | ||
| 89 | task_info_t task; | ||
| 90 | u16 budget; | ||
| 91 | u32 deadline; | ||
| 92 | pid_t donor; | ||
| 93 | } cap_allocation_record_t; | ||
| 94 | |||
| 95 | |||
| 96 | typedef union { | ||
| 97 | trace_header_t header; | ||
| 98 | invocation_record_t invocation; | ||
| 99 | arrival_record_t | ||
