Tag: tlb

记忆障碍和TLB

内存障碍保证数据缓存一致。 但是,它是否保证TLB一致? 我发现在线程之间传递MappedByteBuffer时,JVM(java 7 update 1)有时会因内存错误(SIGBUS,SIGSEG)崩溃而出现问题。 例如 final AtomicReference mbbQueue = new AtomicReference(); // in a background thread. MappedByteBuffer map = raf.map(MapMode.READ_WRITE, offset, allocationSize); Thread.yield(); while (!inQueue.compareAndSet(null, map)); // the main thread. (more than 10x faster than using map() in the same thread) MappedByteBuffer mbb = inQueue.getAndSet(null); 没有Thread.yield()我偶尔会在force(),put()和C的memcpy()中崩溃,这些都表示我试图非法访问内存。 使用Thread.yield()我没有遇到任何问题,但这听起来不是一个可靠的解决方案。 有人遇到过这个问题吗? 有关TLB和内存障碍的保证吗? 编辑:操作系统是Centos 5.7,我已经看到了i7和双Xeon机器上的行为。 我为什么这样做? 因为写入消息的平均时间是35-100 […]