forked from chenshuo/muduo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnote.txt
53 lines (34 loc) · 2.36 KB
/
note.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
9.2.1
A.1.8
10.3.2
gdb中使用thread apply all bt
Use wait-and lock-free structures only if you absolutely must
http://www.thinkingparallel.com/2007/02/19/please-dont-rely-on-memory-barriers-for-synchronization
http://zaitcev.livejournal.com/144041.html
http://www.kernel.org/doc/Documentation/volatile-considered-harmful.txt
http://blog.csdn.net/panaimin/article/details/5981766
http://www.nwcpp.org/Downloads/2007/Machine_Architecture_-_NWCPP.pdf
http://www.aristeia.com/TaklNotes/ACCU2011_CPUCaches.pdf
http://igoro.com/archive/gallery-of-processor-cache-effects/
http://simplygenius.net/Article/FalseSharing
http://en.wikipedia.org/wiki/Spurious_wakeup
http://blog.csdn.net/Solstice/article/details/5829421#comments
http://www.drdobbs.com/cpp/lock-free-code-a-false-sense-of-security/210600279
Be wary of readers/writer locks
http://www.cs.umd.edu/-pugh/java/memoryModel/DoubleCheckedLocking.html
http://www.javaworld.com/jw-02-2001/jw-0209-double.html
http://www.aristeia.com/Papers/DDJ_Jul_Aug_2004_revised.pdf
http://preshing.com/2011118/locks-arent-slow-lock-contention-is
http://www.cs.wustl.edu/-schmidt/PDF/Reactor1-93.pdf
http://www.cs.wustl.edu/-schmidt/PDF/proactor.pdf
lighttpd内部的fdevent结构十分精妙,值得学习
Eventloop代表了线程的主循环,需要让哪个线程干活,就把timer或IO channel(如TCP连接)注册到哪个线程的loop
里即可。对实时性有要求的connection可以单独用一个线程;数据量大的connection可以独占一个线程,并把数据处理
任务分摊到另几个计算线程中(用线程池);其他次要的辅助性connections可以共享一个线程.
Java util.concurrent(Array|Linked)BlockingQueue这份代码可读性很高,代码的基本结构和教科书一致(1个mutex,2个conditon variables),健壮性要高很多。有兴趣的读者还可以试试Intel Threading Building Blocks里的concurrent_queue<T>,性能估计会更好。
socketpair
pipe也有一个经典应用场景,那就是写Reactor/event loop时用来异步唤醒select(或等价的poll/epoll_wait)调用(在linux下,可以用eventfd(2)代替,效率更高),Sun HotSpot JVM在linux就是这么做的
http://blog.csdn.net/haoel/article/details/2224055
http://code.google.com/p/tcpcopy/
## 工具
Intel Thread Checker和Valgrind-Helgrind等能识别pthreads调用,并根据happens-before关系分析程序有无data race