Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists