00001
00010 #ifndef __RRES_H__
00011 #define __RRES_H__
00012
00013 #include "rres_config.h"
00014 #include "rres_interface.h"
00015
00016 #include "qos_types.h"
00017 #include "qos_memory.h"
00018 #include "qos_list.h"
00019
00020 #include <linux/aquosa/kal_generic.h>
00021 #include <linux/aquosa/rres_time.h>
00022
00023 struct kal_timer_t;
00024
00025 extern spinlock_t generic_scheduler_lock __cacheline_aligned;
00026 extern struct list_head server_list;
00027 extern kal_time_t last_update_time;
00028 #ifdef CONFIG_RRES_DEFAULT_SRV
00029 extern server_t *default_srv;
00030 #endif
00031
00033 qos_rv rres_init(void);
00034
00036 qos_rv rres_cleanup(void);
00037
00039 qos_rv rres_cleanup_default_server_nosched(server_t *srv);
00040
00041
00042 qos_rv rres_detach_task_nosched(server_t *srv, struct task_struct *task);
00043
00045 qos_rv rres_move_nosched(server_t * new_srv, struct task_struct *task);
00046
00049
00050
00054
00055
00061 void rres_schedule(void);
00062
00064
00065 void recharge(server_t *srv);
00066
00068 void recharge_reset_from_now(server_t *srv);
00069
00070 qos_rv rres_on_task_block(struct task_struct *task);
00071
00072 qos_rv rres_on_task_unblock(struct task_struct *task);
00073
00081 #define for_each_srv(srv, head, list_field, pos) \
00082 for ((pos) = (head)->next, prefetch((pos)->next); \
00083 (srv) = (list_entry((pos), server_t, list_field)), (pos) != (head); \
00084 (pos) = (pos)->next, prefetch((pos)->next))
00085
00094 #define for_each_srv_safe(srv, head, list_field, pos, postmp) \
00095 for (pos = (head)->next, postmp = pos->next; \
00096 (srv) = (list_entry((pos), server_t, list_field)), pos != (head); \
00097 pos = postmp, postmp = pos->next)
00098
00103 #define for_each_server(srv, pos) for_each_srv((srv), &server_list, slist, (pos))
00104
00110 #define for_each_server_safe(srv, pos, tmppos) for_each_srv_safe((srv), &server_list, slist, (pos), (tmppos))
00111
00113 #define get_task_entry(h) list_entry((h), struct task_list, others)
00114
00122 #define for_each_ready_task_in_server(__srv, t, pos) \
00123 for ((pos) = (__srv)->ready_tasks.next, prefetch((pos)->next); \
00124 (t) = (list_entry((pos), struct task_list, node))->task, (pos) != &((__srv)->ready_tasks); \
00125 (pos) = (pos)->next, prefetch((pos)->next))
00126
00127 #define for_each_blocked_task_in_server(__srv, t, pos) \
00128 for ((pos) = (__srv)->blocked_tasks.next, prefetch((pos)->next); \
00129 (t) = (list_entry((pos), struct task_list, node))->task, (pos) != &((__srv)->blocked_tasks); \
00130 (pos) = (pos)->next, prefetch((pos)->next))
00131
00140 #define for_each_ready_task_in_server_safe(__srv, t, __pos, __tmp) \
00141 for ((__pos) = (__srv)->ready_tasks.next, __tmp = (__pos)->next; \
00142 (t) = (list_entry((__pos), struct task_list, node))->task, (__pos) != &((__srv)->ready_tasks); \
00143 (__pos) = (__tmp), __tmp = (__pos)->next)
00144
00145 #define for_each_blocked_task_in_server_safe(__srv, t, __pos, __tmp) \
00146 for ((__pos) = (__srv)->blocked_tasks.next, __tmp = (__pos)->next; \
00147 (t) = (list_entry((__pos), struct task_list, node))->task, (__pos) != &((__srv)->blocked_tasks); \
00148 (__pos) = (__tmp), __tmp = (__pos)->next)
00149
00151 static inline qos_bool_t is_in_default_server(struct task_struct *t) {
00152 #if defined (CONFIG_RRES_DEFAULT_SRV)
00153 return rres_find_by_task(t) == default_srv;
00154 #else
00155 return 0;
00156 #endif
00157 }
00158
00160 static inline qos_bool_t is_default_server(server_t * srv) {
00161 #if defined (CONFIG_RRES_DEFAULT_SRV)
00162 return (srv == default_srv);
00163 #else
00164 return 0;
00165 #endif
00166 }
00167
00168
00169
00171 void rres_stop(server_t * srv);
00172
00174 void rres_dispatch(server_t *srv);
00175
00176 void stop_task_safe(server_t *srv, struct task_struct *task);
00177
00178 void dispatch_task_safe(server_t *srv, struct task_struct *task);
00179
00182 #endif