Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Jan 2000 23:41:09 -0500 (EST)
From:      Michael Bacarella <mbac@nyct.net>
To:        Alexander Litvin <archer@lucky.net>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: Preemptiveness of FreeBSD threads
Message-ID:  <Pine.BSF.4.05.10001162336110.179-100000@bsd1.nyct.net>
In-Reply-To: <20000116225044.C601@unknown.nowhere.org>

next in thread | previous in thread | raw e-mail | index | archive | help

> 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 majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.10001162336110.179-100000>