Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

context switch from the void vApplicationTickHook(void) callback function

Posted by lz1msz on October 27, 2015

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:

  1. 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()

  1. 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


context switch from the void vApplicationTickHook(void) callback function

Posted by rtel on October 27, 2015

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.


context switch from the void vApplicationTickHook(void) callback function

Posted by lz1msz on October 28, 2015

Thank you!


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists