pthread_cond_t and pthread_mutex_t

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

pthread_cond_t and pthread_mutex_t

Adriaan van Os-2
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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: pthread_cond_t and pthread_mutex_t

Jonas Maebe-3
On 04/08/2019 17:16, 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal