Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

what should be unblocked

Posted by ady001 on April 28, 2016

I understand that xTaskNotifyGive() can be used to unblock a task blocked by xTaskNotifyTake(). But should xTaskNotifyGive() also unblock a task if blocked by vTaskDelayUntil() ?

It seems to during testing, I assumed the xTaskNotifyGive() would only unblock the corresponding xTaskNotifyTake().

Thanks for a confirmation.


what should be unblocked

Posted by rtel on April 28, 2016

But should xTaskNotifyGive() also unblock a task if blocked by vTaskDelayUntil() ?

No - xTaskNotifyGive() will only unblock a task that is specifically waiting for a notification. xTaskAbortDelay() is the only API function that will unblock a task that called vTaskDelayUntil().

Regards.


what should be unblocked

Posted by ady001 on April 28, 2016

I've attached the source file, there isn't much of it - maybe you can take a look.

If I comment out xTaskNotifyGive() and xTaskNotifyTake() calls within the functions prvTask1() and prvTask2() my test LED ( CMP_ON ) flashes at 200ms rate as expected.

If the xTaskNotifyGive() and xTaskNotifyTake() calls are put in place ( as per the attached file ) the LED flashes at a very high rate as if the vTaskDelayUntil() function is falling through. I wouldn't expect these function to have any significant effect on the 200ms flash rate.

Where is my misunderstanding ?

I know there are much easiers ways to flash a LED !

Kind regards,

Attachments

NotificationTests.c (2704 bytes)

what should be unblocked

Posted by heinbali01 on April 29, 2016

I modified your program:

~~~~ /* Let the delays last 2 seconds. */

define NOTIFICATIONTASKPERIOD pdMSTOTICKS( 2000 )

~~~~

and added some logging:

~~~~ 48.528 [ Task-2 ] Take 48.529 [ Task-1 ] Give 48.529 [ Task-1 ] Take 48.529 [ Task-2 ] Give 48.530 [ Task-2 ] Delay 48.530 [ Task-1 ] Delay

50.528 [ Task-2 ] Take
50.529 [ Task-1 ] Give
50.529 [ Task-1 ] Take
50.530 [ Task-2 ] Give
50.530 [ Task-2 ] Delay
50.530 [ Task-1 ] Delay

52.528 [ Task-2 ] Take
52.529 [ Task-1 ] Give
52.529 [ Task-1 ] Take
52.530 [ Task-2 ] Give
52.530 [ Task-2 ] Delay
52.530 [ Task-1 ] Delay

~~~~

For me itruns fine as it is.

The delays will always last 2 seconds and (indeed) they have nothing to do with the TaskNotify calls.

Note that your code has a potential problem:

task-1 will start running first.When it uses the variable 'xTask2', is task-2 already started? Otherwise I wouldn't know a reason.


what should be unblocked

Posted by ady001 on April 29, 2016

Thanks for the log, I think I understand my oversight now.

The effect of the TaskNotify calls is to 'synchronize' the two functions. This meant that the tasks were still executing every 200ms but my LED appeared to stop flashing because the two tasks calls were now in immediate succession due o the 'synchronization'. Whilst the tasks become synchromized one of the tasks must have been blocked for >200ms whilst waiting on the Notify.

Does this sound right ?


what should be unblocked

Posted by heinbali01 on April 29, 2016

Sounds right.

Do you have a second LED for testing? If so, you might assign a LED to each of the tasks and toggle it after every delay. Andif not: assign the LED to task-1 only and have it toggle the LED after every delay.

Regards.


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


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

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

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

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner