00001
00016 #ifndef __RRES_INTERFACE_H__
00017 #define __RRES_INTERFACE_H__
00018
00019 #include "rres_config.h"
00020 #include "qos_types.h"
00021 #include "kal_sched.h"
00022 #include "rres_ready_queue.h"
00023
00026 #if defined(CONFIG_OC_RRES_HRT) || LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,0)
00027 # define MIN_SRV_PERIOD 1000LU
00028 # define MIN_SRV_MAX_BUDGET 0LU
00029 #else
00030 # define MIN_SRV_PERIOD 20000LU
00031 # define MIN_SRV_MAX_BUDGET 0LU
00032 #endif
00033
00034 #define MIN_SRV_PERIOD_DEBUG 200000LU
00036 static inline struct task_list *rres_find_task_list(kal_task_t *task) {
00037 return (struct task_list *) kal_task_get_data(task);
00038 }
00039
00041 static inline server_t * rres_find_by_task(kal_task_t *task) {
00042 struct task_list *tl = rres_find_task_list(task);
00043 if (tl != NULL)
00044 return tl->srv;
00045 else
00046 return NULL;
00047 }
00048
00050 int rres_init_module(void);
00051
00053 void rres_cleanup_module(void);
00054
00061 qos_rv rres_create_server(server_t ** new_srv, qres_time_t max_budget, qres_time_t period, unsigned long flags);
00062
00064 qos_rv rres_init_server(server_t * new_srv, qres_time_t max_budget, qres_time_t period, unsigned long flags);
00065
00067 qos_rv rres_attach_task(server_t *srv, struct task_struct *task);
00068
00072 qos_rv rres_detach_task(server_t *srv, struct task_struct *task);
00073
00080 qos_rv rres_destroy_server(server_t *rres);
00081
00091 qos_rv rres_cleanup_server(server_t *rres);
00092
00099 qos_rv rres_check_destroy(server_t *srv);
00100
00105 server_t* rres_find_by_id(qres_sid_t sid);
00106
00108 qres_sid_t rres_get_sid(server_t *rres);
00109
00111 qos_rv rres_set_params(server_t *rres, qres_time_t budget, qres_time_t period);
00112
00114 qos_rv rres_get_params(server_t *rres, qres_time_t *budget, qres_time_t *period);
00115
00117 qos_rv rres_set_budget(server_t *rres, qres_time_t budget);
00118
00120 static inline qres_time_t rres_get_curr_budget(server_t *srv) {
00121 return kal_time2usec(srv->c);
00122 }
00123
00125 qres_time_t rres_get_period(server_t *rres);
00126
00128 static inline qos_rv rres_get_deadline(server_t *rres, struct timespec *p_deadline) {
00129 *p_deadline = kal_time2timespec(rres->deadline);
00130 return QOS_OK;
00131 }
00132
00134 static inline unsigned long rres_get_flags(server_t *rres) {
00135 return rres->flags;
00136 }
00137
00139 qres_time_t rres_get_exec_time(server_t *rres);
00140
00141
00142
00143
00146 server_t * rres_get_default_server(void);
00147
00155 qos_rv rres_init_default_server(server_t * srv, qres_time_t Q, qres_time_t P, unsigned long flags);
00156
00158 int rres_has_server(struct task_struct *t);
00159
00161 int rres_empty(server_t *srv);
00162
00164 int rres_empty(server_t *srv);
00165
00167 int rres_running(server_t *srv);
00168
00170 static inline struct task_struct *rres_any_ready_task(server_t * srv) {
00171 struct task_list *tl;
00172 if (RRES_PARANOID)
00173 qos_chk_do(srv != NULL && qos_mem_valid(srv), return NULL);
00174 if (list_empty(&srv->ready_tasks))
00175 return NULL;
00176 tl = list_entry(srv->ready_tasks.next, struct task_list, node);
00177 return tl->task;
00178 }
00179
00181 static inline struct task_struct *rres_any_blocked_task(server_t * srv) {
00182 struct task_list *tl;
00183 if (RRES_PARANOID)
00184 qos_chk_do(srv != NULL && qos_mem_valid(srv), return NULL);
00185 if (list_empty(&srv->blocked_tasks))
00186 return NULL;
00187 tl = list_entry(srv->blocked_tasks.next, struct task_list, node);
00188 return tl->task;
00189 }
00190
00191 extern spinlock_t rres_lock;
00192
00193 static inline kal_lock_t *rres_get_spinlock(void) {
00194 return &rres_lock;
00195 }
00196
00197 #endif
00198