Author: kib
Date: Wed Sep 26 09:25:11 2012
New Revision: 240951
URL: http://svn.freebsd.org/changeset/base/240951

Log:
  Make the updates of the tid ring buffer' head and tail pointers
  explicit by moving them into separate statements from the buffer
  element accesses.
  
  Requested by: jhb
  MFC after:    3 days

Modified:
  head/sys/kern/kern_thread.c

Modified: head/sys/kern/kern_thread.c
==============================================================================
--- head/sys/kern/kern_thread.c Wed Sep 26 09:22:28 2012        (r240950)
+++ head/sys/kern/kern_thread.c Wed Sep 26 09:25:11 2012        (r240951)
@@ -102,8 +102,8 @@ tid_alloc(void)
                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 @@ tid_free(lwpid_t tid)
 
        mtx_lock(&tid_lock);
        if ((tid_tail + 1) % TID_BUFFER_SIZE == tid_head) {
-               tmp_tid = tid_buffer[tid_head++];
-               tid_head %= TID_BUFFER_SIZE;
+               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);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to