<BASE HREF="
http://www.geocrawler.com/archives/3/145/1998/10/0/623609/">
<!-- WRITTEN WITH VIM 5.3
http://www.vim.org/ -->
<HTML>
<HEAD>
<STYLE>
<!--
A {text-decoration: none}
A:hover {text-decoration: none; color: #FF6666 }
BODY,TD,P,B {font-family: arial, helvetica, sans-serif}
H1, H2, H3, H4, H5, H6 {font-family: arial, helvetica, sans-serif}
PRE, TT {font-family: courier, sans-serif}
-->
</STYLE>
<TITLE>Geocrawler.com - freebsd-bugs - kern/8500: FreeBSD 3.0 thread scheduler is broken</TITLE>
<script language="javascript">
<!--
brokenLayers = (navigator.appName.substring(0,8) == 'Netscape' && parseFloat(navigator.appVersion) <= 4.01);
WebTV = (navigator.appName.indexOf('WebTV Plus') != -1);
// -->
</script>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#0000CD" TOPMARGIN="0" BOTTOMMARGIN="0" LEFTMARGIN="0" RIGHTMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0" VLINK="#777799" ALINK="#FF6666" BACKGROUND="/img/geocrawler-bg.gif">
<!-- OSDN navbar -->
<style type="text/css">
osdn-search {
background-color:#fff;
border:1px #666666 solid;
font-size: 10px;
color: #666666;
//margin: 0px;
font-family: arial,sans-serif;
}
input[type="text"].osdn-search {
padding-top: 0.1em;
padding-left: 0.2em;
padding-right: 0.2em;
}
.osdn-button {
margin-top: 1px;
margin-bottom: 1px;
}
select.osdn-search {
text-align: center;
}
.osdn-navtext {color: #666666; font-family: verdana, arial, sans-serif; font-size: 10px; text-decoration: none;}
</style>
<script language="JavaScript">
<!--
function jump(target,select,restore){
eval(target+".location='"+select.options[select.selectedIndex].value+"'");
if (restore) select.selectedIndex=0;
}
//-->
</script>
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
<form action="
http://www.osdn.com/osdnsearch.pl" method="POST">
<tr bgcolor="#999999">
<td colspan="5"><img src="
http://images.osdn.com/blank.gif" width="1" height="1" alt=""></td>
</tr>
<tr bgcolor="#eeeeee">
<td nowrap class="osdn-navtext"> <a href="
http://www.osdn.com" class="osdn-navtext" title="click to visit OSDN.com!"><B>OSDN:</B> Open Source Development Network</a>: <a href="
http://www.osdn.com/newsletters/">Newsletters</a> - <a href="
http://jobs.osdn.com">Jobs</a> </td>
<td align="right" valign="middle" width="100%" class="osdn-navtext"><B>SEARCH:</B> </td>
<td align="right" valign="middle" nowrap class="osdn-navtext">
<select name="site" class="osdn-search">
<option value="all" SELECTED>All OSDN Sites</option>
<option value="">-----------</option>
<option value="Freshmeat">freshmeat</option>
<option value="Jobs.OSDN.com">Jobs.OSDN.com</option>
<option value="Kuro5hin">Kuro5hin</option>
<option value="LinuxGram">LinuxGram</option>
<option value="NewsForge">NewsForge</option>
<option value="OSDN">OSDN.com</option>
<option value="Slashcode">Slashcode</option>
<option value="Slashdot">Slashdot</option>
<option value="SourceForge">SourceForge</option>
</select>
<input type="text" name="query" size="12" class="osdn-search"> </td>
<td nowrap width="40"><input type="image" border="0" name="Submit" value="GO" src="
http://images.osdn.com/go.gif" alt="Go" width="30" height="20" align="middle" class="osdn-button"></td>
</tr>
<tr bgcolor="#999999">
<td colspan="5"><img src="
http://images.osdn.com/blank.gif" width="1" height="1" alt=""></td>
</form>
</tr>
</table>
<!-- end OSDN navbar -->
<TABLE cellpadding="5" cellspacing="5" border="0" width="100%" align="center">
<TR>
<TD align="left"><IMG src="/img/geocrawler-title.gif" alt="Geocrawler" width="239" height="61"></TD>
<!-- BANNER start -->
<TD align="center">
<!-- begin banner ad -->
<table border=0 cellpadding=0><tr><td>
<ILAYER id="adilayer1" width="468" height="60" visibility="hide"></ILAYER></NOLAYER>
</TD></TR></TABLE>
</TD>
</TR>
</TABLE>
<TABLE cellspacing="0" cellpadding="0" width="100%" border="0">
<TR valign="middle" bgcolor="#666699">
<TD colspan="2"><IMG src="/img/pixel.gif" width="1" height="1" alt=""></TD>
</TR>
<TR valign="middle" bgcolor="#e8e2ef">
<TD height="20">
<FONT color="#000000" face="Arial, Helvetica" size="2">��
<A href="/"><FONT color="#000000"><B>Home</B></FONT></A> |
<A href="/privacy/"><FONT color="#000000"><B>Privacy Statement</B></FONT></A> |
<A href="/about/"><FONT color="#000000"><B>About</B></FONT></A>
</TD>
<TD align="right" valign="bottom">
<A HREF="/login/"><IMG SRC="/img/register_button.gif" WIDTH=57 HEIGHT=15 ALT="REGISTER" BORDER=0></A>
<A HREF="/login/login.php3"><IMG SRC="/img/login_button.gif" WIDTH=57 HEIGHT=15 ALT="LOGIN" BORDER=0></A> </TD>
</TR>
<TR valign="middle" bgcolor="#666699">
<TD colspan="2"><IMG src="/img/pixel.gif" width="1" height="3" alt=""></TD>
</TR>
</TABLE>
<BASE HREF="
http://www.geocrawler.com/archives/3/145/1998/10/0/623609/">
<IMG SRC="
http://www2.valinux.com/clear.gif?id=104" WIDTH="1" HEIGHT="1">
<TABLE BORDER=0 WIDTH="96%" ALIGN="center" CELLSPACING="2" CELLPADDING="2">
<TR>
<TD HEIGHT="90%" VALIGN=TOP>
<FONT FACE="ARIAL,HELVETICA" SIZE=2>
<TABLE WIDTH="100%" CELLPADDING=3>
<TR>
<TD>
<FONT FACE="ARIAL,HELVETICA" SIZE=2>
<A HREF="/lists/3/"><IMG SRC="/img/ofolder.png" HEIGHT=13 WIDTH=15 BORDER=0> �Mailing Lists</A><BR>
� � <A HREF="/lists/3/FreeBSD/"><IMG SRC="/img/ofolder.png" HEIGHT=13 WIDTH=15 BORDER=0> �FreeBSD</A><BR>
� � � � <A HREF="/lists/3/FreeBSD/145/0/"><IMG SRC="/img/ofolder.png" HEIGHT=13 WIDTH=15 BORDER=0> �<B>freebsd-bugs - Bug Reports</B></A><BR>
</TD><TD ROWSPAN=2 BGCOLOR="#EFEFEF" NOWRAP><B>Archive</B><BR> <A HREF="/archives/3/145/2001/"><IMG SRC="/img/cfolder.png" HEIGHT=13 WIDTH=15 BORDER=0>�2001 (8659 msgs)</A><BR>
<A HREF="/archives/3/145/2000/"><IMG SRC="/img/cfolder.png" HEIGHT=13 WIDTH=15 BORDER=0>�2000 (8572 msgs)</A><BR>
<A HREF="/archives/3/145/1999/"><IMG SRC="/img/cfolder.png" HEIGHT=13 WIDTH=15 BORDER=0>�1999 (7137 msgs)</A><BR>
<A HREF="/archives/3/145/1998/"><IMG SRC="/img/cfolder.png" HEIGHT=13 WIDTH=15 BORDER=0>�1998 (6318 msgs)</A><BR>
<A HREF="/archives/3/145/1997/"><IMG SRC="/img/cfolder.png" HEIGHT=13 WIDTH=15 BORDER=0>�1997 (6418 msgs)</A><BR>
<A HREF="/archives/3/145/1996/"><IMG SRC="/img/cfolder.png" HEIGHT=13 WIDTH=15 BORDER=0>�1996 (5148 msgs)</A><BR>
<A HREF="/archives/3/145/1995/"><IMG SRC="/img/cfolder.png" HEIGHT=13 WIDTH=15 BORDER=0>�1995 (3586 msgs)</A><BR>
<A HREF="/archives/3/145/1994/"><IMG SRC="/img/cfolder.png" HEIGHT=13 WIDTH=15 BORDER=0>�1994 (3 msgs)</A><BR>
</TD>
</TR>
<TR>
<TD ALIGN=LEFT>
<FORM ACTION="/search/" METHOD="GET">
<INPUT TYPE="hidden" NAME="config" value="145">
<INPUT TYPE="TEXT" NAME="words" VALUE=""SIZE=20 MAXLENGTH=25>
�
<INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="Search freebsd-bugs">
</TD>
</TR>
</FORM>
</TABLE>
<H3>Thread: <A HREF="/mail/thread.php3?subject=kern%2F8500%3A+FreeBSD+3.0+thread+scheduler+is+broken&list=145">kern/8500: FreeBSD 3.0 thread scheduler is broken</A></H3><P>
<B><A HREF="/mail/msg_raw.php3?msg_id=623609">Print</A> | <A HREF="/login/monitor.php3?list=145">Monitor This List</A>
| <A HREF="/login/msg_reply.php3?msg_id=623609">Reply To Author</A>
</B><P><TABLE cellspacing="0" cellpadding="2" width="100%">
<TR><TD align=CENTER bgcolor="#666699">
<TABLE WIDTH="100%" CELLPADDING="2" CELLSPACING="0" BGCOLOR="#FFFFFF">
<TR BGCOLOR="#666699"><TD><FONT COLOR="#FFFFFF">Message: 623609</TD></TR>
<TR><TD><PRE>FROM: Peter Wemm<BR>DATE: 10/31/1998�13:10:00<BR>SUBJECT: RE: kern/8500: FreeBSD 3.0 thread scheduler is broken<P>�<P><PRE><FONT FACE="COURIER">The following reply was made to PR kern/8500; it has been noted by GNATS.
From: Peter Wemm <<A HREF="/
[email protected]_p_a_m"><EMAIL: PROTECTED></A>>
To: HighWind Software Information <<A HREF="/
[email protected]_p_a_m"><EMAIL: PROTECTED></A>>
Cc: <A HREF="/
[email protected]_p_a_m"><EMAIL: PROTECTED></A>
Subject: Re: kern/8500: FreeBSD 3.0 thread scheduler is broken
Date: Sun, 01 Nov 1998 03:08:44 +0800
HighWind Software Information wrote:
>
> > >Number: 8500
> > >Category: kern
> > >Synopsis: FreeBSD 3.0 thread scheduler is broken
> >
> > >Description:
> > When an application has threads that are I/O intensive, that thread
> > unfairly steals cycles from all other threads. This makes writing
> > an MT program that does any real amount of I/O impossible.
>
> Yes, open(), read(), write(), etc block the entire process. The libc_r
> thread engine only works for things that can be select()ed apon, and read/
> write cannot (yet).
>
> Ummm. Not to be rude.. But...
>
> That is NOT TRUE AT ALL. read() and write() CERTAINLY are selected
> apon and do NOT block the whole process when using libc_r.
>
> Read /usr/src/lib/libc_r/uthread/uthread_write.c and see for yourself.
Yes, but only if the file descriptor itself supports O_NONBLOCK mode..
/* called by open() wrapper */
_thread_fd_table_init(int fd)
{ ...
/* Get the flags for the file: */
if (fd >= 3 && (entry->flags =
_thread_sys_fcntl(fd, F_GETFL, 0)) == -1) {
ret = -1;
}
else {
...
}
And in write(), it just calls the write system call:
write()
{
....
/* Check if file operations are to block */
blocking = ((_thread_fd_table[fd]->flags & O_NONBLOCK) == 0);
/*
* Loop while no error occurs and until the expected number
* of bytes are written if performing a blocking write:
*/
while (ret == 0) {
/* Perform a non-blocking write syscall: */
^^^^^^^^^^^^^^^^^ - only if opened in O_NONBLOCK
n = _thread_sys_write(fd, buf + num, nbytes - num);
/* Check if one or more bytes were written: */
if (n > 0)
It`s similar for read().
There`s a couple of big ifs so far. *If* you open the file in O_NONBLOCK
mode specifically, then you get non-blocking read/write syscalls. The
syscalls themselves are only non-blocking *if* the underlying fd supports
it. Sockets and pipes support it. Files (at least on ufs/ffs) do not.
No matter whether you ask for O_NONBLOCK or not, you will always get a
blocking read/write with disk IO with read and write.
> The only alternatives are to use the aio/lio syscalls (which work), or
> rfork(). libc_r could probably be modified to use rfork() to have the
> read/write/open/close/etc done in parallel.
>
> I don`t think that is necessary.
It is if you want the threading to continue while the disk is grinding
away. aio_read() and aio_write() would probably be enough to help file
IO, but open() will still be blocking.
Squid has some fairly extensive async disk-IO routines. They happen to
use pthreads as a mechanism of having child processes do the blocking
work. FreeBSD could use rfork() for arranging the blocking stuff in child
processes with shared address space. It would be a lot of work though,
and would be a problem on SMP systems.
> -Rob
Cheers,
-Peter
To Unsubscribe: send mail to <A HREF="/
[email protected]_p_a_m"><EMAIL: PROTECTED></A>
with "unsubscribe freebsd-bugs" in the body of the message
</PRE></TD></TR></TABLE></TD></TR></TABLE>
<P>
</TD>
</TR>
</TABLE>
<P>
<TABLE BORDER=0 WIDTH="100%" ALIGN="center" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD BGCOLOR="#666699"><IMG SRC="/img/clear.gif" width="1" height="3"></TD>
</TR>
<TR>
<TD ALIGN="CENTER">
<P>�<BR>
<FONT size="-1"><A
href="
http://www.osdn.com/terms.shtml#copy">Copyright</A>1999-2001 Open
Source Development Network. All rights reserved.<BR>
<A href="
http://www.osdn.com/advertise/">Advertising</A>��<A
href="
http://www.osdn.com/privacy.shtml">Privacy
Statement</A>��<A
href="
http://www.osdn.com/terms.shtml">Terms of Use</A></FONT>
<BR>
�
</TD>
</TR>
</TABLE>
<P>
<CENTER>
<TABLE border=0 cellpadding=0><TR><TD>
<ILAYER id="adilayer2" width="472" height="64" visibility="hide"></ILAYER></NOLAYER>
</TD></TR></TABLE>
</CENTER>
<LAYER id="adlayer1" src="
http://geoads.osdn.com/1.html" visibility='hide' onLoad="moveToAbsolute(adilayer1.pageX,adilayer1.pageY); clip.height=60; clip.width=468; visibility='show';"></LAYER><LAYER id="adlayer2" src="
http://geoads.osdn.com/5.html" visibility='hide' onLoad="moveToAbsolute(adilayer2.pageX,adilayer2.pageY); clip.height=64; clip.width=472; visibility='show';"></LAYER>
</BODY>
</HTML>