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] [October 2015 Threads]
We are in charge for development of project, based on FreeRTOS VER 8.2.0
Details:
MCU: PIC24EP family /PIC24EP512GU810/
Compiler: XC16 1.21 PRO mode, all optimization enabled
FreeRTOS version: 8.2.0
We are using 5 tasks and several ISRs, but due to behavior issue, need to clarify our ISRs coding:
- Is it RTOS save to switch the context in the callback function: vApplicationTickHook(void)
Due to it is valuable to use it as a 1mS tick timer, we need to send message queue to task and wake-up the task. My question is: Is this context switch RTOS save code for the tick hook. I add the source code inside the vApplicationTickHook(void) function:
void vApplicationTickHook(void)
{
// Local variables:
GOLMSG pMsg;
GRAPHICSMESSAGE MyGraphicsMessage;
BaseTypet xHigherPriorityTaskWoken;
unsigned char PortYieldFlag;
PortYieldFlag = 0;
// Process outgoing messages to the graphics task:
TouchDetectPosition(); // Update the current coordinates
TouchGetMsg(&pMsg); // Decide if the new points generate touch message
// If there is touch message received, send it to the graphics task:
if(pMsg.type != EVENTINVALID) // Received is valid message
{
MyGraphicsMessage.MessageCommand = GRAPHICSTASKTOUCSCREENMESSAGE; // Name the message command header, that this is touch screen message
MyGraphicsMessage.MessageData.MyGolMessage = pMsg;
xHigherPriorityTaskWoken = pdFALSE; // Initialize the variable, which store the condition if context switch is needed
xQueueSendFromISR(GraphicsTaskQueue, &MyGraphicsMessage, &xHigherPriorityTaskWoken); // Send the message to the graphics task queue
if(xHigherPriorityTaskWoken == pdTRUE) // Check if context switch is needed
{
//taskYIELD(); // Perform the context switch
PortYieldFlag = 1;
}
}
// Timestamp functions for all tasks:
MAINAPPLICATIONTASKSTimeStampTick(); // Rolling the software timers
// Process time for load screen duration:
if(1 == MAINAPPLICATIONTASKSLoadScreenTimerTick()) // Inside this function message queue is send to the desired task
{
PortYieldFlag = 1;
}
// Application level task wake-up hook:
////APPLICATIONLEVELTASKTimeoutTick();
if(PortYieldFlag == 1)
{
taskYIELD();
}
} // End of vApplicationTickHook()
- Due to we use many ISRs with different priority, we changed the:#define configKERNELINTERRUPTPRIORITY 0x07
(Also modified all needed values in the needed port files)
Currently all of our ISRs, which can cause context switch are priority level 7, all other ISRs are less priority level
Is this configuration RTOS SAVE?
Many thanks in advance
Regards
Dimitar Belev
Looking at how the port is implemented on that part I would say no, it is not safe. In other ports it is safe, but also pointless, as the tick interrupt will switch to the highest priority task anyway.
It is ok to unblock a task (using vTaskNotifyGiveFromISR()), but don't then perform a context switch. As mentioned above, if the unblocked task is the highest priority task it will get selected to run anyway.
Regards.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.