<div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace;font-size:large"><span style="font-family:arial,sans-serif;font-size:small">2015-02-25 22:47 GMT+08:00 Dmitry Boyarintsev </span><span dir="ltr" style="font-family:arial,sans-serif;font-size:small"><<a href="mailto:skalogryz.lists@gmail.com" target="_blank">skalogryz.lists@gmail.com</a>></span><span style="font-family:arial,sans-serif;font-size:small">:</span><br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div>I presume most of the systems would make the sleeping thread to yield the execution time for other threads.<br></div><div>The questionable behavior might occur in case of  sleep(0); (should it yield the remaining time or just return immediately - up to the OS).<br></div><div>And multi-cpu might also do something different.<br></div><div><br></div></div></div></blockquote><div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large;display:inline">​Yes, I am particularly interested in behavior of SMP system. i.e. my purpose of using threads is to take full advantages of all CPU cores.</div></div><div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large;display:inline"><br></div></div><div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large;display:inline">As far as I know, setting thread priority does not always work, it may require root privilege for example.  I would like to use Sleep() to control relative time share of all threads in the pool.  For example, I run 3 threads on a dual-core system, with thread 1 and 2 share core-1, and thread 3 taking all computing power of core-2...</div></div><div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large;display:inline"><br></div></div><div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large;display:inline">Now the problem is, can I use Sleep to control thread 1 to run at 50% of the speed of thread 2 (which is not throttled), providing that all threads are doing same kind of task, so that they are comparable?</div></div><div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large;display:inline"><br></div></div><div><div class="gmail_default" style="font-family:monospace,monospace;font-size:large;display:inline">Xiangrong​</div> </div></div></div></div>