Chapter 18

Resource Sharing

Abstract

Tasks can share resources in various ways. Multiple threads within the same process can share global variables, through which data can flow back and forth among them. File or memory region objects can be shared via memory mapping by multiple processes. The integrity of an exclusive resource can be endangered when multiple tasks gain access to it at the same time. Semaphore, mutex, and condition variable are POSIX objects that are normally used to protect the integrity of shared resources. For each type of these POSIX objects, we explain the corresponding POSIX functions, examine their usage patterns, and give a few running examples.

Keyword

Shared variables

Shared memory object

Semaphore

Mutex

Condition ...

Get Real-Time Embedded Systems now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.