> Program, when killed with SIGINT, prints all counters and exits.
> 
> Now, as I understand, userspace threads in FreeBSD are preemptive.
> So, though my 11 threads are all computational and do not do
> any syscalls, sleeps, sched_yield, whatever -- newertheless,
> the program should not be stuck in one thread. And it seems to
> be sometimes true. But only sometimes!

Hmmm, my prior response was pretty much bullshit. It doesn't work
for me with 'volatile' at all.

If I put:  printf ("running %d\n", pthread_self());
right before the counter loop, I only get one thread telling me about
itself.

Seems like a scheduler problem. Perhaps it is treating all threads as a
logical unit and assigning them a global priority, and selecting the same
thread to suck up all of it's time, each time.

A "successful" run probably happens on busier systems where other factors
mess with scheduling -- but I haven't verified this.

Putting a sched_yield(); in the loop body makes sure that they get their
fair share, so, other than guessing FreeBSD is at fault, I'm out of ideas. :)

-MB




To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to