[En-Nut-Discussion] Timeout on Event Wait

William Basser wbasser at adelphia.net
Sun Oct 19 17:34:14 CEST 2003


TASKA in a nutshell
static THREAD( GatSeqHandler, arg )
{
	GATSEQ		eCurState = GAT_IDLE;

	// change the priority
	NutThreadSetPriority( 70 );

	FOREVER
	{
		// process the state
		switch ( eCurState )
		{
		case GAT_STRT :
			// wait for start event
			NutEventWait( &g_hGatSeqEvent, NUT_WAIT_INFINITE
);
			NutEventPost( &hRdrRunEvent );
			eCurState = GAT_DSCN;
			break;

		case GAT_WAIT :
			// wait for a completion state
			if ( NutEventWaitNext( &hTktEvent, 5000 ) == 0 )
			{
*** this event wait never times out
*** I have tried both EventWaitNext
*** and EventWait
            	}
			else
			{
				// stop the reader sequencer
				bRdrRun = FALSE;
			}
			break;

		default :
			// error - should never happen
			eCurState = GAT_IDLE;
			break;
		}

		// cooperate
		NutThreadYield( );
	}
}

TASK B in a nutshell
static THREAD( RdrSeqHandler, arg )
{
	RDRSEQ		eCurState = RDR_IDLE;

	// change the priority
	NutThreadSetPriority( 78 );

	FOREVER
	{
		// process the state
		switch ( eCurState )
		{
		case RDR_IDLE :
			// wait for start event/set the reader run flag
			NutEventWait( &hRdrRunEvent, NUT_WAIT_INFINITE
);
			bRdrRun = TRUE;
			eCurState = RDR_CLBF;
			break;

		case RDR_VTKT :
			// turn off the reader run/post the ticket event
			bRdrRun = FALSE;
			NutEventPost( &hTktEvent );
			eCurState = RDR_ROFF;
			break;

		default :
			// error - should never happen
			eCurState = RDR_IDLE;
			break;
		}

		// cooperate
		NutThreadYield( );
	}
}


-----Original Message-----
From: en-nut-discussion-admin at egnite.de
[mailto:en-nut-discussion-admin at egnite.de] On Behalf Of Harald Kipp
Sent: Sunday, October 19, 2003 11:21 AM
To: en-nut-discussion at egnite.de
Subject: RE: [En-Nut-Discussion] Timeout on Event Wait


Another idea:

Even if task B has a lower priority, it needs
to call something, that allows others to run,
like NutThreadYield().

Harald

_______________________________________________
En-Nut-Discussion mailing list
En-Nut-Discussion at egnite.de
http://www.egnite.de/mailman/listinfo/en-nut-discussion




More information about the En-Nut-Discussion mailing list