[DragonFlyBSD - Bug #908] mention msleep() in porting_drivers.txt

Antonio M. Huete Jimenez via Redmine bugtracker-admin at leaf.dragonflybsd.org
Sun Mar 10 08:18:07 PDT 2013


Issue #908 has been updated by tuxillo.

Assignee changed from sjg to tuxillo

Grab
----------------------------------------
Bug #908: mention msleep() in porting_drivers.txt
http://bugs.dragonflybsd.org/issues/908

Author: aoiko
Status: In Progress
Priority: Low
Assignee: tuxillo
Category: 
Target version: 


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)


-- 
You have received this notification because you have either subscribed to it, or are involved in it.
To change your notification preferences, please click here: http://bugs.dragonflybsd.org/my/account



More information about the Bugs mailing list