From 9d3af19d0e63d93eb291074d45085c121844d9ef Mon Sep 17 00:00:00 2001 From: Armin Luntzer <armin.luntzer@univie.ac.at> Date: Thu, 30 Mar 2017 18:01:42 +0200 Subject: [PATCH] data processing network: have pn_get_next_pending_tracker() rotate the queue --- lib/data_proc_net.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/lib/data_proc_net.c b/lib/data_proc_net.c index 12bc752..d93a067 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; } -- GitLab