Project

General

Profile

Actions

Bug #908

closed

mention msleep() in porting_drivers.txt

Added by aoiko over 16 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
Documentation
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Any suggestions on how to make this clearer are welcome.

Index: notes/porting_drivers.txt ===================================================================
RCS file: /home/aggelos/imports/vcs/dcvs/doc/notes/porting_drivers.txt,v
retrieving revision 1.3
diff u -p -u -r1.3 porting_drivers.txt
--
notes/porting_drivers.txt 29 Dec 2007 18:35:59 -0000 1.3
+++ notes/porting_drivers.txt 6 Jan 2008 17:40:24 -0000
@ -84,6 +84,24 @ $DragonFly: doc/notes/porting_drivers.tx
call is replaced with
lockmgr(&my_lock, LK_EXCLUSIVE|LK_NOWAIT);

+ On occasion, the FreeBSD code will use mtx_sleep() or msleep()
+ (currently [01/2008], those macros have identical definitions)
+ in order to release a mutex and sleep without missing any
+ wakeups that might occur in between. The DragonFly idiom for
+ this case is to enter a critical section and use tsleep_interlock()
+ to let threads in other cpus know that we're about to go to
+ sleep. In our example, you would substitute

crit_enter();
+ tsleep_interlock(ident);
+ lockmgr(&my_lock, LK_RELEASE);
+ tsleep(ident, flags, "whatever", timeout);
+ crit_exit();
+ lockmgr(&my_lock, LK_EXCLUSIVE);

for
+ msleep(ident, &my_mtx, flags, "whatever", timeout);
+
As for mtx_assert() calls, translate them like this:

mtx_assert(&my_mtx, MA_OWNED) -> KKASSERT(lockstatus(&my_lock, curthread) != 0)
Actions

Also available in: Atom PDF