what should be unblocked

ady001 wrote on Thursday, 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.

rtel wrote on Thursday, 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.

ady001 wrote on Thursday, 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,

heinbali01 wrote on Friday, April 29, 2016:

I modified your program:

/* Let the delays last 2 seconds. */
#define NOTIFICATION_TASK_PERIOD    pdMS_TO_TICKS( 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.

ady001 wrote on Friday, 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 ?

heinbali01 wrote on Friday, 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.