Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-02

cthreads unit

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

ik

Hello,

I'm trying to use the pthread_self function that supposed to be existed at cthreads unit.
However the compiler tell me that it does not know "pthread_self".

I'm using Linux 64 bit (so I can't use libc), using fpc 2.2.0 . Looking at the source of cthreads.pp, it does have an include for pthread.inc file, that does contain dynamic/static linking of the function, so what am I missing ?

Ido

Reply by email

Jonas Maebe
to ik
ik wrote
I'm trying to use the pthread_self function that supposed to be existed at cthreads unit. However the compiler tell me that it does not know "pthread_self".

It's only imported into that unit (in the implementation), it's not exported. The cthreads unit only installs a thread manager, it does not expose any implementation details (that's the whole point of that unit).

I'm using Linux 64 bit (so I can't use libc), using fpc 2.2.0 . Looking at the source of cthreads.pp, it does have an include for pthread.inc file, that does contain dynamic/static linking of the function, so what am I missing ?

If you want to use the RTL support for threading, use the generic RTL routines and not OS-specific ones. There is e.g. a GetCurrentThreadId function (but don't count on it returning the same value as pthread_self).

If you want to program with pthreads directly, use the pthreads unit instead.

Jonas

Reply by email

ik
to Jonas Maebe

Thanks, that works.

Jonas Maebe wrote 31 lines
On 17 Feb 2008, at 19:42, ik wrote: > I'm trying to use the pthread_self function that supposed to be > existed at cthreads unit. > However the compiler tell me that it does not know "pthread_self". It's only imported into that unit (in the implementation), it's not exported. The cthreads unit only installs a thread manager, it does not expose any implementation details (that's the whole point of that unit). > I'm using Linux 64 bit (so I can't use libc), using fpc 2.2.0 . > Looking at the source of cthreads.pp, it does have an include for > pthread.inc file, that does contain dynamic/static linking of the > function, so what am I missing ? If you want to use the RTL support for threading, use the generic RTL routines and not OS-specific ones. There is e.g. a GetCurrentThreadId function (but don't count on it returning the same value as pthread_self). If you want to program with pthreads directly, use the pthreads unit instead. Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email