Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 Jan 2000 22:03:22 -0800
From:      Jason Evans <jasone@canonware.com>
To:        Alexander Litvin <archer@lucky.net>
Cc:        hackers@freebsd.org
Subject:   Re: Preemptiveness of FreeBSD threads
Message-ID:  <20000116220322.T302@sturm.canonware.com>
In-Reply-To: <20000116225044.C601@unknown.nowhere.org>; from archer@lucky.net on Sun, Jan 16, 2000 at 10:50:45PM -0500
References:  <20000116225044.C601@unknown.nowhere.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Jan 16, 2000 at 10:50:45PM -0500, Alexander Litvin wrote:
> I've a simple sample program (see at the bottom). It creates 10
> threads with start function start_my_thread(), and then runs the
> same function in main(). So, we have 11 threads doing the same job.
> 
> Function start_my_thread() just increments indefinitely counters
> (each thread has its own counter).
> 
> 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!

My experiments with your test program do exactly what I would expect.  The
longer the program is run, thu longer the program has to preempt threads,
which means that given enough time, all threads will run.  If the program
is run for a short time (less than about 1.5 seconds) then some threads may
never get to run.

You don't mention how long you run the program for, so I'm assuming that
the runtime must be quite short for you to be seeing the results that
concerned you.  All tests that I ran showed non-zero counters for all
threads if the program ran for more than 1.5 seconds.

Jason


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?20000116220322.T302>