![]() ![]() For the start let's consider how a normal spinlock is implemented. We may see that the ARCH_USE_QUEUED_SPINLOCKS is enabled by default in the x86_64 specific kernel configuration file - arch/x86/Kconfig: config X86īefore we start to consider what queued spinlock concept is, let's look on other types of spinlocks. This means that the CONFIG_QUEUED_SPINLOCKS kernel configuration option will be enabled by default if the ARCH_USE_QUEUED_SPINLOCKS is enabled. If we will look at the following kernel configuration file - kernel/Kconfig.locks, we will see following configuration entries: config ARCH_USE_QUEUED_SPINLOCKS At least this is true for the x86_64 architecture. Queued spinlocks is a locking mechanism in the Linux kernel which is replacement for the standard spinlocks. spin_is_locked - returns the state of the given spinlock Īnd we know that all of these macros with the arch_* prefix which are defined in the include/linux/spinlock.h header file will be expanded to the call of the functions from the include/asm-generic/qspinlock.h: # define arch_spin_is_locked(l) queued_spin_is_locked(l) # define arch_spin_is_contended(l) queued_spin_is_contended(l) # define arch_spin_value_unlocked(l) queued_spin_value_unlocked(l) # define arch_spin_lock(l) queued_spin_lock(l) # define arch_spin_trylock(l) queued_spin_trylock(l) # define arch_spin_unlock(l) queued_spin_unlock(l)īefore we consider how queued spinlocks and their API are implemented, let's first take a look at the theory.spin_unlock_bh - releases given spinlock and enables software interrupts.spin_unlock - releases given spinlock and acquire given spinlock.spin_lock_irqsave and spin_lock_irq - disable interrupts on local processor and preserve/not preserve previous interrupt state in the flags.spin_lock_bh - disables software interrupts and acquire given spinlock.spin_lock_init - produces initialization of the given spinlock.We saw the API of spinlock in the previous part: Here we will try to understand what this concept represents. If you have read the previous part, you may remember that besides normal spinlocks, the Linux kernel provides a special type of spinlocks - queued spinlocks. We will continue to learn about this synchronization primitive here. In the first part of this chapter we meet the first spinlock. This is the second part of the chapter which describes synchronization primitives in the Linux kernel. Synchronization primitives in the Linux kernel. Write and Submit your first Linux kernel Patch How the Linux kernel handles a system call ![]() Initialization of external hardware interrupts structures Implementation of some exception handlers Initialization of non-early interrupt gates Last preparations before the kernel entry pointĬontinue architecture-specific boot-time initializationsĪrchitecture-specific initializations, again.Įnd of the architecture-specific initializations, almost. The above method also makes your critical sections very short because all you do while the mutex is locked is std::list splicing, which is just a few pointer modifications.Īlternatively, just use concurrent_bounded_queue class from Intel® Threading Building Blocks.Video mode initialization and transition to protected mode
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |