Sign in Join

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

Mailing lists / fpc-pascal / 2019-08

pthread_cond_t and pthread_mutex_t

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Adriaan van Os

The FPC runtime library seems to export the type definitions of pthread_mutex_t and pthread_cond_t but the functions that operate on them are private in cthreads.pp and pthread.inc.

So, is there a Pascal runtime library equivalent of the following code or should I redeclare the required C-functions ?

var
mutex: pthread_mutex_t;
condition: pthread_cond_t;
thread 1
------
pthread_mutex_lock( mutex);
while not condition do
     pthread_cond_wait( condition, mutex);
pthread_mutex_unlock( mutex);
thread 2:
------
pthread_mutex_lock( mutex);
pthread_cond_signal( condition);
pthread_mutex_unlock( mutex);

Regards,

Adriaan van Os

Jonas Maebe
to Adriaan van Os
Adriaan van Os wrote
The FPC runtime library seems to export the type definitions of pthread_mutex_t and pthread_cond_t but the functions that operate on them are private in cthreads.pp and pthread.inc.

There is a pthreads library interface in the pthreads unit (packages/pthreads).

Jonas