Locking fundamentals

2009-05-13 06:03:40来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

From: Duane Whitty
Subject: Locking fundamentals
To:
freebsd-hackers@freebsd.org
Message-ID:
Content-Type: text/plain; charset=us-ascii
Hello again,
It seems to me that understanding locking holds the key to
understanding fbsd internals.
Could someone review my understanding of fbsd locking fundamentals.
(No assertions here, just questions)
    lock_mgr
--------------------
mutexes|sx_lock
-------------------    ^
atomic | mem barriers  |
Don't lock if you don't need to.
Lock only what you need to.
Use the simplest lock that gets the job done.
Don't drop locks prematurely because acquiring locks is expensive.
When possible sleep rather than spin.
??????
Memory barriers order operations
Atomic operations complete without being interrupted
Atomic operations and memory barriers are the primitives.
Mutexes are implemented by atomic operations and memory barriers.
Mutexes are relatively simple and inexpensive but may not recurse.
Shared/exclusive locks are more versatile than mutexes in that they
may be upgraded or downgraded from or to shared/exclusive and they
may be acquired recursively.  More expensive than mutexes.
lock_mgr locks are used when reference counting is needed
?????
Would there be any particular sections of kernel code that you believe
might be enlightening with respects to locking?
I have read the man pages describing each family of locks, John Baldwin's
BSDCon 2002 paper, Jeffrey Hsu's paper, the Arch handbook, and the source.
I don't understand it all yet and it feels like I am missing some
fundamental point, especially concerning the lock_mgr family.  Does
anyone have some pointers they feel like sharing?
Does anyone have any good references they can point me to that is
relevant to fbsd given all the recent changes as a result of SMP?
Is The Design and Implementation of the FreeBSD Operating System
still current enough?
Best Regards,
Duane Whitty
-----------------------------
From: Hans Petter Selasky
Subject: Re: Locking fundamentals
To:
freebsd-hackers@freebsd.org
Cc: Duane Whitty
Message-ID:
Content-Type: text/plain;  charset="iso-8859-1"
On Wednesday 20 December 2006 05:18, Duane Whitty wrote:
> Hello again,
>
> It seems to me that understanding locking holds the key to
> understanding fbsd internals.
>
> Could someone review my understanding of fbsd locking fundamentals.
> (No assertions here, just questions)
>
>      lock_mgr
> --------------------
>   mutexes|sx_lock
> -------------------    ^
> atomic | mem barriers  |

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:还是OpenBSD安装,抄得。

下一篇:NAT—基于OpenBSD的网络地址转换