Asynchronous communication between master and slave threads

I am writing a process that has a master thread and a set of slave threads. Master thread is supposed to get jobs dynamically and assign to slave thread which is free. Master also get results back from slaves once a job is done. The number of slaves should be adjustable dynamically based on job load.

The interesting thing is that when job is in progress, master may decide to stop a job. I am thinking of some way of communication between one(master) and many(slaves) to assign jobs, stop a job (specific to a salve which does the job), get results from slave.

Will message queues be useful?

Thanks in advance

/Tamil

Sure, or something similar. If master has a queue to each thread, it can send tasks and stop requests. However, if you want a thread to suspend processing, it needs to be interrupted. Maybe all threads can service a SIGUSR1 to read a special queue or flag for such. Dispatching work without latency from excess buffering or lost cycles waiting on master or locks is one problem. Suspending and reactivating threads is another. Oh, BTW, lwp concurrent threads are a different problem than threads sharing a lwp.