What Happens When a Deadlock Occurs in Linux Driver Code?

When writing a “dead loop” in the Linux kernel (<span><span>while(1);</span></span> or <span><span>for(;;);</span></span>), what happens depends on three key factors: On which CPU the code runs and at what priority (interrupt context or process context); Whether kernel preemption is enabled; Whether the CPU is responsible for maintaining system heartbeat (tick, RCU, scheduling clock, IPI, etc.). Let’s … Read more

Bilibili C++ Interview: Differences Between Mutex and Spin Lock, and Their Use Cases

Bilibili C++ Interview: Differences Between Mutex and Spin Lock, and Their Use Cases

In multithreaded programming, synchronization mechanisms are essential for ensuring safe access to shared resources.Mutexes and Spin Locks, as the two most classic types of locks, are widely used in various systems and frameworks.This article will comprehensively analyze the differences between the two from the perspectives of underlying implementation principles, waiting strategy differences, performance overhead analysis, … Read more