From: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Doug McNaught <doug(at)wireboard(dot)com> |
Cc: | Igor Kovalenko <Igor(dot)Kovalenko(at)motorola(dot)com>, pgsql-hackers(at)postgresql(dot)org, frankeh(at)us(dot)ibm(dot)com, rusty(at)rustcorp(dot)com(dot)au |
Subject: | Re: Lightweight locking primitive |
Date: | 2002-03-13 00:08:50 |
Message-ID: | 200203130008.g2D08o822879@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Doug McNaught wrote:
> They're basically the same thing. Currently, pthread_mutexes on Linux
> (implemented in glibc) are fairly gross in the contended case, since
> there is no clean way to wait for lock release, and they interact
> fairly nastily with signal semantics. The futex patches create a new
> system call which lets you cleanly wait for a locked futex (an
> unlocking task checks for waiting lockers and calls into the kernel
> for wakeups if it finds any).
Strange that it doesn't wait for the lock. BSD/OS has:
The pthread_mutex_lock() function locks the mutex pointed to by mutex. If
mutex is already locked, the calling thread will block until the mutex
becomes available. Upon success the pthread_mutex_lock() function re-
turns with the mutex locked and the calling thread as its owner.
In fact, they have a pthread_mutex_trylock() version that doesn't block:
The pthread_mutex_trylock() function performs a non-blocking mutex lock
operation. It behaves exactly like pthread_mutex_lock() except that if
any thread (including the calling thread) currently owns the mutex, an
immediate error return is performed.
--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
From | Date | Subject | |
---|---|---|---|
Next Message | Patrick Welche | 2002-03-13 00:10:12 | Re: Help Wanted for running C code |
Previous Message | Mark Pritchard | 2002-03-13 00:07:53 | Re: Help Wanted for running C code |