summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_thread.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-09-26 09:25:11 +0000
committerkib <kib@FreeBSD.org>2012-09-26 09:25:11 +0000
commit0c5a309cd8a104f5a4c08509cfa99a78e04e1259 (patch)
tree1a3bf7ec6abd5d88725b3ec2dc4d9af341628f33 /sys/kern/kern_thread.c
parent625aa019e15a1c35c558ebe8d7a0c3ba4faf345f (diff)
downloadFreeBSD-src-0c5a309cd8a104f5a4c08509cfa99a78e04e1259.zip
FreeBSD-src-0c5a309cd8a104f5a4c08509cfa99a78e04e1259.tar.gz
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
Diffstat (limited to 'sys/kern/kern_thread.c')
-rw-r--r--sys/kern/kern_thread.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index 9d92447..bee267f 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -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);
OpenPOWER on IntegriCloud