Synchronization Quest: Understanding the differences and applications of System V and POSIX semaphores

Directory title 1. Introduction 1.1 Overview of the importance of semaphores 1.2 Purpose of this article: Compare System V and POSIX semaphores 2. Basics of Semaphores 2.1 Definition and Function of Semaphores 2.2 The role of semaphores in process synchronization (Role in Process Synchronization) Synchronization and Mutual Exclusion The similarity between the psychology of semaphores […]

Teach you step by step how to develop a map APP using COMPOSE~

Translated from: https://www.darrylbayliss.net/jetpack-compose-for-maps/ Foreword It’s hard to imagine that Jetpack Compose 1.0 was released back in July 2021. https://android-developers.googleblog.com/2021/07/jetpack-compose-announcement.html Now two years later, 24% of the top 1,000 apps on Google Play have adopted the new technology Compose, and its influence is evident. https://android-developers.googleblog.com/2023/05/whats-new-in-jetpack-compose.html As a member of the MAD (Modern Android Development) philosophy, Jetpack […]

[C++]: Use of associative container map

Table of Contents 1. Introduction to map 2. Initialization of map 2.1. Method 1 2.2. Method 2 2.3. Method 3 3. Comparison of map sorting (functor) 4. Use of common built-in functions of map 4.1 Iterator 4.2 Capacity 4.3 Element access 3.4Modifier 3.5 Operation 5. Map traversal (iteration) 5.1 Iterator 5.2 Scope for Summarize 1. […]

Linux kernel critical section, mutex, semaphore

1. Critical section: Access public resources or a piece of code through serialization of multi-threads. It is fast and suitable for controlling data access. 2. Mutex: Designed to coordinate individual access to a shared resource. 3. Semaphore: Designed to control a resource with a limited number of users. Critical Section A simple way to ensure […]

Using eBPF to detect mmap leaks

Table of Contents background Official website malloc leak detection mmap leak detection Call munmap to release memory summary Background We know that the memory space requested by the mmap system call belongs to the file mapping area and the anonymous mapping area. This part of the area does not belong to the heap, so it […]

Java collection ConcurrentHashMap What is the difference between how to use each method and HashMap through source code analysis?

Table of Contents Hello friends, today I will analyze the thread-safe hashmap. The main features of ConcurrentHashMap include: ConcurrentHashMap example Let’s take a look at the source code of the size(), containsKey(), and replace() methods. Okay, let’s continue to look at the replace method. The first thing is to check whether a null pointer exception […]

Experiment 4-Implementation and application of semaphore

Implementation and application of semaphore Corresponding experiment manual: https://hoverwinter.gitbooks.io/hit-oslab-manual/content/sy4_sem.html Supplementary knowledge Semaphore operations Reference links: https://c.biancheng.net/view/8632.html https://www.cnblogs.com/Suzkfly/p/14351449.html head File: #include<fcntl.h> #include<sys/stat.h> #include<semaphore.h> Operation function: //Open the named semaphore sem_t * sem_open(const char * name, int oflag, mode_t mode, unsigned int value); //Close the semaphore int sem_close(sem_t * sem); //Delete semaphore file int sem_unlink(const cahr * […]

Data structure: unordered_map and unordered_set

Table of Contents 1.Framework 2. Structure unordered_map unordered_set 3. Modifications to HashTable Change template parameters 4. Add an iterator a. Structure b. Operator overloading c.HashTable encapsulates iterator d.Iterators of unordered_map and unordered_set 1.Frame 1. Reuse HashTable ~~> Add template parameter KeyOfT to obtain Key value unordered_map passes K, V unordered_set passes K 2. Add iterator: […]

Spring injects Beans into List/Map

Table of Contents Spring injects Beans into List/Map Inject into List Inject into Map Summarize Spring injects Bean into List/Map In the Spring framework, we often need to use collection types (such as List, Map, etc.) to store a set of Bean objects in applications. Through Spring’s dependency injection feature, we can easily inject multiple […]

Vuex: Helper functions: mapState, mapMutations, mapActions, mapGetters: VOA mode

Description Vuex provides four commonly used auxiliary functions: the purpose is to map the corresponding data and functions in state(), mutaions{}, actions{}, getters{} in vuex, so that we can be more flexible in the component. Simply use these data and functions mapState mapMutations mapActions mapGetters Usage cases /src/store/index.jsState Manager import axios, { Axios } from […]