Monthly Archives: November 2010

0mq code reading (1): mailbox

mailbox.cpp/h: mailbox is the inter-thread communication mechanism . In 0mq, whenever one thread wants to modify the status of the other one, it sends a message to inform the other thread to do it. You don’t need any synchronization among … Continue reading

Posted in 0mq code reading | Leave a comment

As hard as 10 lines of code…

bool ceq(const char *s, const char *t, std::size_t n) {   int i=0, j=0, size=static_cast<int>(n), k;   while(i<n && j<size) {     for(k=0; k<size && s[(i+k)%size]==t[(j+k)%size]; ++k);     if(k==size) return true;     if(s[(i+k)%size]>t[(j+k)%size])       i+=k+1;     else       j+=k+1;   … Continue reading

Posted in Programming | Leave a comment

MCS Spin Lock

MCS spin lock is named after the inventors John Mellor Crummey and Michael Scotty.  see “Algorithms for Scalable Synchronization on Shared-Memory Multiprocessors”.  ACM Trans. Comput. Syst. 9(1): 21-65 (1991). The quotation from Edsger W. Dijkstra Prize in Distributed Computing  2006: “The … Continue reading

Posted in Programming | Leave a comment