Quality RTOS & Embedded Software

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




Loading

It's really need cRxLock and cTxLock in Queue struct?

Posted by ctc8631 on June 5, 2017

Hello, I'm keep learning FreeRTOS source code, But in queue.c, I'm not really understand why need cRxLock and cTxLock, I know that in send or receive function it can lock rx and tx when it check the timeout, and in this situation the ISR event will record in cRxLock and cTxLock, after checking timeout, it will check Lock value and release lock.

But I think the check timeout is not really long, why just put check into critical section, then there is no need to use cRxLock and cTxLock and save release lock which is not short execute

I think maybe there is a key to design Lock, can anyone give me some hint, thanks


It's really need cRxLock and cTxLock in Queue struct?

Posted by rtel on June 5, 2017

As I recall the rx and tx locks are used to allow queues to be used from tasks and interrupts at the same time. If a queue is locked then an interrupt using the queue knows it can modify some data structures but not others - the structures it can't modify are then modified from the task level when the queue is unlocked. So:

1) A task locks a queue and starts accessing it. 2) An interrupt uses the queue, but noticing it is locked, does not complete the queue operation. 3) When the task unlocks the queue it notices an interrupt also accessed the queue and completes the operation the interrupts started.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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