What was solved
accomplish
down_read/up_read
kernel/locking/rwsem.c
down_read
LOCK_CONTENDED(sem, __down_read_trylock, __down_read);
include/linux/lockdep.h
449 #define LOCK_CONTENDED(_lock, try, lock)
450 lock(_lock)
kernel/locking/rwsem.c
1220 static inline void __down_read(struct rw_semaphore *sem)
1221 {
1222 __down_read_common(sem, TASK_UNINTERRUPTIBLE);
1223 }
1205 /*
1206 * lock for reading
1207 */
1208 static inline int __down_read_common(struct rw_semaphore *sem, int state)
1209 {
1210 long count;
1211
1212 if (!rwsem_read_trylock(sem, &count)) {
1213 if (IS_ERR(rwsem_down_read_slowpath(sem, count, state)))
1214 return -EINTR;
1215 DEBUG_RWSEMS_WARN_ON(!is_rwsem_reader_owned(sem), sem);
1216 }
1217 return 0;
1218 }
235 static inline bool rwsem_read_trylock(struct rw_semaphore *sem, long *cntp)
236 {
237 *cntp = atomic_long_add_return_acquire(RWSEM_READER_BIAS, &sem->count);
238
239 if (WARN_ON_ONCE(*cntp < 0))
240 rwsem_set_nonspinnable(sem);
241
242 if (!(*cntp & RWSEM_READ_FAILED_MASK)) {
243 rwsem_set_reader_owned(sem);
244 return true;
245 }
246
247 return false;
248 }
include/asm-generic/atomic-long.h
556 static __always_inline long
557 atomic_long_add_return_acquire(long i, atomic_long_t *v)
558 {
559 return atomic_add_return_acquire(i, v);
560 }
down_write/up_write
down_write
LOCK_CONTENDED(sem, __down_write_trylock, __down_write);
__down_write
__down_write_common
rwsem_write_trylock
atomic_long_try_cmpxchg_acquire
Previous article:OK6410A development board (VII) 4 arm cross-compilation chain manufacturer
Next article:OK6410A Development Board (VIII) 76 linux-5.11 OK6410A Implementation of linux kernel synchronization mechanism sequence lock
Recommended ReadingLatest update time:2024-11-15 09:26
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- 【Competition Information】Document download: RSL 10_add profiles & RSL 10_IDE_installation
- LORA CAD channel activity detection
- The Problem with Fully Differential Op Amp Output Voltage Rails
- Take a break and have a laugh
- EEWORLD University - Master the basic knowledge and artistic design of high-voltage gate driver design
- MSP430F149 uses JTAG and BSL to download configuration diagram
- What are the ideas for making lyrics display screen?
- Analysis of common problems with DTU
- Why does the waveform oscillate after amplification?
- What the heck is uC/OS? What is it for?