[fpc-devel] semaphores and mutes

Peter Popov ppopov at tamu.edu
Sat Jun 21 00:32:16 CEST 2008


I haven't followed the discussion so far, so what I might say may be out  
of context and not relevant.

Regarding semaphores and mutexes:
the implementation in Kylix of TEvent is incomplete in the sense that  
TEvent.WaitFor(timeout: Integer) does not work for any timeout other than  
$FFFFFFFF. Some time ago fpc was in the same situation and I don't known  
if that have been resolved. If it have been resolved, please disregard the  
rest of the post.

Anyways, some time ago I debuged the issue and patched kylix's SynObjs  
unit to cure that. Basically, the problem is, as expected, glibc. Older  
version did not have sem_timedwait() implemented. Later glibc included it,  
along with several new variants of the remaining semaphore routines. So,  
based on what thread model is used (LinuxThreads or NTPL) each semaphore  
routine is implemented several times. The thing is a total mess. Anyways,  
if one explicitly instructs the kylix linker which version of semaphore  
functions to use (they have to be consistent) TEvent.WaitFor can be  
implemnted for any timeout. If there is interest I can post the patch.

Peter Popov

On Fri, 20 Jun 2008 17:13:11 -0500, Boian Mitov <mitov at mitov.com> wrote:

> While on the discussion, are there any plans for Semaphore and Mutex in  
> the libraries in the future? I will be writing my own implementations  
> using the Events, but just curious if in the future they are planned to  
> be offered. I have seen Semaphore used in the TThread implementation,  
> but they are not available outside the unit, so I assume they are too  
> platform specific. I think I can make implementation by using only  
> events, critical sections and counters.
>
>   With best regards,
>     Boian Mitov


-- 
|***********************************************|
|                                               |
|  Peter Popov,                                 |
|                                               |
|  608L Blocker Bldg.                           |
|  Institute for Scientific Computation,        |
|  Texas A&M University                         |
|  College Station, Texas 77843-3404            |
|-----------------------------------------------|
|  Phone: +1 (979) 458-4644,                    |
|  Fax: +1 (979) 845-5827                       |
|                                               |
|***********************************************|



More information about the fpc-devel mailing list