Let the same piece of physical memory be mapped to the respective process address spaces of process A and process B. Process A can immediately see process B’s update of the data in the shared memory; Steps to use shared memory 1. The process calls the shmget function to create new or obtain existing shared […]
Tag: interprocess
Processes, Threads, and Interprocess Communication – Signals
signal Signal mechanism The signal is a simulation of the interrupt mechanism at the software level, and it is an asynchronous communication method. The Linux kernel notifies the user process through the signal, and different signal types represent different events. Linux extends the early unix signal mechanism Signal generation: 1 keystroke spawns 2 System call […]
Processes, Threads, and Interprocess Communication – Thread Mutex
Thread Communication – Mutual Exclusion critical resource A shared resource that only one task (process, thread) can access at a time Critical section Code that accesses critical resources Mutual exclusion mechanism mutex mutual exclusion lock Tasks apply for locks before accessing critical resources, and release locks after accessing Mutex initialization – pthread_mutex_init #include <pthread.h> int […]
LinuxC interprocess communication — pipe
nameless pipe 1. The kernel will open up a “pipe”, and the communication process will realize communication by sharing this pipe. code show as below: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> int fd[2]; void read_msg(int sig) { char buffer[1024] = {0}; read(fd[0], buffer, sizeof(buffer)); printf(“buffer […]
Processes, Threads, and Interprocess Communication – Interprocess Communication
Interprocess Communication (IPC, InterProcess Communication) Concept: It is the exchange of information between processes. Common communication methods Unnamed pipe (pipe) Famous pipes (fifo) signal shared memory (mmap) socket Outdated IPC communication method System V IPC shared memory message queue Semaphore set Anonymous pipe Anonymous pipeline features Anonymous pipes have the following characteristics: Can only be […]
io thread-7 interprocess communication-system IPC
ftok: #include key_t ftok(const char *pathname, int proj_id); Function: Generate a complex value from a simple value given by a parameter Return value: Returns the generated key successfully, returns -1 on failure pathname: the file name will use the inode node number of the file proj_id: just enter a value 1. Shared memory Directly read […]
Linux source code analysis – interprocess communication – shared memory
In the Linux system, each process has an independent virtual memory space, that is to say, the data obtained by different processes accessing the same virtual memory address is different, because the same virtual memory address of different processes will be mapped to at different physical memory addresses. But sometimes, in order to communicate between […]
Python single inheritance, multiple inheritance, @property, exception, file operation, thread and process, interprocess communication, TCP framework 7.24
Single inheritance class luban: def __init__(self, name): self.name = name self.skill = “Fishing Missile” self. damageLevel = 20 def attack(self): print(“{} used the skill {}, causing great trouble to the enemy\ ” “And has a {}% chance to cause a one-hit kill effect”.format(self.name, self.skill, self.damageLevel)) class luban7(luban): pass # __name__ : Magic method: similar to […]
Linux interprocess communication (fifo famous pipe)
Article directory foreword 1. Explanation of the concept of famous pipelines 2. Create fifo from the command line 3. Create fifo without command line Four, fifo and pipeline comparison Summarize Foreword In the last article, we explained the unnamed pipeline. In this article, we will explain the famous pipeline. 1. Explanation of the concept of […]