Current location - Quotes Website - Signature design - What linux kernel locks are there?
What linux kernel locks are there?
What does the 2k2 new kernel choose?

It is recommended to choose locking C or rebound C, and locking sg and sf can also be selected at other positions.

Spin lock Spin lock principle?

Rotary lock (rotary lock)

A spin lock is similar to a mutex lock except that it does not cause the caller to sleep. If the spin lock is already held by other execution units, the caller will always loop there to see if it is held.

No, the holder of the rotating lock has released the lock, hence the name "rotating". Its function is to solve the mutually exclusive use of a resource. Spin lock is more effective because it does not cause the caller to sleep.

Above mutual exclusion. Although it is more effective than mutex, it also has some disadvantages:

1, spin lock always takes up CPU. He kept running -spin without getting a lock, so he took up the CPU. If you can't get the lock in a short time, it will undoubtedly reduce CPU efficiency.

2. It may cause deadlock when using spin lock, deadlock when calling recursively, and deadlock when calling other functions, such as copy_to_user (), copy_from_user (), kmalloc (), etc.

Therefore, we should use spin lock carefully. Only when the kernel is preemptive or SMP does it really need spin lock. Under single CPU and nonpreemptive kernel, the operation of spin lock is empty. The rotary lock is suitable for lock users to keep the lock for a short time.

Locking principle of two kinds of locks

Mutex lock: thread will lock from sleep->; Running (unlocking) has the overhead of context switching, cpu preemption, signal sending, etc.

Spin lock: the thread is always running (locking->; Unlock), infinite loop detects the flag bit of the lock, and the mechanism is not complicated.

Mutex locks belong to sleep waiting locks. For example, there are two threads (thread A and thread B) on a dual-core machine, running in Core0 and Core 2 respectively.

On Core 1 Suppose that thread A wants to obtain a lock of a critical section through pthread_mutex_lock operation, and this lock is being held by thread B at this time, then thread A will be blocked.

What is a Bm lock?

Bm lock, BootLoader, is a small program that runs before the operating system kernel runs. It is responsible for loading the hardware initialization program and starting the system process when it is turned on, just like the bios of a computer.

What does it mean to unlock the bl lock?

Unlocking BL lock is short for bootloader, which is Bootloader lock. It mainly checks the system signature, kernel signature and recovery signature during the boot process, and terminates the boot if the signatures are inconsistent.

How to unlock the Samsung mobile phone kernel lock?

1. Enter the mobile phone interface and click Set Universal Password Lock.

; 2. After entering the password for the last screen lock, enter the menu and select "Close Password". Enter the password again to close the screen lock.

3. If you forget the password, you can only restore the phone to the factory settings through itunes, but all the information in the phone will be emptied.