mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2026-07-10 13:29:45 -04:00
change(freertos/smp): Update timers.c locking
Updated timers.c to use granular locking - Added xTaskSpinlock and xISRSpinlock - Replaced critical section macros with data group critical section macros such as taskENTER/EXIT_CRITICAL() with tmrENTER/EXIT_CRITICAL(). - Added vTimerEnterCritical() and vTimerExitCritical() to map to the data group critical section macros. Co-authored-by: Sudeep Mohanty <sudeep.mohanty@espressif.com>
This commit is contained in:
parent
3ba8783ca4
commit
a85f9cfaba
1 changed files with 55 additions and 12 deletions
67
timers.c
67
timers.c
|
|
@ -79,6 +79,17 @@
|
|||
#define tmrSTATUS_IS_STATICALLY_ALLOCATED ( 0x02U )
|
||||
#define tmrSTATUS_IS_AUTORELOAD ( 0x04U )
|
||||
|
||||
/*
|
||||
* Macros to mark the start and end of a critical code region.
|
||||
*/
|
||||
#if ( portUSING_GRANULAR_LOCKS == 1 )
|
||||
#define tmrENTER_CRITICAL() taskDATA_GROUP_ENTER_CRITICAL( &xTimerTaskSpinlock, &xTimerISRSpinlock )
|
||||
#define tmrEXIT_CRITICAL() taskDATA_GROUP_EXIT_CRITICAL( &xTimerTaskSpinlock, &xTimerISRSpinlock )
|
||||
#else /* #if ( portUSING_GRANULAR_LOCKS == 1 ) */
|
||||
#define tmrENTER_CRITICAL() taskENTER_CRITICAL()
|
||||
#define tmrEXIT_CRITICAL() taskEXIT_CRITICAL()
|
||||
#endif /* #if ( portUSING_GRANULAR_LOCKS == 1 ) */
|
||||
|
||||
/* The definition of the timers themselves. */
|
||||
typedef struct tmrTimerControl /* The old naming convention is used to prevent breaking kernel aware debuggers. */
|
||||
{
|
||||
|
|
@ -582,7 +593,7 @@
|
|||
traceENTER_vTimerSetReloadMode( xTimer, xAutoReload );
|
||||
|
||||
configASSERT( xTimer );
|
||||
taskENTER_CRITICAL();
|
||||
tmrENTER_CRITICAL();
|
||||
{
|
||||
if( xAutoReload != pdFALSE )
|
||||
{
|
||||
|
|
@ -593,7 +604,7 @@
|
|||
pxTimer->ucStatus &= ( ( uint8_t ) ~tmrSTATUS_IS_AUTORELOAD );
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
tmrEXIT_CRITICAL();
|
||||
|
||||
traceRETURN_vTimerSetReloadMode();
|
||||
}
|
||||
|
|
@ -607,7 +618,15 @@
|
|||
traceENTER_xTimerGetReloadMode( xTimer );
|
||||
|
||||
configASSERT( xTimer );
|
||||
portBASE_TYPE_ENTER_CRITICAL();
|
||||
#if ( ( configNUMBER_OF_CORES > 1 ) )
|
||||
{
|
||||
tmrENTER_CRITICAL();
|
||||
}
|
||||
#else
|
||||
{
|
||||
portBASE_TYPE_ENTER_CRITICAL();
|
||||
}
|
||||
#endif
|
||||
{
|
||||
if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) == 0U )
|
||||
{
|
||||
|
|
@ -620,7 +639,15 @@
|
|||
xReturn = pdTRUE;
|
||||
}
|
||||
}
|
||||
portBASE_TYPE_EXIT_CRITICAL();
|
||||
#if ( ( configNUMBER_OF_CORES > 1 ) )
|
||||
{
|
||||
tmrEXIT_CRITICAL();
|
||||
}
|
||||
#else
|
||||
{
|
||||
portBASE_TYPE_EXIT_CRITICAL();
|
||||
}
|
||||
#endif
|
||||
|
||||
traceRETURN_xTimerGetReloadMode( xReturn );
|
||||
|
||||
|
|
@ -1126,7 +1153,7 @@
|
|||
/* Check that the list from which active timers are referenced, and the
|
||||
* queue used to communicate with the timer service, have been
|
||||
* initialised. */
|
||||
taskENTER_CRITICAL();
|
||||
tmrENTER_CRITICAL();
|
||||
{
|
||||
if( xTimerQueue == NULL )
|
||||
{
|
||||
|
|
@ -1168,7 +1195,7 @@
|
|||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
tmrEXIT_CRITICAL();
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
@ -1182,7 +1209,15 @@
|
|||
configASSERT( xTimer );
|
||||
|
||||
/* Is the timer in the list of active timers? */
|
||||
portBASE_TYPE_ENTER_CRITICAL();
|
||||
#if ( ( configNUMBER_OF_CORES > 1 ) )
|
||||
{
|
||||
tmrENTER_CRITICAL();
|
||||
}
|
||||
#else
|
||||
{
|
||||
portBASE_TYPE_ENTER_CRITICAL();
|
||||
}
|
||||
#endif
|
||||
{
|
||||
if( ( pxTimer->ucStatus & tmrSTATUS_IS_ACTIVE ) == 0U )
|
||||
{
|
||||
|
|
@ -1193,7 +1228,15 @@
|
|||
xReturn = pdTRUE;
|
||||
}
|
||||
}
|
||||
portBASE_TYPE_EXIT_CRITICAL();
|
||||
#if ( ( configNUMBER_OF_CORES > 1 ) )
|
||||
{
|
||||
tmrEXIT_CRITICAL();
|
||||
}
|
||||
#else
|
||||
{
|
||||
portBASE_TYPE_EXIT_CRITICAL();
|
||||
}
|
||||
#endif
|
||||
|
||||
traceRETURN_xTimerIsTimerActive( xReturn );
|
||||
|
||||
|
|
@ -1210,11 +1253,11 @@
|
|||
|
||||
configASSERT( xTimer );
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
tmrENTER_CRITICAL();
|
||||
{
|
||||
pvReturn = pxTimer->pvTimerID;
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
tmrEXIT_CRITICAL();
|
||||
|
||||
traceRETURN_pvTimerGetTimerID( pvReturn );
|
||||
|
||||
|
|
@ -1231,11 +1274,11 @@
|
|||
|
||||
configASSERT( xTimer );
|
||||
|
||||
taskENTER_CRITICAL();
|
||||
tmrENTER_CRITICAL();
|
||||
{
|
||||
pxTimer->pvTimerID = pvNewID;
|
||||
}
|
||||
taskEXIT_CRITICAL();
|
||||
tmrEXIT_CRITICAL();
|
||||
|
||||
traceRETURN_vTimerSetTimerID();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue