[Cbe-oss-dev] [PATCH 11/23]MARS/base: idle wait fix

Yuji Mano yuji.mano at am.sony.com
Sat Mar 14 12:18:38 EST 2009


From: Kazunori Asayama <asayama at sm.sony.co.jp>

Avoid unexpected idle wait

The current scheduler has possibility to missing 'ready' workload and
to deadlock, since the static variable 'queue_header' is overwritten
in the 'update_header_bits_counter' function. This patch fixes the
problem by retrying the search in case that no 'ready' workload is
found in a 'ready' workload block.

Signed-off-by: Kazunori Asayama <asayama at sm.sony.co.jp>
Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
---
 base/src/common/kernel_internal_types.h |    5 +++--
 base/src/mpu/kernel/kernel.c            |    9 +++++----
 2 files changed, 8 insertions(+), 6 deletions(-)

--- a/base/src/common/kernel_internal_types.h
+++ b/base/src/common/kernel_internal_types.h
@@ -46,9 +46,10 @@
 
 #define MARS_KERNEL_ID_NONE			0xffff
 
-#define MARS_KERNEL_STATUS_BUSY			0x0
+#define MARS_KERNEL_STATUS_EXIT			0x0
 #define MARS_KERNEL_STATUS_IDLE			0x1
-#define MARS_KERNEL_STATUS_EXIT			0x2
+#define MARS_KERNEL_STATUS_BUSY			0x2
+#define MARS_KERNEL_STATUS_RETRY		0x3
 
 #define MARS_KERNEL_TICKS_FLAG_SYNC_BEGIN	0x1
 #define MARS_KERNEL_TICKS_FLAG_SYNC_END		0x2
--- a/base/src/mpu/kernel/kernel.c
+++ b/base/src/mpu/kernel/kernel.c
@@ -730,7 +730,7 @@ static int reserve_workload(void)
 	/* search block for workload index to run */
 	index = search_block(block, 1);
 	if (index < 0)
-		return MARS_KERNEL_STATUS_IDLE;
+		return MARS_KERNEL_STATUS_RETRY;
 
 	/* set global workload info based on workload block and index */
 	workload_id = MARS_WORKLOAD_PER_BLOCK * block + index;
@@ -938,13 +938,14 @@ int main(unsigned long long mpu_context_
 		int status = scheduler();
 
 		switch (status) {
-		case MARS_KERNEL_STATUS_BUSY:
+		case MARS_KERNEL_STATUS_EXIT:
+			exit_flag = 1;
 			break;
 		case MARS_KERNEL_STATUS_IDLE:
 			scheduler_idle_wait();
 			break;
-		case MARS_KERNEL_STATUS_EXIT:
-			exit_flag = 1;
+		case MARS_KERNEL_STATUS_BUSY:
+		case MARS_KERNEL_STATUS_RETRY:
 			break;
 		}
 	}






More information about the cbe-oss-dev mailing list