Process (daemon process–mutex lock–IPC mechanism–producer model–zombie process and orphan process–simulated ticket grabbing–message queue)…

Table of contents 1: Process theoretical knowledge 1.Theoretical knowledge 2: What is a process? Three: Zombie processes and orphan processes 1. Zombie process Four: Daemon process 1. What is a daemon process? 2. The main process creates a daemon process 3.Daemon process Five: Mutex lock (simulating multi-person ticket grabbing) 1.What is a lock? 2. What […]

Go language concurrent programming essentials: in-depth mastery of Mutex mutex locks

In concurrent programming, we need to deal with the simultaneous access of shared resources by multiple threads. If shared resources are accessed simultaneously without control, it will cause race condition problems, causing unpredictable errors in the program. In order to solve this problem, the Go language provides the sync package, which includes synchronization mechanisms such […]

Linux thread synchronization, mutex locks, deadlock avoidance, condition variables

1. Overview of thread synchronization Thread synchronization definition Thread synchronization refers to controlling the relative execution order between multiple threads so that data can be shared correctly and orderly between threads. The following are common usage scenarios for thread synchronization. Tasks executed by multi-threads have sequential dependencies Data shared between threads can only be used […]

Mutex locks and condition variables

Synchronization is necessary in order to allow data to be shared between threads or processes. Mutex locks and condition variables are the basic components of synchronization. 1. Mutex lock Mutex locks are used to protect critical section resources. In fact, they protect the data manipulated in the critical section. Mutex locks are usually used to […]

Linux thread mutex lock (Mutex)

Linux mutex lock 1. Header file 2. Type 2.1. Type value 2.2. Mutex locks and attribute types 3. Interface 3.1. Mutex lock interface 3.1.1 Dynamic initialization of resources 3.1.2. Dynamically releasing resources 3.1.3. Mutex lock attempt 3.1.4. Mutex locking 3.1.5. Mutex locking with timeout 3.1.6. Unlocking the mutex lock 3.2. Mutex property interface 3.2.1. Property […]

System programming six: thread synchronization mutual exclusion + named semaphore + unnamed signal + mutex lock

Problem introduction: Example: Two threads access a certain memory space at the same time, resulting in data trampling. #include<stdio.h> #include <pthread.h> int g_val = 0; //The routine function of the thread, that is, after creating the thread, execute this function void* routine1(void *arg) { g_val = 100; sleep(1);//Delay 1 second, then thread 2 will be […]

Multithreading and concurrent programming (3)-mutex lock implemented by AQS and ReentrantLock

1. Pipe process model-MESA model What is a management process? The monitor refers to the management of shared variables and related operations on shared variables. In the history of tube process development, three different tube process models have appeared successively, namely Hasen model, Hoare model and MESA model. What is now widely used is the […]

Thread mutex (mutex)

Overview Threads need to access some shared resources. In order to ensure orderly access to shared resources and prevent competition, shared resources need to be protected in some way to enable orderly access to shared resources. Thread mutexes are used to implement thread A means of mutual exclusion. typedef union { struct __pthread_mutex_s __data ; […]