FreeRTOS Support Archive

The FreeRTOS support forum can be used for active support both from Amazon Web Services
and the community. In return for using our software for
free, we request you play fair and do your bit to help others! 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.

How to prevent retriggering a task?

Hi,
I have a task, waiting for a trigger signal. After that some processing starts out, which also contains waiting phases, but on other semaphores. After work is finished, the task waits again for a trigger.
How can I effectively prevent retriggering.
The problem is, that I have to set some parameters before the trigger is set, if I don't prevent retriggering, this changes corrupt the running sequence.

How to prevent retriggering a task?

I dont understand. If the code is looping and taking the semaphore each loop like you show then the take will time out or return when the semaphore is given. If you dont want that then is the answer just not to take the semaphore?

How to prevent retriggering a task?

.. the loop needs some time. Guess //Do something is running for 200ms. In this time, it should be forbidden to make any changes. So calling the trigger function, which sets some parameters should be prevented. Only after the task is back waiting for a trigger calls to the trigger function should be allowed.

How to prevent retriggering a task?

It sounds like you need to wrap the acces to the data with a mutex, so the triggered task begins with taking the mutex, and gives it when done, and the trigger action takes the mutex before setting up the data and then gives it when triggering the task.

An alternative (if you aren't sending much data) is put it in a struct and rather than using a semaphore, send the data in a queue, and have sender and receiver each keep private copies so they can't corrupt each other.

How to prevent retriggering a task?

The Queue will have practically the same timing as the semaphore. Assuming the processing task is waiting on a queue get (like it was waiting for a semaphore take), as soon as the sending task does a queue send (instead of a semaphore give) the processing task will become ready, and if of higher priority switched to, just like the case of the semaphore.

The one difference will be that if the values sent need to be computed just before the task starts (which you do not currently maintain, which is part of the issue you are having), then the Mutex wi be better as you can't get the Mutex until the processing task is basically done.