<HTML>
<HEAD>
   <TITLE>Linux Threads Home Page: What kinds of things should be threaded or multitasked?</TITLE>
</HEAD>
<BODY BACKGROUND="GraySea.gif">

<P><FONT SIZE=+3>What kinds of things should be threaded or multitasked?</FONT></P>

<UL>
<P>If you are a programmer and would like to take advantage of multithreading,
the natural question is what parts of the program should/ should not be
threaded. Here are a few rules of thumb (if you say &quot;yes&quot; to
these, have fun!):</P>

<UL>
<LI>Are there groups of <I>lengthy</I> operations that don't necessarily
depend on other processing (like painting a window, printing a document,
responding to a mouse-click, calculating a spreadsheet column, signal handling,
etc.)?</LI>

<LI>Will there be few locks on data (the amount of shared data is identifiable
and &quot;small&quot;)?</LI>

<LI>Are you prepared to worry about locking (mutually excluding data regions
from other threads), deadlocks (a condition where two COEs have locked
data that other is trying to get) and race conditions (a nasty, intractable
problem where data is not locked properly and gets corrupted through threaded
reads &amp; writes)?</LI>

<LI>Could the task be broken into various &quot;responsibilities&quot;?
E.g. Could one thread handle the signals, another handle GUI stuff, etc.?</LI>
</UL>
</UL>

<P><HR SIZE=4 WIDTH="100%"></P>
<CENTER><TABLE CELLSPACING=0 CELLPADDING=0 >
<TR>
<TD><A HREF="LinusCode.html"><CENTER><IMG SRC="ArrowLeft.gif" ALT="[Left Arrow]" BORDER=0 HEIGHT=40 WIDTH=40></CENTER></A></TD>
<TD><A HREF="index.html"><CENTER><IMG SRC="House.gif" ALT="[Home]" BORDER=0 HEIGHT=40 WIDTH=40></CENTER></A></TD>
<TD><A HREF="Dictionary.html"><CENTER><IMG SRC="BookSearch.gif" ALT="[Book Search]" BORDER=0 HEIGHT=40 WIDTH=40></CENTER></A></TD>
<TD><A HREF="mailto:walton@oclc.org"><CENTER><IMG SRC="MailBox.gif" ALT="[Mailbox]" BORDER=0 HEIGHT=40 WIDTH=40></CENTER></A></TD>
<TD><A HREF="ThreadLibs.html"><CENTER><IMG SRC="ArrowRight.gif" ALT="[Right Arrow]" BORDER=0 HEIGHT=40 WIDTH=40></CENTER></A></TD>
</TR>
<TR>
<TD><A HREF="LinusCode.html">[Previous Page]</A></TD>
<TD><A HREF="index.html">[First Page]</A></TD>
<TD><A HREF="Dictionary.html">[Dictionary]</A></TD>
<TD><A HREF="mailto:walton@oclc.org">[Email Author]</A></TD>
<TD><A HREF="ThreadLibs.html">[Next Page]</A></TD>
</TR>
</TABLE></CENTER>

</BODY></HTML>
