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

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) 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