00001
00008 #ifndef __RRES_READY_QUEUE_LIST_H__
00009 #define __RRES_READY_QUEUE_LIST_H__
00010
00011 #include "rres_config.h"
00012 #include "kal_timer.h"
00013 #include "qos_types.h"
00014 #include "qos_func.h"
00015
00016 #include "qos_list.h"
00017
00022 typedef struct list_head rq_placeholder_t;
00023
00024 #include "rres_server.h"
00025
00027 extern struct list_head ready_queue;
00028
00030 #define rq_placeholder_init(p_list_head) INIT_LIST_HEAD_NULL(p_list_head)
00031
00033 static inline server_t *get_highest_priority_server(void) {
00034 if (list_empty(&ready_queue))
00035 return NULL;
00036 else
00037 return list_entry(ready_queue.next, server_t, rq_ph);
00038 }
00039
00044 #define for_each_ready_server(srv, pos) \
00045 for_each_srv((srv), &ready_queue, rq_ph, (pos))
00046
00048 static inline int ready_queue_empty(void) {
00049 return list_empty(&ready_queue);
00050 }
00051
00053 static inline int srv_alone(server_t *srv) {
00054 return (((srv)->rq_ph.prev == &ready_queue) && ((srv)->rq_ph.next == &ready_queue));
00055 }
00056
00058 static inline int in_ready_queue(server_t *srv) {
00059 return ((srv)->rq_ph.next != NULL);
00060 }
00061
00063 static qos_func_define(void, ready_queue_remove, server_t *srv)
00064 {
00065 qos_log_debug("(s:%d): Removing from ready queue", srv->id);
00066
00067 qos_chk_do(in_ready_queue(srv), return, "Attempt to remove (s:%d) from ready queue while it is not in rq. IGNORED", srv->id);
00068
00069 list_del_null(&srv->rq_ph);
00070 }
00071
00072 static inline qos_rv rres_edf_init(void) {
00073 INIT_LIST_HEAD(&ready_queue);
00074 return QOS_OK;
00075 }
00076
00077 static inline void rres_edf_cleanup(void) {
00078
00079 qos_chk(list_empty(&ready_queue));
00080 }
00081
00083 static qos_func_define(qos_rv, ready_queue_add, server_t *srv) {
00084 int ret;
00085
00086 qos_log_debug("%d", srv->id);
00087
00088 if (in_ready_queue(srv)) {
00089
00090
00091
00092 qos_log_crit("%d is already in ready queue", srv->id);
00093 DUMP_STACK;
00094 ready_queue_remove(srv);
00095 }
00096 list_add_ordered(ready_queue, server_t, srv, rq_ph, deadline, ret);
00097 return QOS_OK;
00098 }
00099
00100 #endif
00101