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] [April 2016 Threads] what should be unblockedPosted 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 unblockedPosted 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 unblockedPosted 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,
what should be unblockedPosted 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 unblockedPosted 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 unblockedPosted 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|