[Midnightbsd-cvs] src [8131] trunk/sys/kern/kern_thread.c: do not skip two elements of the tid_buffer when reusing the buffer slot.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Fri Sep 16 17:47:51 EDT 2016


Revision: 8131
          http://svnweb.midnightbsd.org/src/?rev=8131
Author:   laffer1
Date:     2016-09-16 17:47:51 -0400 (Fri, 16 Sep 2016)
Log Message:
-----------
do not skip two elements of the tid_buffer when reusing the buffer slot. make updates of head and tail pointers explicit

Modified Paths:
--------------
    trunk/sys/kern/kern_thread.c

Modified: trunk/sys/kern/kern_thread.c
===================================================================
--- trunk/sys/kern/kern_thread.c	2016-09-16 21:46:59 UTC (rev 8130)
+++ trunk/sys/kern/kern_thread.c	2016-09-16 21:47:51 UTC (rev 8131)
@@ -102,8 +102,8 @@
 		mtx_unlock(&tid_lock);
 		return (-1);
 	}
-	tid = tid_buffer[tid_head++];
-	tid_head %= TID_BUFFER_SIZE;
+	tid = tid_buffer[tid_head];
+	tid_head = (tid_head + 1) % TID_BUFFER_SIZE;
 	mtx_unlock(&tid_lock);
 	return (tid);
 }
@@ -115,11 +115,11 @@
 
 	mtx_lock(&tid_lock);
 	if ((tid_tail + 1) % TID_BUFFER_SIZE == tid_head) {
-		tmp_tid = tid_buffer[tid_head++];
+		tmp_tid = tid_buffer[tid_head];
 		tid_head = (tid_head + 1) % TID_BUFFER_SIZE;
 	}
-	tid_buffer[tid_tail++] = tid;
-	tid_tail %= TID_BUFFER_SIZE;
+	tid_buffer[tid_tail] = tid;
+	tid_tail = (tid_tail + 1) % TID_BUFFER_SIZE;
 	mtx_unlock(&tid_lock);
 	if (tmp_tid != -1)
 		free_unr(tid_unrhdr, tmp_tid);



More information about the Midnightbsd-cvs mailing list