PERFORCE change 118717 for review

Roman Divacky rdivacky at FreeBSD.org
Tue Apr 24 10:47:59 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=118717

Change 118717 by rdivacky at rdivacky_witten on 2007/04/24 10:47:41

	Add some comments clarifying what the requeing code does. It took
	me half a year to understand this ;)

Affected files ...

.. //depot/projects/linuxolator/src/sys/compat/linux/linux_futex.c#16 edit

Differences ...

==== //depot/projects/linuxolator/src/sys/compat/linux/linux_futex.c#16 (text+ko) ====

@@ -401,9 +401,12 @@
 	TAILQ_REMOVE(&f->f_waiting_proc, wp, wp_list);
 	FUTEX_UNLOCK;
 
+	/* if we got woken up in futex_wake */
 	if ((ret == 0) && (wp->wp_new_futex != NULL)) {
+		/* suspend us on the new futex */
 		ret = futex_sleep(wp->wp_new_futex, td, timeout);
-		futex_put(wp->wp_new_futex);	/* futex_get called in wakeup */
+		/* and release the old one */
+		futex_put(wp->wp_new_futex);
 	}
 
 	free(wp, M_LINUX);
@@ -430,10 +433,15 @@
 			wakeup_one(wp);
 			count++;
 		} else {
+			/* if we are going to requeue stuff */
 			if (newf != NULL) {
-				/* futex_put called after tsleep */
+				/* get a new futex */
 				wp->wp_new_futex = futex_get(newf->f_uaddr,
 				    FUTEX_LOCKED);
+				/* 
+				 * and wake it up so the code in futex_sleep 
+				 * can requeue us
+				 */
 				wakeup_one(wp);
 				if (count - n >= n2)
 					break;


More information about the p4-projects mailing list