#include #include #include #include #include struct release_heap* release_heap_alloc(int gfp_flags); void release_heap_free(struct release_heap* rh); int higher_res_prio(struct reservation* first, struct reservation* second) { struct reservation *first_task = first; struct reservation *second_task = second; /* There is no point in comparing a reservation to itself. */ if (first && first == second) { return 0; } /* check for NULL reservations */ if (!first || !second) return first && !second; #ifdef CONFIG_LITMUS_LOCKING // SOMEWHAT HACKY -- guarantee that a non-preemptive reservation // is higher-priority than any other; fall back to regular // priority-checking if both are non-preemptive or both are preemptive if (first->ops->is_np(first, -1) != second->ops->is_np(second, -1)) return first->ops->is_np(first, -1); /* Check for inherited priorities. Change reservation * used for comparison in such a case. */ if (unlikely(first->inh_res)) first_task = first->inh_res; if (unlikely(second->inh_res)) second_task = second->inh_res; #endif if (first_task->priority > second_task->priority) { return 1; } else if (first_task->priority == second_task->priority) { /* Tie break by pid */ if (first_task->id < second_task->id) { return 1; } #ifdef CONFIG_LITMUS_LOCKING else if (first_task->id == second_task->id) { /* If the PIDs are the same then the task with the * inherited priority wins. */ if (!second->inh_res) { return 1; } } #endif } return 0; /* fall-through. prio(second_task) > prio(first_task) */ } void init_ext_reservation( struct reservation* res, unsigned int id, struct reservation_ops* ops) { res->id = id; res->ops = ops; res->heap_node = bheap_node_alloc(GFP_ATOMIC); res->rel_heap = release_heap_alloc(GFP_ATOMIC); bheap_node_init(&res->heap_node, res); INIT_LIST_HEAD(&res->ln); INIT_LIST_HEAD(&res->all_list); } void clean_up_ext_reservation(struct reservation* res) { bheap_node_free(res->heap_node); release_heap_free(res->rel_heap); }