osMutexDef( Mutex );
osMutexId mutex; void Thread0( void * arg);
void Thread1( void * arg); osThreadDef( Thread0, Thread0, osPriorityNormal, );
osThreadDef( Thread1, Thread1, osPriorityAboveNormal, ); void Thread0( void * arg)
{
while()
{
osMutexWait( mutex, osWaitForever );
osDelay( );
osMutexRelease( mutex );
osDelay( );
}
} void Thread1( void * arg)
{
while()
{
osMutexWait( mutex, osWaitForever );
osDelay( );
osMutexRelease( mutex );
osDelay( );
}
} int main( void )
{
osKernelInitialize(); osThreadCreate( osThread(Thread0), (void *) );
osThreadCreate( osThread(Thread1), (void *) ); mutex = osMutexCreate( osMutex(Mutex) ); osKernelStart(); return ;
}