[Cbe-oss-dev] [PATCH 9/10] MARS: workload signal use defines

Yuji Mano Yuji.Mano at am.sony.com
Wed Aug 6 04:54:51 EST 2008


Use defined macro instead of magic number when initializing workload signals.

Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>

---
 include/common/mars/mars_workload_types.h |    3 +++
 src/host/lib/mars_workload_queue.c        |    8 ++++----
 src/mpu/kernel/mars_kernel_scheduler.c    |    5 +++--
 src/mpu/kernel/mars_kernel_workload.c     |    6 +++---
 4 files changed, 13 insertions(+), 9 deletions(-)

--- a/include/common/mars/mars_workload_types.h
+++ b/include/common/mars/mars_workload_types.h
@@ -62,6 +62,9 @@ extern "C" {
 #define MARS_WORKLOAD_COUNTER_MIN		0x0000	/* minimum counter */
 #define MARS_WORKLOAD_COUNTER_MAX		0xffff	/* maximum counter */
 
+#define MARS_WORKLOAD_SIGNAL_ON			1	/* signal set on */
+#define MARS_WORKLOAD_SIGNAL_OFF		0	/* signal set off */
+
 #define MARS_WORKLOAD_MAX			1024	/* wl max */
 #define MARS_WORKLOAD_PER_BLOCK			16	/* wl per block */
 #define MARS_WORKLOAD_NUM_BLOCKS		64	/* wl max / per block */
--- a/src/host/lib/mars_workload_queue.c
+++ b/src/host/lib/mars_workload_queue.c
@@ -111,7 +111,7 @@ int workload_queue_add(struct mars_workl
 	queue->block[block].state[index] = MARS_WORKLOAD_STATE_FINISHED;
 	queue->block[block].priority[index] = MARS_WORKLOAD_PRIORITY_MIN;
 	queue->block[block].counter[index] = MARS_WORKLOAD_COUNTER_MIN;
-	queue->block[block].signal[index] = 0;
+	queue->block[block].signal[index] = MARS_WORKLOAD_SIGNAL_OFF;
 	queue->block[block].wait[index] = MARS_WORKLOAD_ID_NONE;
 	queue->header.count++;
 
@@ -139,7 +139,7 @@ int workload_queue_remove(struct mars_wo
 	queue->block[block].state[index] = MARS_WORKLOAD_STATE_NONE;
 	queue->block[block].priority[index] = MARS_WORKLOAD_PRIORITY_MIN;
 	queue->block[block].counter[index] = MARS_WORKLOAD_COUNTER_MIN;
-	queue->block[block].signal[index] = 0;
+	queue->block[block].signal[index] = MARS_WORKLOAD_SIGNAL_OFF;
 	queue->block[block].wait[index] = MARS_WORKLOAD_ID_NONE;
 	queue->header.count--;
 
@@ -179,7 +179,7 @@ int workload_queue_schedule(struct mars_
 	queue->block[block].state[index] = MARS_WORKLOAD_STATE_READY;
 	queue->block[block].priority[index] = priority;
 	queue->block[block].counter[index] = MARS_WORKLOAD_COUNTER_MIN;
-	queue->block[block].signal[index] = 0;
+	queue->block[block].signal[index] = MARS_WORKLOAD_SIGNAL_OFF;
 	queue->block[block].wait[index] = MARS_WORKLOAD_ID_NONE;
 
 	return MARS_SUCCESS;
@@ -230,7 +230,7 @@ int workload_queue_signal_send(struct ma
 	MARS_CHECK_RET(queue->block[block].state[index] !=
 			MARS_WORKLOAD_STATE_NONE, MARS_ERROR_STATE);
 
-	queue->block[block].signal[index] = 1;
+	queue->block[block].signal[index] = MARS_WORKLOAD_SIGNAL_ON;
 
 	return MARS_SUCCESS;
 }
--- a/src/mpu/kernel/mars_kernel_scheduler.c
+++ b/src/mpu/kernel/mars_kernel_scheduler.c
@@ -95,8 +95,9 @@ static int search_block(struct mars_work
 					block->state[i] =
 						MARS_WORKLOAD_STATE_READY;
 				}
-			} else if (block->signal[i]) {
-				block->signal[i] = 0;
+			} else if (block->signal[i] ==
+				MARS_WORKLOAD_SIGNAL_ON) {
+				block->signal[i] = MARS_WORKLOAD_SIGNAL_OFF;
 				block->state[i] = MARS_WORKLOAD_STATE_READY;
 				i--;
 			}
--- a/src/mpu/kernel/mars_kernel_workload.c
+++ b/src/mpu/kernel/mars_kernel_workload.c
@@ -174,7 +174,7 @@ int workload_schedule(uint16_t workload_
 		queue_block.state[index] = MARS_WORKLOAD_STATE_READY;
 		queue_block.priority[index] = priority;
 		queue_block.counter[index] = MARS_WORKLOAD_COUNTER_MIN;
-		queue_block.signal[index] = 0;
+		queue_block.signal[index] = MARS_WORKLOAD_SIGNAL_OFF;
 		queue_block.wait[index] = MARS_WORKLOAD_ID_NONE;
 
 		/* attempt to write back workload queue block to cache line */
@@ -284,7 +284,7 @@ int workload_signal_send(uint16_t worklo
 		}
 
 		/* set the workload signal */
-		queue_block.signal[index] = 1;
+		queue_block.signal[index] = MARS_WORKLOAD_SIGNAL_ON;
 
 		/* attempt to write back workload queue block to cache line */
 		status = atomic_put(&queue_block,
@@ -333,7 +333,7 @@ int workload_signal_try_wait(void)
 			MARS_ERROR_STATE);
 
 	/* return busy if task has not received signal */
-	if (!queue_block.signal[index])
+	if (queue_block.signal[index] != MARS_WORKLOAD_SIGNAL_ON)
 		return MARS_ERROR_BUSY;
 
 	return MARS_SUCCESS;





More information about the cbe-oss-dev mailing list