Tag:Semaphore
-
GCD bottom layer analysis (III): fence, semaphore, dispatching group and source
1、 Fence function CPUThe ability of out of order execution makes our efforts to ensure the safety of multithreading extremely difficult. Therefore, to ensure thread safety, preventCPUReordering is required. Unfortunately, there is no portable way to prevent reordering. Usually it is calledCPUProvides an instruction that is often referred to asbarrier。 OnebarrierCommand will blockCPUSwap the instructions […]
-
Hongmeng light kernel source code analysis: master the differences in semaphore usage
Summary:This article leads you to analyze the source code of the semaphore module of Hongmeng light kernel, including semaphore structure, semaphore pool initialization, semaphore creation and deletion, application for release, etc. This article is shared from Huawei cloud community《Hongmeng light kernel m core source code analysis series 11 semaphore》, original author: zhushy. Semaphore is a […]
-
The interviewer asked me to use channel to realize the synchronization lock in the sync package. Did he deliberately embarrass me?
preface The go language provides two concurrency control methods: channel and sync package. Each method has its applicable scenario. Not all concurrency scenarios are suitable for channel application. Sometimes it is easier to use the synchronization primitive provided in the sync package. Today’s topic is purely to learn and master the powerful capabilities of channel […]
-
(25) springcloud hystrix resource isolation strategy (thread and semaphore) for Java spring cloud enterprise rapid development architecture
There are two resource isolation strategies of hystrix: thread pool and semaphore. Why do we need resource isolation? Recommend the source code of split architecture In a distributed system, services call each other. For example, the number of threads configured in our container (Tomcat) is 1000, service a-service R, in which the concurrency of service […]
-
Java distributed lock redisson usage
This article is transferred from: Le byte Main explanation: redisson For more Java related information, you can follow the official account Le byte. Send: 999 Let’s take a look at the statement of redis official website on distributed locks: Redisson is the framework of distributed locks in Java. 1、 What is redisson? If you used […]
-
IOS multithreading swift GCD III: dispatch source, semaphore
This part is almost indistinguishable from the GCD of OC; But first, by comparing a lot of macro definitions of OC (dispatch_time_now, nsec_per_sec, etc.), swift is obviously easier to readDispatch source, a scheduling resource, is used to coordinate the processing of underlying system events. When receiving a specified system signal, it executes tasks in a […]
-
Implementation of circular queue in C + + buffer pool
Undertake the task of last week. The purpose effect is that the writing thread writes the data to the buffer, and the reading thread obtains the data in the buffer. buffer data structure The so-called buffer is to open up a section of memory space to save data. The main attributes include the memory space […]
-
0.0.1, dealloc block, tell a story, IOS interview questions
1. Opening This paper attempts to answer the following questions: When an object is used instead of an alldeoc method Not class level control, but object level control 2. Associated object 3. Lock This article is the second part of the interview This article has reference c/ CYLDeallocBlockExecutor 1. How to make good use of […]
-
Multi process dual buffer read and process
Title Requirements Write two C language programs under Linux platform to realize the following functions:(1) X and Y processes cooperate with each other to process the data in the input file, and write the processing results to the output file.(2) The X process is responsible for reading the input file in blocks and transferring the […]
-
Mutually exclusive locks commonly used by Swift
@Synchronized is the thread mutex method in OC. Swift corresponds to objc_ sync_ Enter (self) and objc_ sync_ exit(self)。The parameters in the method can only make self, and other parameters cannot achieve the purpose of mutual exclusion. @objc private func remove() { print(“\(Thread.current)::\(array.count)”) //Mutex objc_sync_enter(self) while array.count > 0 { array.removeLast() print(“\(Thread.current)::\(array.count)”) } print(“\(Thread.current)::\(array.count)”) objc_sync_exit(self) […]
-
Analyzing the working mechanism of hystrix from the source code
1、 What problem did hystrix solve? There are many dependencies in complex distributed applications, and each dependency will inevitably fail at some time. If the application does not isolate each dependency and reduce external risks, it is easy to bring down the whole application. Take a common example in e-commerce scenarios. For example, the order […]
-
Semaphore confesses: I’m right to use the current limiter!
Hello, I’m semaphore. My Chinese name is “semaphore”. I’m from the JUC (Java. Util. Concurrent) family. Our family has many excellent members, such as:Countdownlatch (wait for other threads to execute before executing a thread),Cyclicbarrier (loop blocks a group of threads until an event is reached)Of course, I’m no weaker than them ω Oh, yeah. The […]