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] [February 2016 Threads] How to prevent retriggering a task?Posted by gerhardkreuzer on February 4, 2016 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.
Task skeleton:
task
{
take (smphrtrigger);
FOREVER
{
Take(smphrtrigger);
//Do something
}
}
void triggerTask()
{
xy = 4711;
Give(smphr_trigger);
}
Thanks for helping
With best regards
Gerhard
How to prevent retriggering a task?Posted by davedoors on February 4, 2016 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?Posted by gerhardkreuzer on February 4, 2016 .. 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?Posted by richard_damon on February 5, 2016 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?Posted by gerhardkreuzer on February 5, 2016 Thanks. As the point in time has to be exect as possible (trigger), a queue isn't that good idea, so I choose to use a mutex
With best regards
Gerhard
How to prevent retriggering a task?Posted by richard_damon on February 6, 2016 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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|