{"action":"opened","issue":{"url":"https://api.github.com/repos/Bloss/Code/issues/4","repository_url":"https://api.github.com/repos/Bloss/Code","labels_url":"https://api.github.com/repos/Bloss/Code/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/Bloss/Code/issues/4/comments","events_url":"https://api.github.com/repos/Bloss/Code/issues/4/events","html_url":"https://github.com/Bloss/Code/issues/4","id":147462049,"number":4,"title":"处理器重排序与内存屏障指令","user":{"login":"Bloss","id":9587448,"avatar_url":"https://avatars.githubusercontent.com/u/9587448?v=3","gravatar_id":"","url":"https://api.github.com/users/Bloss","html_url":"https://github.com/Bloss","followers_url":"https://api.github.com/users/Bloss/followers","following_url":"https://api.github.com/users/Bloss/following{/other_user}","gists_url":"https://api.github.com/users/Bloss/gists{/gist_id}","starred_url":"https://api.github.com/users/Bloss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bloss/subscriptions","organizations_url":"https://api.github.com/users/Bloss/orgs","repos_url":"https://api.github.com/users/Bloss/repos","events_url":"https://api.github.com/users/Bloss/events{/privacy}","received_events_url":"https://api.github.com/users/Bloss/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-11T15:19:00Z","updated_at":"2016-04-11T15:19:00Z","closed_at":null,"body":"现代的处理器使用写缓存区来临时向内存写入的数据，它可以避免由于处理器停顿下来等待向内存写入数据而产生延迟。同时，通过批处理的方式刷新写缓冲区，以及合并写缓冲区对同一内存地址的多次写，减少了对内存总线的占用，**但是每个处理上的写缓冲区，仅仅对它所在的处理器可见**，这个特性会对内存操作的执行顺序产生重要的影响：  \r\n* 处理器对内存的读/写操作的执行顺序，不一定与内存实际发生的读/写操作顺序一致！  \r\n| Processor A | Processor B              |\r\n  --------------          ----\r\n| a = 1; // A1   | B = 2; // B2                 |\r\n| x = b; // A2   | y = a; //B2                  |\r\n   ------------------------------\r\n| 初始状态：a = b = 0                         |\r\n| 处理器允许执行后的结果：x = y = 0 |"}}