`
javasee
  • 浏览: 965609 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

Locking and Synchronization in Solaris kernel

阅读更多

1. Parallel System Architecture
SMP - Symmetric multiprocessor with a shared memory model; single kernel image
MPP - Message-based model; multiple kernel images
NUMA/ccNUMA - Shared memory model; single kernel images

2. Hardware Considerations for Locks and Syncronization
Consideration:
(1) need For an automatic test-and-set instruction for locking primitives
(2) Data global visibility issue because of the use of hardware load and store buffers and instruction reordering
Solution:
(1) Use of native machine instructions (cmpxchgl on x86)
(2) Use of memory barrier instructions

3. Synchronization Objects in Solaris
(1) mutex lock (exclusive read and write access to data)
(2) read/write lock (multiple readers are allowable but only one writer is allowed)
(3) semaphores (access to a finite number of resources)
(4) dispatcher lock (??)
(5) condition variables (not a type of lock, used for thread syncrhronization and an integral part of the kernel sleep/wakeup facility)

4. Mutex lock
The kernel implements two types of mutex locks: spin locks and adaptive locks. Spin locks spin in a tight loop if a desired lock is being held when a thread attempts to acquire the lock. Adaptive locks are the most common type of lock used and are designed to dynamically either spin or block when a lock is being held, depending on the state of the holder. If the lock holder is running on a processor, the thread attempting to get the lock will spin, otherwise, block (sleep and yield the processor to other threads).
High level interrupts (interrupt levels 11-15) are not allowed to block, so only spin locks can be used in high-level interrupt handlers. Also, spin locks can raise the interrupt level of the processor when the lock is acquired. In a word, spin locks are not allowed to used in any places when sleep and context switch is not allowed.
Mutex lock interface:

mutex_init() initialize a lock, the type of the lock is specified (spin or adaptive)
mutex_enter() accquire the lock
mutex_exit() release the lock

mutex(9F) for more information.

5. Read write lock
The interface for read write lock is:

rw_init() initialize a rw lock
rw_enter() accquire the lock
rw_exit() release the lock

rwlock(9F) for more information

分享到:
评论

相关推荐

    Locking in Linux Kernel

    在Linux内核中,锁机制是确保并发执行的线程之间正确同步的关键工具。它用于保护共享资源,防止数据竞争和不一致状态的发生。对于驱动编写者来说,深入理解锁的原理和用法至关重要,因为驱动程序往往需要访问硬件...

    Adison.Wesley.Linux.Kernel.Development.3rd.Edition.Jun.2010

    In-depth coverage of kernel synchronization and locking Useful insight into submitting kernel patches and working with the Linux kernel community About the Author Robert Love is an open source ...

    Kernel-Locking

    ### Kernel-Locking:深入理解 Linux 内核中的锁定机制 #### 一、引言与并发问题 本书由 Paul Rusty Russell 撰写,是一份关于 Linux 内核锁定技术的指南,它针对 Linux 内核 2.4 版本进行编写。随着对称多处理...

    Oracle Database Transactions and Locking Revealed(Apress,2014).

    Transaction design in turn relies upon a good understanding of how the underlying database platform manages of the locking of resources so as to prevent access conflicts and data loss that might ...

    Biased Locking in HotSpot

    HotSpot虚拟机作为Java平台的主流虚拟机之一,提供了多种锁优化策略,其中之一就是“偏见锁”(Biased Locking)。本文将深入探讨HotSpot中的偏见锁机制,以及它如何提高并发性能。 偏见锁是一种针对轻量级锁的优化...

    Optimistic Locking with Concurrency in Oracle

    乐观锁在Oracle数据库并发控制中的应用 乐观锁是一种在数据库管理系统中实现并发控制的方法,它假设在多数情况下读多写少的情况,因此在读取数据时不会加锁,只有在更新数据时才会检查在此期间是否有其他事务修改了...

    Kernel Locking 中文版

    ### Kernel Locking 中文版 —— 《Unreliable Guide To Hacking The Linux Kernel》中文版 #### 第1章. 引言 欢迎来到Rusty Russell的《不可靠指南:内核锁定》的中文版。这份文档深入探讨了Linux 2.6内核中的锁...

    C++ and the Perils of Double-Checked Locking

    在介绍双检锁模式(Double-Checked Locking Pattern,DCLP)的C++实现中,Scott Meyers和Andrei Alexandrescu在其2004年的文章中指出,传统的单例模式实现并不具备线程安全性。单例模式是设计模式中经常被提及的一种...

    Concurrency Control and Recovery in Database Systems

    《Concurrency Control and Recovery in Database Systems》这本书全面涵盖了数据库系统中的并发控制与数据恢复的理论和实践,是该领域内一部不可或缺的经典之作。通过深入学习本书,读者可以掌握数据库管理的关键...

    Expert SQL Server Transactions and Locking

    This book explains how to troubleshoot and address blocking problems and deadlocks, and write code and design database schemas to minimize concurrency issues in the systems you develop

    《Expert SQL Server Transactions and Locking》源码

    《Expert SQL Server Transactions and Locking》是一本专为SQL Server数据库管理员和开发人员编写的权威指南,涵盖了事务处理和锁定机制这两个核心主题。这本书的源码提供了深入理解这些概念的实际示例,对于学习和...

    C++ and the Perils of Double Checked Locking.zip

    《C++ and the Perils of Double Checked Locking》是一篇探讨C++编程中双重检查锁定(Double-Checked Locking)模式潜在问题的文献。在多线程编程中,双重检查锁定是一种常见的优化策略,旨在减少对同步原语的依赖...

    Sybase Performance and Tuning:locking

    在Sybase数据库管理系统中,锁定(Locking)是实现并发控制的关键技术之一。本文档基于Sybase Adaptive Server Enterprise 12.5.1版本,深入探讨了锁定机制在数据库性能与调优中的作用及其相关知识点。 #### 二、...

    Mode-locking of a terahertz laser by direct phase synchronization

    标题与描述均提到了“通过直接相位同步实现太赫兹激光器的模式锁定”,这是一项在太赫兹科学领域的重要技术突破。太赫兹(THz)波段位于微波与红外光之间,频率范围大约在0.1到10THz,具有独特的优势,如非电离性、...

    Biased Locking in HotSpot - Dave - 2006.pdf

    知识点一:偏向锁(Biased Locking)的起源 偏向锁的概念源自于一篇由Dave、Mark Moir和Bill Scherer共同撰写的论文。作者们指出,传统的Java监控锁(即synchronized锁)在执行CAS操作(比较并交换)时会带来显著的...

    multiprocessor_Synchronization_lecture19_0520.pdf

    接着,文档涉及了多个同步主题:“Mutual exclusion and locks”、“Waiting and signaling”、“Wait-free synchronization”和“Transactional memory”。这些是实现多处理器同步时常常涉及的几个关键概念。 ...

    Java.Threads.and.the.Concurrency.Utilities.1484216997

    In Part 1, you learn about Thread API basics and runnables, synchronization and volatility, waiting and notification, and the additional capabilities of thread groups, thread local variables, and the...

Global site tag (gtag.js) - Google Analytics