Greg wrote:
One final thought / question / observation along the same lines...

This is what got me started on this line of thinking / research...

I have experimented with posix threads and find repeatedly that even a multi-threaded application yields results the same as if I have coded a non-multi-threaded application.

If I need to give examples, I shall later, but basicly, I code with pthreads.h in C a simple counting thread which reports its thread number and the count. I then set main to spawn multiple threads, and in the threads, each has a random sleep in between printfs to show the thread / count.

I even put in flushes to make sure the results weren't due to a printf 
buffering issue.

Each and every result was of a thread counting in sequence before going to the next thread. No sleep states were put in the main program. It simple spawned a bunch of threads back to back, and then waited for them to "join".

Is this normal? I thought even under a uniprocessor machine the threads were to 
time-slice like on a multicore.

It is depend on your application and how you write your code. For example we can have a good speed up for dense matrix multiplication, however, for some application such as sparse matrix calculation using multiple threads may even slow down your application.

Hung

Reply via email to