摘要: The purpose of the algorithm is, given a curve composed of line segments, to find a similar curve with fewer points. The algorithm defines 'dissimilar' based on the maximum distance between the original curve and the simplified curve. The simplified curve consists of a subset of the points t 阅读全文
posted @ 2011-05-05 22:55 qsort 阅读(1555) 评论(0) 推荐(0)
摘要: compile time assert:#define UNIQUE(x) __unique_name##x#define STATIC_ASSERT(expr) typedef char UNIQUE(__LINE__)[(expr)?1:-1]; 阅读全文
posted @ 2011-05-05 18:14 qsort 阅读(565) 评论(0) 推荐(0)
摘要: False sharing is an inherent artifact of cache coherence protocols (like MESI and MOESI). It happens when two participants (threads) operates on different part of the same cache-line. Seehttp://en.wikipedia.org/wiki/False_sharingfor more details (and sample code). 阅读全文
posted @ 2011-05-05 18:13 qsort 阅读(176) 评论(0) 推荐(0)
摘要: #pragma GCC poisonRemove the specified identifier(s) from the program (and forbid them from appearing).Seehttp://gcc.gnu.org/onlinedocs/gcc-3.2.3/cpp/Pragmas.htmlfor more information. 阅读全文
posted @ 2011-05-05 18:11 qsort 阅读(764) 评论(0) 推荐(1)
摘要: __func__, __FUNCTION__, __PRETTY_FUNCTION__In C++, __PRETTY_FUNCTION__ contains the type signature of the function.Seehttp://gcc.gnu.org/onlinedocs/gcc-4.5.2/gcc/Function-Names.htmlfor more information. 阅读全文
posted @ 2011-05-05 18:08 qsort 阅读(199) 评论(0) 推荐(0)
摘要: Quoting APUE2:The mutex passed to pthread_cond_wait protects the condition. The caller passes it locked to the function, which then atomically places the calling thread on the list of threads waiting for the condition and unlocks the mutex. This closes the window between the time that the condition 阅读全文
posted @ 2011-05-05 18:05 qsort 阅读(248) 评论(0) 推荐(0)
摘要: 场景:不小心删除了某文件,但该文件之前被某进程(譬如一个daemon)打开尚未关闭。注:文件删除是在打开的fd都关闭以后发生的,即,unlink一个文件以后,如果inode的引用计数降到0,这个文件应该被删除,但如果还有进程打开了这个文件且尚未关闭(即打开计数不为0),那么文件将在最后一个打开该文件的进程关闭该文件的fd以后删除。这也是为什么会有install这种命令的缘故。install会首先unlink文件,之后以同样文件名open(其实是create)该文件并写入;与之对应的是,cp命令打开文件直接写入。在install最常用的场合,安装新版本的共享库.so文件,由于要更新的.so文件可 阅读全文
posted @ 2011-05-05 18:02 qsort 阅读(253) 评论(0) 推荐(0)