Subj : Re: Windows Suspend/ResumeThread API equivalent for Linux or POSIX? To : comp.programming.threads From : Oliver S. Date : Thu May 12 2005 02:54 am >> ... (esspecially when multiple worker-threads share this flag on >> a SMP-system and need to MESI -broadcast for a newer version of >> the cache-line containing that flag to all CPUs) ... > Umm, no, it would stay shared until it was modified. Oh, my fault; you're right ! >> Don't you think an API like SuspendThread / ResumeThread >> is much smarter in that case ? > No, I don't. In fact, it's a grossly ugly premature optimization. That's your personal view, but _for_this_special_case_ this "opti- mization" is ok under some circumstances. Do you really think that polluting the code otherwise unrelated to threading-issues to check a flag is less ugly ? > And if you suspend the thread while it holds the 'malloc' mutex, > you're screwed. I've written a rendering-core of a PostScript-interpreter and this rendering-core can be distributed among a number of processors in a SMP-system. And the worker-threads of this core share a highly opti- mized common memory-allocator for every device-oject. And if I sus- pend all worker-threads attached to every device-object and using the same memory-pool-object, this wouldn't cause any side-effects; and there isn't any magic in taking care for this issue when wri- ting code for worker-threads. Of course there could be cases where you aren't able to design the worker-threads according to that rule because you're forced to use a library that baffles that approach. >> And as suspending an resuming a thread can be considered as a >> longer interval of suspension through preemption, such an API >> could be provided by an operating-system without a significant >> cost in code-size or growth in complexity of the OS. > It is nothing like pre-emption, because with pre-emption, the > thread will ultimately be rescheduled with no action from user > code, so deadlock is not possible. Of course this is possibe, but you misunderstood me. I simply wanted to say that the OS-code for SuspendThread / ResumeThread use the same code for suspending and resuming the thread which the scheduler uses. .