[Cbe-oss-dev] [PATCH 5/10] MARS: task queue push pop cleanup
Yuji Mano
Yuji.Mano at am.sony.com
Thu Aug 28 05:29:07 EST 2008
This moves some logic around in task queue push/pop routines in preparation for
next patch.
Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
---
src/host/lib/mars_task_queue.c | 50 ++++++++++++++++++++---------------------
src/mpu/lib/mars_task_queue.c | 50 ++++++++++++++++++++---------------------
2 files changed, 50 insertions(+), 50 deletions(-)
--- a/src/host/lib/mars_task_queue.c
+++ b/src/host/lib/mars_task_queue.c
@@ -114,11 +114,6 @@ int mars_task_queue_clear(struct mars_ta
mars_mutex_lock((struct mars_mutex *)queue);
- /* clear the queue count and push/pop ea */
- queue->count = 0;
- queue->push_ea = queue->buffer_ea;
- queue->pop_ea = queue->buffer_ea;
-
/* signal all waiting tasks that queue is ready for push */
for (i = 0; i < queue->push_wait_count; i++)
workload_queue_signal_send(
@@ -127,6 +122,11 @@ int mars_task_queue_clear(struct mars_ta
/* flush all ids from push wait list */
queue->push_wait_count = 0;
+ /* clear the queue count and push/pop ea */
+ queue->count = 0;
+ queue->push_ea = queue->buffer_ea;
+ queue->pop_ea = queue->buffer_ea;
+
mars_mutex_unlock((struct mars_mutex *)queue);
return MARS_SUCCESS;
@@ -137,16 +137,6 @@ static void push_update(struct mars_task
struct mars_context *mars =
(struct mars_context *)queue->mars_context_ea;
- /* increment queue count */
- queue->count++;
-
- /* increment queue push ea */
- queue->push_ea += queue->size;
-
- /* wrap to front of queue if necessary */
- if (queue->push_ea == queue->buffer_ea + (queue->size * queue->depth))
- queue->push_ea = queue->buffer_ea;
-
/* signal waiting task that queue is ready for pop */
if (queue->pop_wait_count) {
/* signal waiting task */
@@ -158,6 +148,16 @@ static void push_update(struct mars_task
memmove(&queue->pop_wait_id[0], &queue->pop_wait_id[1],
sizeof(uint16_t) * queue->pop_wait_count);
}
+
+ /* increment queue count */
+ queue->count++;
+
+ /* increment queue push ea */
+ queue->push_ea += queue->size;
+
+ /* wrap to front of queue if necessary */
+ if (queue->push_ea == queue->buffer_ea + (queue->size * queue->depth))
+ queue->push_ea = queue->buffer_ea;
}
static int push(struct mars_task_queue *queue, const void *data, int try)
@@ -210,16 +210,6 @@ static void pop_update(struct mars_task_
struct mars_context *mars =
(struct mars_context *)queue->mars_context_ea;
- /* decrement queue count */
- queue->count--;
-
- /* increment queue pop ea */
- queue->pop_ea += queue->size;
-
- /* wrap to front of queue if necessary */
- if (queue->pop_ea == queue->buffer_ea + (queue->size * queue->depth))
- queue->pop_ea = queue->buffer_ea;
-
/* signal waiting task that queue is ready for push */
if (queue->push_wait_count) {
/* signal waiting task */
@@ -231,6 +221,16 @@ static void pop_update(struct mars_task_
memmove(&queue->push_wait_id[0], &queue->push_wait_id[1],
sizeof(uint16_t) * queue->push_wait_count);
}
+
+ /* decrement queue count */
+ queue->count--;
+
+ /* increment queue pop ea */
+ queue->pop_ea += queue->size;
+
+ /* wrap to front of queue if necessary */
+ if (queue->pop_ea == queue->buffer_ea + (queue->size * queue->depth))
+ queue->pop_ea = queue->buffer_ea;
}
static int pop(struct mars_task_queue *queue, void *data, int peek, int try)
--- a/src/mpu/lib/mars_task_queue.c
+++ b/src/mpu/lib/mars_task_queue.c
@@ -113,11 +113,6 @@ int mars_task_queue_clear(uint64_t queue
mars_mutex_lock_get(queue_ea, (struct mars_mutex *)&queue);
- /* clear the queue count and push/pop ea */
- queue.count = 0;
- queue.push_ea = queue.buffer_ea;
- queue.pop_ea = queue.buffer_ea;
-
/* signal all waiting tasks that queue is ready for push */
for (i = 0; i < queue.push_wait_count; i++)
mars_signal_send(queue.push_wait_id[i]);
@@ -125,6 +120,11 @@ int mars_task_queue_clear(uint64_t queue
/* flush all ids from push wait list */
queue.push_wait_count = 0;
+ /* clear the queue count and push/pop ea */
+ queue.count = 0;
+ queue.push_ea = queue.buffer_ea;
+ queue.pop_ea = queue.buffer_ea;
+
mars_mutex_unlock_put(queue_ea, (struct mars_mutex *)&queue);
return MARS_SUCCESS;
@@ -132,16 +132,6 @@ int mars_task_queue_clear(uint64_t queue
static void push_update(void)
{
- /* increment queue count */
- queue.count++;
-
- /* increment queue push ea */
- queue.push_ea += queue.size;
-
- /* wrap to front of queue if necessary */
- if (queue.push_ea == queue.buffer_ea + (queue.size * queue.depth))
- queue.push_ea = queue.buffer_ea;
-
/* signal waiting task that queue is ready for pop */
if (queue.pop_wait_count) {
/* signal waiting task */
@@ -152,6 +142,16 @@ static void push_update(void)
memmove(&queue.pop_wait_id[0], &queue.pop_wait_id[1],
sizeof(uint16_t) * queue.pop_wait_count);
}
+
+ /* increment queue count */
+ queue.count++;
+
+ /* increment queue push ea */
+ queue.push_ea += queue.size;
+
+ /* wrap to front of queue if necessary */
+ if (queue.push_ea == queue.buffer_ea + (queue.size * queue.depth))
+ queue.push_ea = queue.buffer_ea;
}
static int push(uint64_t queue_ea, const void *data,
@@ -262,16 +262,6 @@ int mars_task_queue_try_push_begin(uint6
static void pop_update(void)
{
- /* decrement queue count */
- queue.count--;
-
- /* increment queue pop ea */
- queue.pop_ea += queue.size;
-
- /* wrap to front of queue if necessary */
- if (queue.pop_ea == queue.buffer_ea + (queue.size * queue.depth))
- queue.pop_ea = queue.buffer_ea;
-
/* signal waiting task that queue is ready for push */
if (queue.push_wait_count) {
/* signal waiting task */
@@ -282,6 +272,16 @@ static void pop_update(void)
memmove(&queue.push_wait_id[0], &queue.push_wait_id[1],
sizeof(uint16_t) * queue.push_wait_count);
}
+
+ /* decrement queue count */
+ queue.count--;
+
+ /* increment queue pop ea */
+ queue.pop_ea += queue.size;
+
+ /* wrap to front of queue if necessary */
+ if (queue.pop_ea == queue.buffer_ea + (queue.size * queue.depth))
+ queue.pop_ea = queue.buffer_ea;
}
static int pop(uint64_t queue_ea, void *data,
More information about the cbe-oss-dev
mailing list