[fpc-devel] Why FreeBSD sem_init() works different to Linux?
Sven Barth
pascaldragon at googlemail.com
Wed Feb 6 21:17:23 CET 2013
Am 06.02.2013 20:24 schrieb "Graeme Geldenhuys" <graeme at geldenhuys.co.uk>:
>
> Hi,
>
> OK, now that we established that semaphores are broken in FreeBSD using
> FPC 2.6.0 and the upcoming FPC 2.6.2. I'm looking for an alternative.
>
> An alternative for two reasons.
> - I hate IFDEF code, and the semaphore code between Linux, FreeBSD
> and Windows are different.
> - Semaphore sem_t structure is incorrectly defined for FreeBSD, so
> I'll have to implement a special case for that platform.
If you just define your own semaphore class that contains the platform
specific types and lock and unlock methods then you only need to add an
additional "array[0..4] of Longint" after the "sem_t" field for FreeBSD.
Then you should be okay.
> Semaphore functionality seems pretty simple though, so I am thinking of
> creating my own Object Pascal based cross-platform semaphore - no low
> level code or OS specific library API's.
You need to use at least synchronisation primitives like mutexes otherwise
it won't be threadsafe.
>
> It case I'm overlooking something critical, has anybody else done
> something like this. If so, anybody willing to share that code - saving
> me some time in developing, unit testing and debugging my own Object
> Pascal based semaphore.
If you really want to do this the hard way you should read corresponding
articles.
Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20130206/9357d122/attachment.html>
More information about the fpc-devel
mailing list