[Cbe-oss-dev] [PATCH 1/2] MARS: kernel scheduler add code comments

Yuji Mano Yuji.Mano at am.sony.com
Fri Aug 15 07:26:19 EST 2008


This adds some comments explaining some of the code inside the kernel scheduler 

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

---
 src/mpu/kernel/mars_kernel_scheduler.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

--- a/src/mpu/kernel/mars_kernel_scheduler.c
+++ b/src/mpu/kernel/mars_kernel_scheduler.c
@@ -59,29 +59,34 @@ static int search_block(struct mars_work
 	int max_priority = -1;
 
 	/* search through workload queue for next workload to run
-	** while incrementing wait counts for all waiting workloads
-	** and pick the workload that has been waiting the longest
-	*/
+	 * while incrementing wait counter for all waiting workloads
+	 * and pick the workload that has been waiting the longest
+	 */
 	for (i = 0; i < MARS_WORKLOAD_PER_BLOCK; i++) {
 		switch (block->state[i]) {
 		case MARS_WORKLOAD_STATE_READY:
+			/* priority greater than max priority so select */
 			if ((int)block->priority[i] > max_priority) {
 				index = i;
 				max_count = block->counter[i];
 				max_priority = block->priority[i];
+			/* priority equal and wait counter greater so select */
 			} else if ((int)block->priority[i] == max_priority &&
 				(int)block->counter[i] > max_count) {
 				index = i;
 				max_count = block->counter[i];
 			}
+			/* increment wait counter without overflowing */
 			if (block->counter[i] < MARS_WORKLOAD_COUNTER_MAX)
 				block->counter[i]++;
 			break;
 		case MARS_WORKLOAD_STATE_WAITING:
+			/* waiting for workload to finish so check status */
 			if (block->wait[i] != MARS_WORKLOAD_ID_NONE) {
 				int bl = block->wait[i]/MARS_WORKLOAD_PER_BLOCK;
 				int id = block->wait[i]%MARS_WORKLOAD_PER_BLOCK;
 
+				/* fetch the necessary workload block */
 				mars_dma_get_and_wait(&queue_block,
 				  queue_header.queue_ea +
 				  offsetof(struct mars_workload_queue, block) +
@@ -89,6 +94,7 @@ static int search_block(struct mars_work
 				  sizeof(struct mars_workload_queue_block),
 				  MARS_DMA_TAG);
 
+				/* check if workload is finished and reset */
 				if (queue_block.state[id] ==
 					MARS_WORKLOAD_STATE_FINISHED) {
 					block->wait[i] =
@@ -96,6 +102,7 @@ static int search_block(struct mars_work
 					block->state[i] =
 						MARS_WORKLOAD_STATE_READY;
 				}
+			/* waiting for signal so check signal bit and reset */
 			} else if (block->signal[i] ==
 				MARS_WORKLOAD_SIGNAL_ON) {
 				block->signal[i] = MARS_WORKLOAD_SIGNAL_OFF;





More information about the cbe-oss-dev mailing list