Quality RTOS & Embedded Software

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


Loading

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.


[ 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