[Cbe-oss-dev] [PATCH 1/5] MARS: yield in workload queue wait busy loop

Yuji Mano Yuji.Mano at am.sony.com
Tue Jul 15 10:26:29 EST 2008


Call sched_yield() inside the busy loop on the host-side
to wait for workload completion. This allows other
processes to run more generously on the host while waiting
in the busy loop.

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

---
 src/host/lib/mars_workload_queue.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/src/host/lib/mars_workload_queue.c
+++ b/src/host/lib/mars_workload_queue.c
@@ -35,6 +35,7 @@
  * LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
  */
 
+#include <sched.h>
 #include <unistd.h>
 #include <string.h>
 
@@ -194,9 +195,8 @@ int workload_queue_wait(struct mars_work
 	MARS_CHECK_RET(queue->block[block].state[index] !=
 			MARS_WORKLOAD_STATE_NONE, MARS_ERROR_STATE);
 
-	while (*(volatile uint8_t *)&queue->block[block].state[index] !=
-		MARS_WORKLOAD_STATE_FINISHED) {
-	}
+	while (queue->block[block].state[index] != MARS_WORKLOAD_STATE_FINISHED)
+		sched_yield();
 
 	return MARS_SUCCESS;
 }





More information about the cbe-oss-dev mailing list