diff --git a/lib/data_proc_net.c b/lib/data_proc_net.c index 12bc752e799fe671c0730640e3465856614d39f9..d93a067d52ce9d7de28fac28871c17467f26b984 100644 --- a/lib/data_proc_net.c +++ b/lib/data_proc_net.c @@ -219,17 +219,14 @@ void pn_queue_critical_trackers(struct proc_net *pn) /** - * @brief locate the first tracker that holds at least one task + * @brief locate the next tracker that holds at least one task * * @param pn a struct proc_net * * @return a pointer to a struct proc_task or NULL if none was found * - * @note empty trackers are moved to the end of the queue - * - * ideally, the tracker nodes would already be sorted so that the most critical - * tracker was the first item - * XXX implement that sometime... + * @note trackers are always moved to the end of the queue, critical trackers + * have priority */ struct proc_tracker *pn_get_next_pending_tracker(struct proc_net *pn) @@ -244,16 +241,17 @@ struct proc_tracker *pn_get_next_pending_tracker(struct proc_net *pn) if (list_empty(&pn->nodes)) return NULL; + pn_queue_critical_trackers(pn); list_for_each_entry_safe(pt, p_tmp, &pn->nodes, node) { if (cnt++ > pn->n) break; + pn_node_to_queue_tail(pn, pt); + if (pt_track_tasks_pending(pt)) return pt; - - pn_node_to_queue_tail(pn, pt); } return NULL; @@ -362,9 +360,6 @@ int pn_process_next(struct proc_net *pn) struct proc_tracker *pt; - /* make sure critical trackers are on top */ - pn_queue_critical_trackers(pn); - pt = pn_get_next_pending_tracker(pn); if (!pt) return cnt; @@ -382,10 +377,6 @@ int pn_process_next(struct proc_net *pn) break; } - - /* move processing task to end of queue */ - pn_node_to_queue_tail(pn, pt); - return cnt; }