Skip to content
Snippets Groups Projects
Commit cd538447 authored by homunkulus's avatar homunkulus
Browse files

Auto merge of #10 - pftbest:tsan_write_after_read, r=japaric

What if tsan is right?

Is speedup from one less barrier worth the risk in this case?
parents a885d6a4 e5e24f08
No related branches found
No related tags found
No related merge requests found
...@@ -88,8 +88,8 @@ where ...@@ -88,8 +88,8 @@ where
let n = rb.capacity() + 1; let n = rb.capacity() + 1;
let buffer: &mut [T] = unsafe { rb.buffer.as_mut() }; let buffer: &mut [T] = unsafe { rb.buffer.as_mut() };
let head = rb.head.load_relaxed();
let tail = rb.tail.load_relaxed(); let tail = rb.tail.load_relaxed();
let head = rb.head.load_acquire();
let next_tail = (tail + 1) % n; let next_tail = (tail + 1) % n;
if next_tail != head { if next_tail != head {
// NOTE(ptr::write) the memory slot that we are about to write to is uninitialized. We // NOTE(ptr::write) the memory slot that we are about to write to is uninitialized. We
......
...@@ -87,7 +87,7 @@ fn contention() { ...@@ -87,7 +87,7 @@ fn contention() {
scope.execute(move || { scope.execute(move || {
let mut sum: u32 = 0; let mut sum: u32 = 0;
for i in 0..N { for i in 0..(2*N) {
let i = i as u8; let i = i as u8;
sum = sum.wrapping_add(i as u32); sum = sum.wrapping_add(i as u32);
while let Err(_) = p.enqueue(i) {} while let Err(_) = p.enqueue(i) {}
...@@ -99,7 +99,7 @@ fn contention() { ...@@ -99,7 +99,7 @@ fn contention() {
scope.execute(move || { scope.execute(move || {
let mut sum: u32 = 0; let mut sum: u32 = 0;
for _ in 0..N { for _ in 0..(2*N) {
loop { loop {
match c.dequeue() { match c.dequeue() {
Some(v) => { Some(v) => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment