Semaphore or what should I use?

Ville Vainio ville at spammers.com
Thu Dec 2 14:56:49 CET 2004


>>>>> "Sergei" == Sergei Organov <osv at javad.ru> writes:

    Sergei> My answer to OP's question is: use either lock (mutex) or
    Sergei> semaphore.  I'd probably use semaphore as mutexes are
    Sergei> usually optimized for the case when contention probability
    Sergei> is low (i.e., they usually shouldn't be locked for a long
    Sergei> time).

Both Mutexes and Semaphores put the thread to sleep, so I don't think
there will be a big difference.

The OP might also want to check out read/write lock. The first thing
google finds is

http://www.majid.info/mylos/weblog/2004/11/04-1.html

-- 
Ville Vainio   http://tinyurl.com/2prnb



More information about the Python-list mailing list