好文推荐 ’ 目录归档

Java并发编程【1.2时代】

         本文介绍了Java原生的多线程技术(1.2),通过详细介绍waitnotify相关的机制、基础的多线程技术以及基于这些技术的等待超时、线程间的通信技术和线程池高阶技术,最后通过一个基于线程池的简单文本web服务器—MollyServer,来阐明多线程带来好处。通过介绍这些技术,展示了在没有使用Java并发包的时代(1.5-)是如何完成Java的多线程编程,为理解Java5提供了良好帮助。

阅读全文

原创文章,转载请注明: 转载自并发编程网 – ifeve.com本文链接地址: Java并发编程【1.2时代】


Memory Barriers/Fences

原文地址:http://mechanical-sympathy.blogspot.com/2011/07/memory-barriersfences.html(因墙转载)

In this article I’ll discuss the most fundamental technique in concurrent programming known as memory barriers, or fences, that make the memory state within a processor visible to other processors.

CPUs have employed many techniques to try and accommodate the fact that CPU execution unit performance has greatly outpaced main memory performance.  In my “Write Combining” article I touched on just one of these techniques.  The most common technique employed by CPUs to hide memory latency is to pipeline instructions and then spend significant effort, and resource, on trying to re-order these pipelines to minimise stalls related to cache misses.

When a program is executed it does not matter if its instructions are re-ordered provided the same end result is achieved.  For example, within a loop it does not matter when the loop counter is updated if no operation within the loop uses it.  The compiler and CPU are free to re-order the instructions to best utilise the CPU provided it is updated by the time the next iteration is about to commence.  Also over the execution of a loop this variable may be stored in a register and never pushed out to cache or main memory, thus it is never visible to another CPU. 阅读全文

原创文章,转载请注明: 转载自并发编程网 – ifeve.com本文链接地址: Memory Barriers/Fences


False Sharing && Java 7

原文:http://mechanical-sympathy.blogspot.hk/2011/08/false-sharing-java-7.html (因为被墙移动到墙内)

In my previous post on False Sharing I suggested it can be avoided by padding the cache line with unused longfields.  It seems Java 7 got clever and eliminated or re-ordered the unused fields, thus re-introducing false sharing.  I’ve experimented with a number of techniques on different platforms and found the following code to be the most reliable.

阅读全文

原创文章,转载请注明: 转载自并发编程网 – ifeve.com本文链接地址: False Sharing && Java 7


CPU Cache Flushing Fallacy

原文地址:http://mechanical-sympathy.blogspot.com/2013/02/cpu-cache-flushing-fallacy.html (因有墙移动到墙内)

作者:Mechanical Sympathy

Even from highly experienced technologists I often hear talk about how certain operations cause a CPU cache to “flush”.  This seems to be illustrating a very common fallacy about how CPU caches work, and how the cache sub-system interacts with the execution cores.  In this article I will attempt to explain the function CPU caches fulfil, and how the cores, which execute our programs of instructions, interact with them.  For a concrete example I will dive into one of the latest Intel x86 server CPUs.  Other CPUs use similar techniques to achieve the same ends. 阅读全文

原创文章,转载请注明: 转载自并发编程网 – ifeve.com本文链接地址: CPU Cache Flushing Fallacy


return top