I really have no idea what I'm talking about, but ... On Sat, Jun 24, 2017 at 10:02 AM, Jia-Ju Bai <baijiaju1...@163.com> wrote: > On 2017/6/23 23:59, Ted Unangst wrote: > >> Jia-Ju Bai wrote: >>> >>> Hi, >>> >>> I am a freshman in developing OpenBSD drivers, and I have a question in >>> lock usage in OpenBSD kernel code. >>> >>> I only find two kinds of locks which are often used in OpenBSD drivers, >>> namely "mutex lock" and "rw lock". I want to know which lock can be held >>> when the current thread can sleep. >>> >>> From my knowledge of OpenBSD document, I only find that "mutex lock" >>> can not be used in this situation. So I have two questions" >>> (1) What about "rw lock"? >>> (2) What about other kinds of locks? >> >> you're on the right track. the rw_init and mtx_init man pages go into this >> in >> more detail and explain the various other options as well. > > > Thanks for reply. > > I have read the man pages of "rw_init": > http://man.openbsd.org/OpenBSD-5.8/rwlock.9 > > But I can not ensure whether the thread can sleep when it holds a "rw lock" > .... > Could you please give me an explicit answer? Thanks in advance :)
In the man page, I see the sentence, The rw_init() function is used to initiate the lock pointed to by rwl. The name argument specifies the name of the lock, which is used as the wait message if the thread needs to sleep. which seems to indicate to my naive reading that it might be possible. I note that my understanding of "busy lock" would lead me to think that would the non-sleep option. -- Joel Rees One of these days I'll get someone to pay me to design a language that combines the best of Forth and C. Then I'll be able to leap wide instruction sets with a single #ifdef, run faster than a speeding infinite loop with a #define, and stop all integer size bugs with my bare cast. http://defining-computers.blogspot.com/2017/06/reinventing-computers.html More of my delusions: http://reiisi.blogspot.com/2017/05/do-not-pay-modern-danegeld-ransomware.html http://reiisi.blogspot.jp/p/novels-i-am-writing.html