![]() ![]() If the pthread_spin_lock, Returns the EDEADLK Errors or other errors, Or the caller may permanently spin. Int pthread_spin_unlock(pthread_spinlock_t *lock) ġ) If the spin lock is currently unlocked ,pthread_spin_lock Don't spin, You can lock it Ģ) If the spin lock is currently locked, The result of re obtaining the lock is undefined. Int pthread_spin_trylock(pthread_spinlock_t *lock) Int pthread_spin_lock(pthread_spinlock_t *lock) Int pthread_spin_destroy(pthread_spinlock_t *lock) Int pthread_spin_init(pthread_spinlock_t *lock, int pshared) Because the interrupt handler cannot sleep, Only this kind of lock can be used shortcoming :ġ) Thread spin waits for the lock to become available ,CPU You can't do anything else, Will waste CPU resources Pseudo code S = 1 Applicable scenario :ġ) The lock is held for a short time, And threads don't want to spend too much on rescheduling Ģ) In a non preemptive kernel, Will block interrupt, In this way, the interrupt handler will not cause the system to deadlock. Spin locks are usually used as underlying primitives to implement other types of locks. This busy wait blocking state, Also called spin. ![]() Spinlocks are similar to mutexes, However, spinlocks do not block processes through sleep, Instead, it is in a blocking state of busy waiting until the lock is obtained. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |