mirror of
				https://github.com/FreeRTOS/FreeRTOS-Kernel.git
				synced 2025-11-04 11:09:01 +01:00 
			
		
		
		
	refactor: change methods ENTER|EXIT critical (#1140)
refactor: change methods ENTER|EXIT critical The read and write of BaseType_t are atomic for a number of ports and therefore, do not require taskENTER_CRITICAL/taskEXIT_CRITICAL. This PR introduces portBASE_TYPE_ENTER_CRITICAL and portBASE_TYPE_EXIT_CRITICAL which default to taskENTER_CRITICAL and taskEXIT_CRITICAL. The APIs that read/write BaseType_t are updated to use these new macros. The next change would to be to define portBASE_TYPE_ENTER_CRITICAL and portBASE_TYPE_EXIT_CRITICAL to nothing for ports where BaseType_t read and write are atomic. Signed-off-by: guilherme giacomo simoes <trintaeoitogc@gmail.com>
This commit is contained in:
		
							parent
							
								
									1cb8042961
								
							
						
					
					
						commit
						e81ad46b0e
					
				
							
								
								
									
										2
									
								
								.github/third_party_tools.md
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/third_party_tools.md
									
									
									
									
										vendored
									
									
								
							@ -11,4 +11,4 @@ team.
 | 
				
			|||||||
| Tool | Website | Getting Started |
 | 
					| Tool | Website | Getting Started |
 | 
				
			||||||
|------|---------|-----------------|
 | 
					|------|---------|-----------------|
 | 
				
			||||||
| Code Sonar | [Link](https://codesecure.com/our-products/codesonar/) | [Link](https://github.com/CodeSecure-SE/FreeRTOS-Kernel/blob/main/examples/codesonar/README.md) |
 | 
					| Code Sonar | [Link](https://codesecure.com/our-products/codesonar/) | [Link](https://github.com/CodeSecure-SE/FreeRTOS-Kernel/blob/main/examples/codesonar/README.md) |
 | 
				
			||||||
| Coverity | [Link](https://www.synopsys.com/software-integrity/security-testing/static-analysis-sast.html) | [Link](../examples/coverity/README.md) |
 | 
					| Coverity | [Link](https://www.blackduck.com/static-analysis-tools-sast/coverity.html) | [Link](../examples/coverity/README.md) |
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,6 @@
 | 
				
			|||||||
# MISRA Compliance for FreeRTOS-Kernel
 | 
					# MISRA Compliance for FreeRTOS-Kernel
 | 
				
			||||||
FreeRTOS-Kernel is MISRA C:2012 compliant. This directory contains a project to
 | 
					FreeRTOS-Kernel is MISRA C:2012 compliant. This directory contains a project to
 | 
				
			||||||
run [Synopsys Coverity](https://www.synopsys.com/software-integrity/security-testing/static-analysis-sast.html)
 | 
					run [Synopsys Coverity](https://www.blackduck.com/static-analysis-tools-sast/coverity.html)
 | 
				
			||||||
for checking MISRA compliance.
 | 
					for checking MISRA compliance.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
> **Note**
 | 
					> **Note**
 | 
				
			||||||
 | 
				
			|||||||
@ -85,6 +85,14 @@
 | 
				
			|||||||
    #define portARCH_NAME    NULL
 | 
					    #define portARCH_NAME    NULL
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef portBASE_TYPE_ENTER_CRITICAL
 | 
				
			||||||
 | 
					    #define portBASE_TYPE_ENTER_CRITICAL()    taskENTER_CRITICAL()
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifndef portBASE_TYPE_EXIT_CRITICAL
 | 
				
			||||||
 | 
					    #define portBASE_TYPE_EXIT_CRITICAL()    taskEXIT_CRITICAL()
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef configSTACK_DEPTH_TYPE
 | 
					#ifndef configSTACK_DEPTH_TYPE
 | 
				
			||||||
    #define configSTACK_DEPTH_TYPE    StackType_t
 | 
					    #define configSTACK_DEPTH_TYPE    StackType_t
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										8
									
								
								queue.c
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								queue.c
									
									
									
									
									
								
							@ -2202,11 +2202,11 @@ UBaseType_t uxQueueMessagesWaiting( const QueueHandle_t xQueue )
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    configASSERT( xQueue );
 | 
					    configASSERT( xQueue );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    taskENTER_CRITICAL();
 | 
					    portBASE_TYPE_ENTER_CRITICAL();
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        uxReturn = ( ( Queue_t * ) xQueue )->uxMessagesWaiting;
 | 
					        uxReturn = ( ( Queue_t * ) xQueue )->uxMessagesWaiting;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    taskEXIT_CRITICAL();
 | 
					    portBASE_TYPE_EXIT_CRITICAL();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    traceRETURN_uxQueueMessagesWaiting( uxReturn );
 | 
					    traceRETURN_uxQueueMessagesWaiting( uxReturn );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2223,11 +2223,11 @@ UBaseType_t uxQueueSpacesAvailable( const QueueHandle_t xQueue )
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    configASSERT( pxQueue );
 | 
					    configASSERT( pxQueue );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    taskENTER_CRITICAL();
 | 
					    portBASE_TYPE_ENTER_CRITICAL();
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        uxReturn = ( UBaseType_t ) ( pxQueue->uxLength - pxQueue->uxMessagesWaiting );
 | 
					        uxReturn = ( UBaseType_t ) ( pxQueue->uxLength - pxQueue->uxMessagesWaiting );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    taskEXIT_CRITICAL();
 | 
					    portBASE_TYPE_EXIT_CRITICAL();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    traceRETURN_uxQueueSpacesAvailable( uxReturn );
 | 
					    traceRETURN_uxQueueSpacesAvailable( uxReturn );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										12
									
								
								tasks.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								tasks.c
									
									
									
									
									
								
							@ -2623,14 +2623,14 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        traceENTER_uxTaskPriorityGet( xTask );
 | 
					        traceENTER_uxTaskPriorityGet( xTask );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        taskENTER_CRITICAL();
 | 
					        portBASE_TYPE_ENTER_CRITICAL();
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            /* If null is passed in here then it is the priority of the task
 | 
					            /* If null is passed in here then it is the priority of the task
 | 
				
			||||||
             * that called uxTaskPriorityGet() that is being queried. */
 | 
					             * that called uxTaskPriorityGet() that is being queried. */
 | 
				
			||||||
            pxTCB = prvGetTCBFromHandle( xTask );
 | 
					            pxTCB = prvGetTCBFromHandle( xTask );
 | 
				
			||||||
            uxReturn = pxTCB->uxPriority;
 | 
					            uxReturn = pxTCB->uxPriority;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        taskEXIT_CRITICAL();
 | 
					        portBASE_TYPE_EXIT_CRITICAL();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        traceRETURN_uxTaskPriorityGet( uxReturn );
 | 
					        traceRETURN_uxTaskPriorityGet( uxReturn );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2697,14 +2697,14 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        traceENTER_uxTaskBasePriorityGet( xTask );
 | 
					        traceENTER_uxTaskBasePriorityGet( xTask );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        taskENTER_CRITICAL();
 | 
					        portBASE_TYPE_ENTER_CRITICAL();
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            /* If null is passed in here then it is the base priority of the task
 | 
					            /* If null is passed in here then it is the base priority of the task
 | 
				
			||||||
             * that called uxTaskBasePriorityGet() that is being queried. */
 | 
					             * that called uxTaskBasePriorityGet() that is being queried. */
 | 
				
			||||||
            pxTCB = prvGetTCBFromHandle( xTask );
 | 
					            pxTCB = prvGetTCBFromHandle( xTask );
 | 
				
			||||||
            uxReturn = pxTCB->uxBasePriority;
 | 
					            uxReturn = pxTCB->uxBasePriority;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        taskEXIT_CRITICAL();
 | 
					        portBASE_TYPE_EXIT_CRITICAL();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        traceRETURN_uxTaskBasePriorityGet( uxReturn );
 | 
					        traceRETURN_uxTaskBasePriorityGet( uxReturn );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -3040,12 +3040,12 @@ static void prvInitialiseNewTask( TaskFunction_t pxTaskCode,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        traceENTER_vTaskCoreAffinityGet( xTask );
 | 
					        traceENTER_vTaskCoreAffinityGet( xTask );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        taskENTER_CRITICAL();
 | 
					        portBASE_TYPE_ENTER_CRITICAL();
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            pxTCB = prvGetTCBFromHandle( xTask );
 | 
					            pxTCB = prvGetTCBFromHandle( xTask );
 | 
				
			||||||
            uxCoreAffinityMask = pxTCB->uxCoreAffinityMask;
 | 
					            uxCoreAffinityMask = pxTCB->uxCoreAffinityMask;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        taskEXIT_CRITICAL();
 | 
					        portBASE_TYPE_EXIT_CRITICAL();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        traceRETURN_vTaskCoreAffinityGet( uxCoreAffinityMask );
 | 
					        traceRETURN_vTaskCoreAffinityGet( uxCoreAffinityMask );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										8
									
								
								timers.c
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								timers.c
									
									
									
									
									
								
							@ -601,7 +601,7 @@
 | 
				
			|||||||
        traceENTER_xTimerGetReloadMode( xTimer );
 | 
					        traceENTER_xTimerGetReloadMode( xTimer );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        configASSERT( xTimer );
 | 
					        configASSERT( xTimer );
 | 
				
			||||||
        taskENTER_CRITICAL();
 | 
					        portBASE_TYPE_ENTER_CRITICAL();
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) == 0U )
 | 
					            if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) == 0U )
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@ -614,7 +614,7 @@
 | 
				
			|||||||
                xReturn = pdTRUE;
 | 
					                xReturn = pdTRUE;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        taskEXIT_CRITICAL();
 | 
					        portBASE_TYPE_EXIT_CRITICAL();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        traceRETURN_xTimerGetReloadMode( xReturn );
 | 
					        traceRETURN_xTimerGetReloadMode( xReturn );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -1169,7 +1169,7 @@
 | 
				
			|||||||
        configASSERT( xTimer );
 | 
					        configASSERT( xTimer );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /* Is the timer in the list of active timers? */
 | 
					        /* Is the timer in the list of active timers? */
 | 
				
			||||||
        taskENTER_CRITICAL();
 | 
					        portBASE_TYPE_ENTER_CRITICAL();
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if( ( pxTimer->ucStatus & tmrSTATUS_IS_ACTIVE ) == 0U )
 | 
					            if( ( pxTimer->ucStatus & tmrSTATUS_IS_ACTIVE ) == 0U )
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
@ -1180,7 +1180,7 @@
 | 
				
			|||||||
                xReturn = pdTRUE;
 | 
					                xReturn = pdTRUE;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        taskEXIT_CRITICAL();
 | 
					        portBASE_TYPE_EXIT_CRITICAL();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        traceRETURN_xTimerIsTimerActive( xReturn );
 | 
					        traceRETURN_xTimerIsTimerActive( xReturn );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user