Linux multi-threaded programming-unnamed semaphore

Introduction An unnamed semaphore (usually a semaphore of type sem_t in a POSIX environment) is a primitive for synchronization and mutual exclusion, which allows threads and processes to execute in the expected order and ensures access to shared resources. secure access. The main difference between unnamed semaphores and named semaphores is their visibility and lifetime. […]

8. Counting semaphore Semaphore

1. Preface Starting from this section, we learn a new chapter – synchronization tools. This section will introduce you to the first commonly used Java concurrency tool class, Semaphore. This section first explains what the Semaphore semaphore is through a real-life example, and then introduces the most basic usage of the Semaphore tool class. After […]

FreeRTOS source code understanding (8) – semaphore

FreeRTOS source code understanding (1) – FreeRTOS ideas sorting out FreeRTOS source code understanding (2) – interrupts and list items FreeRTOS source code understanding (3) – task FreeRTOS source code understanding (4) – task scheduler FreeRTOS source code understanding (5) – task switching FreeRTOS source code understanding (6) – time management FreeRTOS source code understanding […]

Linux multithreaded programming – named semaphore

Basic concepts Named semaphore is a synchronization primitive mainly used for inter-process synchronization and communication. They are visible between different processes and can therefore be used to control access to shared resources by multiple processes. The following is a detailed introduction to named semaphores: 1. Basics: Semaphore value: A non-negative integer that usually represents the […]

Mutex locks, condition variables, semaphores and applicable scenarios

Article directory mutex lock Commonly used methods in the actual combat of mutex locks condition variable Commonly used methods in the actual combat process of condition variables signal Common methods of semaphores producer and consumer issues A rough version of the producer-consumer code (if only mutexes were used) An improved version of the producer-consumer code […]

[Common c/c++] Producer-consumer model using mutex/cv/semaphore

Foreword: The producer-consumer model is a commonplace topic, and there are various implementation methods. The operating efficiency of different methods is also very different. It is difficult to balance factors such as code simplicity, data security, operational stability, and operational performance. Basic model -> Large-granularity lock + busy waiting (high efficiency, high CPU) Component: mutex […]

FreeRTOS semaphores and task synchronization – 3 mutually exclusive semaphores

1. Mutually exclusive semaphore A mutex semaphore is a special binary semaphore used to control access to shared resources between two or more tasks. Mutex semaphores provide a priority inheritance mechanism that raises the priority of the task holding the mutex semaphore to the priority of the task waiting for the mutex semaphore. Unlike binary […]

FreeRTOS semaphore and task synchronization-1 binary semaphore

Semaphore is a messaging mechanism used by the operating system to implement resource management and task synchronization. FreeRTOS semaphores are divided into binary semaphores, counting semaphores, mutual exclusion semaphores and recursive mutual exclusion semaphores. A mutually exclusive semaphore can be regarded as a special binary semaphore, but there are some differences between mutually exclusive semaphores […]

Embedded Linux application development – driver collection – synchronization and mutual exclusion ④ implementation of spin lock/semaphore/mutex

Embedded Linux application development-driver collection-synchronization and mutual exclusion ④ implementation of spin lock/semaphore/mutex Chapter 1 Synchronization and Mutual Exclusion④ 1.5 Implementation of spinlock spinlock 1.5.1 Spin lock kernel structure 1.5.2 Implementation of spinlock in UP system 1.5.3 Implementation of spinlock in SMP system 1.6 Implementation of semaphore 1.6.1 Kernel structure of semaphore 1.6.2 Implementation of […]

STM32F4X UCOSIII task semaphore

STM32F4X UCOSIII task semaphore Comparison between task semaphore and kernel semaphore Kernel semaphore task semaphore UCOSIII task semaphore API Task semaphore sending function Task semaphore receiving function UCOSIII task semaphore routine The semaphore mechanism was explained in the previous chapter. In addition to the kernel semaphore, UCOSIII also has task semaphores. In UCOSIII, there is […]