Skip to Content
Hands-On RTOS with Microcontrollers
book

Hands-On RTOS with Microcontrollers

by Brian Amos
May 2020
Intermediate to advanced
496 pages
13h 54m
English
Packt Publishing
Content preview from Hands-On RTOS with Microcontrollers

When to pass by reference

Since a queue will make a copy of whatever it is holding, if the data structure being queued is large, it will be inefficient to pass it around by value:

  • Sending and receiving from queues forces a copy of the queue element each time.
  • The resulting queue gets very large for large data items if large structures are queued.

So, when there are large items that need to be queued, passing the items by reference is a good idea. Here's an example of a larger structure. After the compiler pads out this struct, it ends up being 264 bytes in size:

mainQueueCompositePassByReference.c:

#define MAX_MSG_LEN 256typedef struct{  uint32_t redLEDState : 1;  uint32_t blueLEDState : 1;  uint32_t greenLEDState : 1; uint32_t msDelayTime; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On RTOS with Microcontrollers - Second Edition

Hands-On RTOS with Microcontrollers - Second Edition

Jim Yuill, Penn Linder

Publisher Resources

ISBN: 9781838826734Supplemental Content