Added a new scheduler interface function, which may be used
to control empty queue scheduling. SP scheduler uses this
to ensure that empty queues are not stored into scheduler
queues.

Signed-off-by: Petri Savolainen <[email protected]>
---
 platform/linux-generic/include/odp_schedule_if.h |  1 +
 platform/linux-generic/odp_queue.c               | 26 ++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/platform/linux-generic/include/odp_schedule_if.h 
b/platform/linux-generic/include/odp_schedule_if.h
index 0d82d84..86a117f 100644
--- a/platform/linux-generic/include/odp_schedule_if.h
+++ b/platform/linux-generic/include/odp_schedule_if.h
@@ -71,6 +71,7 @@ int sched_cb_queue_is_atomic(uint32_t queue_index);
 odp_queue_t sched_cb_queue_handle(uint32_t queue_index);
 void sched_cb_queue_destroy_finalize(uint32_t queue_index);
 int sched_cb_queue_deq_multi(uint32_t queue_index, odp_event_t ev[], int num);
+int sched_cb_queue_empty(uint32_t queue_index);
 
 /* API functions */
 typedef struct {
diff --git a/platform/linux-generic/odp_queue.c 
b/platform/linux-generic/odp_queue.c
index e11c912..f3e589e 100644
--- a/platform/linux-generic/odp_queue.c
+++ b/platform/linux-generic/odp_queue.c
@@ -745,3 +745,29 @@ int sched_cb_queue_deq_multi(uint32_t queue_index, 
odp_event_t ev[], int num)
 
        return ret;
 }
+
+int sched_cb_queue_empty(uint32_t queue_index)
+{
+       queue_entry_t *queue = get_qentry(queue_index);
+       int ret = 0;
+
+       LOCK(&queue->s.lock);
+
+       if (odp_unlikely(queue->s.status < QUEUE_STATUS_READY)) {
+               /* Bad queue, or queue has been destroyed. */
+               UNLOCK(&queue->s.lock);
+               return -1;
+       }
+
+       if (queue->s.head == NULL) {
+               /* Already empty queue. Update status. */
+               if (queue->s.status == QUEUE_STATUS_SCHED)
+                       queue->s.status = QUEUE_STATUS_NOTSCHED;
+
+               ret = 1;
+       }
+
+       UNLOCK(&queue->s.lock);
+
+       return ret;
+}
-- 
2.8.1

_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to