Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pthreads signal-like pause?

Is there a way in the pthreads API that I can have one thread instruct either itself or another thread to pause?

By pause, I mean stop executing and stop getting scheduled until another thread signals it to resume.

like image 210
John Humphreys Avatar asked Jul 05 '26 22:07

John Humphreys


1 Answers

In pthread / POSIX Thread stack, you may use pthread_kill to send signals to individual threads; but unfortunately that doesnt include "stop", "continue", or "terminate". See the Notes here

If you are only interested in pausing the thread; a crafty formula of mutexes and conditional variables are the best way forward.

like image 108
ϹοδεMεδιϲ Avatar answered Jul 08 '26 14:07

ϹοδεMεδιϲ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!