Reputation: 9092
Is there a way to temporarily pause and resume a whole group of threads, without using condition variables or other synchronization primitives within the threads?
pthread_kill
affects the entire process, so it cannot be used to suspend threads, but is there a low level system call for this in Linux/Windows/Darwin?
The reason is that there should be a diagnostics module that runs itself on a different thread. It should periodically freeze an entire multi-threaded program, and then read out some (atomic) variables of the other threads.
Upvotes: 1
Views: 122
Reputation: 182743
This would be almost impossible to make work. As soon as the diagnostic module attempted to acquire a lock that another thread was holding, the process would deadlock. And, in general, you have no way to know what operations might internally attempt to acquire locks that other threads might be holding. Whatever problem you're trying to solve, there's almost certainly a better way to solve it.
Upvotes: 1