OK6410A Development Board (VIII) 77 linux-5.11 OK6410A Implementation of Linux kernel synchronization mechanism read and write semaphores

Publisher:脑力激荡Latest update time:2022-08-18 Source: csdnKeywords:OK6410A Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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

Keywords:OK6410A Reference address:OK6410A Development Board (VIII) 77 linux-5.11 OK6410A Implementation of Linux kernel synchronization mechanism read and write semaphores

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

802.11ay RF supplier Pharrowtech receives 15 million euros in Series A funding
Pharrowtech, a provider of millimeter wave hardware and software for next-generation wireless applications, has announced the completion of a €15 million Series A funding round to continue developing next-generation 60GHz wireless RF transceiver and antenna technology.  The round was led by Netherlands-based investo
[Network Communication]
Intelligent ultrasonic liquid level transmitter designed using LPC2119 chip CAN bus and DSl8B20
0 Preface Fieldbus is a fully distributed, fully digital, intelligent, two-way, interconnected, multi-variable, multi-point, and multi-station communication network used between field instruments, control systems and control rooms. CAN (Controller Area Network) is a serial data communication protocol proposed by the G
[Microcontroller]
Intelligent ultrasonic liquid level transmitter designed using LPC2119 chip CAN bus and DSl8B20
LPC1114 watchdog_how to start and feed the dog
The function code for starting the watchdog timer is as follows: void WDT_Enable(uint8_t mode) {    LPC_SYSCON- PDRUNCFG &= ~(0x1 6); // Watchdog oscillator clock power-on (bit6)    LPC_SYSCON- WDTOSCCTRL = (0x1 5); // WDT_OSC_CLK=300KHz    LPC_SYSCON- WDTCLKSEL = 0x2; // Select watchdog oscillator clock    LPC_
[Microcontroller]
Jiwei Index fell 0.18% Huatian Technology's revenue target for this year reached 11.6 billion yuan
According to Jiwei.com, the three major A-share indexes closed down slightly today, and the market trading volume shrank. The two markets traded a total of 687.4 billion yuan. Industry sectors rose and fell, with the environmental protection engineering sector leading the gains. Northbound funds sold a net of 7.903 bi
[Mobile phone portable]
Jiwei Index fell 0.18% Huatian Technology's revenue target for this year reached 11.6 billion yuan
Features and application scope of 6113 multifunctional electrical device tester
Features: • The multifunctional electrical installation tester integrates all electrical testing functions in one unit. With its excellent testing performance and friendly ergonomic design, it provides unprecedented simple, fast and intelligent electrical testing solutions. • Testing and inspection of low voltage elec
[Test Measurement]
TSMC: Submit business data to the United States before November 8
On October 8, the U.S. Department of Commerce held a semiconductor summit on September 23, attended by TSMC, Intel, Samsung, Micron and other industry giants. According to Korean media reports, in the face of chip shortages, the U.S. Department of Commerce asked TSMC, Samsung and other semiconductor companies to hand
[Mobile phone portable]
Honor Magic4 Pro uses NXP's SN110 eSIM solution
Recently, NXP said that the company's SN110 series eSIM helps Honor smartphone applications in Europe and other overseas markets, and can perform multiple mobile services at the same time. GSMA-compliant and certified eSIM solutions make it fundamentally easier for device manufacturers to provide consumers with cellul
[Mobile phone portable]
Has NCM811 battery become the new favorite of car companies?
There are many factors that affect the range of new energy vehicles: body design (wind resistance, lightweight, etc.), three-electric system (battery, motor, electronic control), environmental factors (climate, temperature), and even the driver's driving habits. From a certain perspective, this is a "metaphysics". But
[Automotive Electronics]
Has NCM811 battery become the new favorite of car companies?
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号