1 |
On 06/11/2009 01:35 AM, Greg wrote: |
2 |
> One final thought / question / observation along the same lines... |
3 |
> |
4 |
> This is what got me started on this line of thinking / research... |
5 |
> |
6 |
> I have experimented with posix threads and find repeatedly that even a multi-threaded application yields results the same |
7 |
> as if I have coded a non-multi-threaded application. |
8 |
> |
9 |
> If I need to give examples, I shall later, but basicly, I code with pthreads.h in C a simple counting thread which reports |
10 |
> its thread number and the count. I then set main to spawn multiple threads, and in the threads, each has a random sleep in |
11 |
> between printfs to show the thread / count. |
12 |
> |
13 |
> I even put in flushes to make sure the results weren't due to a printf buffering issue. |
14 |
> |
15 |
> Each and every result was of a thread counting in sequence before going to the next thread. No sleep states were put in |
16 |
> the main program. It simple spawned a bunch of threads back to back, and then waited for them to "join". |
17 |
> |
18 |
> Is this normal? I thought even under a uniprocessor machine the threads were to time-slice like on a multicore. |
19 |
|
20 |
No, it's not normal. That means the code you wrote has bugs :) |