mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Mutex robust APIs are not available on Mac
Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:
parent
2e38eb5423
commit
92be5d47ee
|
@ -39,6 +39,7 @@ struct event
|
|||
pthread_cond_t cond;
|
||||
bool event_triggered;
|
||||
};
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
struct event * event_create( void )
|
||||
{
|
||||
|
@ -48,13 +49,16 @@ struct event * event_create( void )
|
|||
{
|
||||
ev->event_triggered = false;
|
||||
pthread_mutexattr_init( &ev->mutexattr );
|
||||
#ifndef __APPLE__
|
||||
pthread_mutexattr_setrobust( &ev->mutexattr, PTHREAD_MUTEX_ROBUST );
|
||||
#endif
|
||||
pthread_mutex_init( &ev->mutex, &ev->mutexattr );
|
||||
pthread_cond_init( &ev->cond, NULL );
|
||||
}
|
||||
|
||||
return ev;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void event_delete( struct event * ev )
|
||||
{
|
||||
|
@ -63,13 +67,16 @@ void event_delete( struct event * ev )
|
|||
pthread_cond_destroy( &ev->cond );
|
||||
free( ev );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
bool event_wait( struct event * ev )
|
||||
{
|
||||
if( pthread_mutex_lock( &ev->mutex ) == EOWNERDEAD )
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
/* If the thread owning the mutex died, make the mutex consistent. */
|
||||
pthread_mutex_consistent( &ev->mutex );
|
||||
#endif
|
||||
}
|
||||
|
||||
while( ev->event_triggered == false )
|
||||
|
@ -81,6 +88,8 @@ bool event_wait( struct event * ev )
|
|||
pthread_mutex_unlock( &ev->mutex );
|
||||
return true;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
bool event_wait_timed( struct event * ev,
|
||||
time_t ms )
|
||||
{
|
||||
|
@ -92,8 +101,10 @@ bool event_wait_timed( struct event * ev,
|
|||
ts.tv_nsec += ( ( ms % 1000 ) * 1000000 );
|
||||
if( pthread_mutex_lock( &ev->mutex ) == EOWNERDEAD )
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
/* If the thread owning the mutex died, make the mutex consistent. */
|
||||
pthread_mutex_consistent( &ev->mutex );
|
||||
#endif
|
||||
}
|
||||
|
||||
while( ( ev->event_triggered == false ) && ( ret == 0 ) )
|
||||
|
@ -110,15 +121,19 @@ bool event_wait_timed( struct event * ev,
|
|||
pthread_mutex_unlock( &ev->mutex );
|
||||
return true;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void event_signal( struct event * ev )
|
||||
{
|
||||
if( pthread_mutex_lock( &ev->mutex ) == EOWNERDEAD )
|
||||
{
|
||||
#ifndef __APPLE__
|
||||
/* If the thread owning the mutex died, make the mutex consistent. */
|
||||
pthread_mutex_consistent( &ev->mutex );
|
||||
#endif
|
||||
}
|
||||
ev->event_triggered = true;
|
||||
pthread_cond_signal( &ev->cond );
|
||||
pthread_mutex_unlock( &ev->mutex );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
|
Loading…
Reference in a new issue