FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [November 2009 Threads] FreeRTOS Privilege Status DetectionPosted by Jerry Ross on November 14, 2009 FreeRTOSS6.0.0:
Definition in: FreeRTOS.h
#ifndef portPRIVILEGE_BIT #define portPRIVILEGE_BIT ( ( unsigned portBASE_TYPE ) 0x00 ) #endif
Usage in: tasks.c
/* Should the task be created in privileged mode? */ LINE: 403 if( ( uxPriority & portPRIVILEGE_BIT ) != 0x00 ) { xRunPrivileged = pdTRUE; } else { xRunPrivileged = pdFALSE; } uxPriority &= ~portPRIVILEGE_BIT;
The code at line 403 will always fail the test ( uxPriority & portPRIVILEGE_BIT ) != 0x00 because portPRIVILEGE_BIT is the value 0 which represents the privilege bit position in uxPriority. It is being used as a value, zero (0), instead of a bit position of zero (0) so the expression (uxPriority & portPRIVILEGE_BIT) will always produce a value of zero (0) which will never be !=0x00.
Jerry Ross
RE: FreeRTOS Privilege Status DetectionPosted by Richard on November 14, 2009 #ifndef portPRIVILEGE_BIT #define portPRIVILEGE_BIT ( ( unsigned portBASE_TYPE ) 0x00 ) #endif
This definition is the default setting when portPRIVILEGE_BIT is not defined anywhere else. In the Cortex M3 MPU ports portPRIVILEGE_BIT is defined as 0x80000000, which means bit 31 indicates the privilege status.
if( ( uxPriority & portPRIVILEGE_BIT ) != 0x00 ) { xRunPrivileged = pdTRUE; } else { xRunPrivileged = pdFALSE; }
If portPRIVILEGE_BIT is 0 then xRunPrivileged will always be set to pdFALSE as anything bitwise ANDed with 0 will always be zero. However, if portPRIVILEGE_BIT is set to 0 then the MPU is not being used and pdFALSE is the correct value for xRunPrivileged. A value of 0 does not mean bit 0, it means no bits are set.
Regards.
RE: FreeRTOS Privilege Status DetectionPosted by Jerry Ross on November 14, 2009 Thank you for the quick reply. I understand your logic now. I should have scanned the entire code base for an answer. I will be more thorough next time.
My compiler elides the expression because it has no effect.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|