Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 13 Nov 2004 03:21:57 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        =?X-UNKNOWN?Q?Arne_W=F6rner?= <arne_woerner@yahoo.com>
Cc:        freebsd-realtime@FreeBSD.org
Subject:   Re: system calls
Message-ID:  <20041113025019.Q2310@epsplex.bde.org>
In-Reply-To: <20041111181446.64684.qmail@web41215.mail.yahoo.com>
References:  <20041111181446.64684.qmail@web41215.mail.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 11 Nov 2004, Arne W=F6rner wrote:

> Hiho!
>
> I just read in the BUGS section of the man page of rtprio(1), that system=
 calls
> are never preemted.

This is out of date.  System calls are sometimes preempted in -current.

> Does that mean, that a "read(fd,buffer,10000000)" blocks all other proces=
ses,
> until 10^7 bytes are read even if fd points to a file on a very slow and =
huge
> floppy disc?

It meant that long ago when 10^7 bytes was a lot of memory and took
about 1 second to read from /dev/zero.  The problem was worked around
for some syscalls by giving up control every few ticks (every 1/5
second, which is more than a few (?)) in uiomove().  Things work
a little differently in -current.  The timeout for giving up control
is broken since it is reset on every context switch and -current
switches contexts too much (on every non-fast interrupt...); thus
the timeout rarely expires.  However, switching contexts preempts
the process often enough.

Core dumps were fixed similarly.

> Unfortunately I am quite sure, that I would not find out the truth by
> experimentation or by looking at source code. Sorry...

Try looking at the gzip image activator and large sysctls, and running
them under non-current.

gunzipping takes much longer than copying out data.  It's possible to
have a tiny input file that wants to expand to many gigabytes in memory
to run.  If it is too big then it won't fit but the gzip image activator
will take a long time to expand the part that fits.

Almost any sysctl that copies out a huge amount of data and doesn't
explictly give up control will not be preempted for too long.  I've
written too many such sysctls for debugging.  Typically they print out
trace buffers in a human readable form.  Formatting (printf) takes
much longer than copying, and I sometimes make the trace buffers larger
(several MB) giving possibly hundreds of MB of output.

Bruce


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041113025019.Q2310>