194 lines
4.2 KiB
HTML
194 lines
4.2 KiB
HTML
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||
|
<HTML
|
||
|
><HEAD
|
||
|
><TITLE
|
||
|
>How does my computer do several things at once?</TITLE
|
||
|
><META
|
||
|
NAME="GENERATOR"
|
||
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
|
||
|
REL="HOME"
|
||
|
TITLE="The Unix and Internet Fundamentals HOWTO"
|
||
|
HREF="index.html"><LINK
|
||
|
REL="PREVIOUS"
|
||
|
TITLE="How do input devices and interrupts work?"
|
||
|
HREF="devices.html"><LINK
|
||
|
REL="NEXT"
|
||
|
TITLE="How does my computer keep processes from stepping on each other?"
|
||
|
HREF="memory-management.html"></HEAD
|
||
|
><BODY
|
||
|
CLASS="sect1"
|
||
|
BGCOLOR="#FFFFFF"
|
||
|
TEXT="#000000"
|
||
|
LINK="#0000FF"
|
||
|
VLINK="#840084"
|
||
|
ALINK="#0000FF"
|
||
|
><DIV
|
||
|
CLASS="NAVHEADER"
|
||
|
><TABLE
|
||
|
SUMMARY="Header navigation table"
|
||
|
WIDTH="100%"
|
||
|
BORDER="0"
|
||
|
CELLPADDING="0"
|
||
|
CELLSPACING="0"
|
||
|
><TR
|
||
|
><TH
|
||
|
COLSPAN="3"
|
||
|
ALIGN="center"
|
||
|
>The Unix and Internet Fundamentals HOWTO</TH
|
||
|
></TR
|
||
|
><TR
|
||
|
><TD
|
||
|
WIDTH="10%"
|
||
|
ALIGN="left"
|
||
|
VALIGN="bottom"
|
||
|
><A
|
||
|
HREF="devices.html"
|
||
|
ACCESSKEY="P"
|
||
|
>Prev</A
|
||
|
></TD
|
||
|
><TD
|
||
|
WIDTH="80%"
|
||
|
ALIGN="center"
|
||
|
VALIGN="bottom"
|
||
|
></TD
|
||
|
><TD
|
||
|
WIDTH="10%"
|
||
|
ALIGN="right"
|
||
|
VALIGN="bottom"
|
||
|
><A
|
||
|
HREF="memory-management.html"
|
||
|
ACCESSKEY="N"
|
||
|
>Next</A
|
||
|
></TD
|
||
|
></TR
|
||
|
></TABLE
|
||
|
><HR
|
||
|
ALIGN="LEFT"
|
||
|
WIDTH="100%"></DIV
|
||
|
><DIV
|
||
|
CLASS="sect1"
|
||
|
><H1
|
||
|
CLASS="sect1"
|
||
|
><A
|
||
|
NAME="multitasking"
|
||
|
></A
|
||
|
>7. How does my computer do several things at once?</H1
|
||
|
><P
|
||
|
>It doesn't, actually. Computers can only do one task (or
|
||
|
<I
|
||
|
CLASS="firstterm"
|
||
|
>process</I
|
||
|
>) at a time. But a computer can change tasks
|
||
|
very rapidly, and fool slow human beings into thinking it's doing several
|
||
|
things at once. This is called
|
||
|
<I
|
||
|
CLASS="firstterm"
|
||
|
>timesharing</I
|
||
|
>.</P
|
||
|
><P
|
||
|
>One of the kernel's jobs is to manage timesharing. It has a part
|
||
|
called the
|
||
|
<I
|
||
|
CLASS="firstterm"
|
||
|
>scheduler</I
|
||
|
>
|
||
|
which keeps information inside itself about all the other (non-kernel)
|
||
|
processes in your zoo. Every 1/60th of a second, a timer goes off in the
|
||
|
kernel, generating a clock interrupt. The scheduler stops whatever process
|
||
|
is currently running, suspends it in place, and hands control to another
|
||
|
process.</P
|
||
|
><P
|
||
|
>1/60th of a second may not sound like a lot of time. But on today's
|
||
|
microprocessors it's enough to run tens of thousands of machine
|
||
|
instructions, which can do a great deal of work. So even if you have many
|
||
|
processes, each one can accomplish quite a bit in each of its
|
||
|
timeslices.</P
|
||
|
><P
|
||
|
>In practice, a program may not get its entire timeslice. If an
|
||
|
interrupt comes in from an I/O device, the kernel effectively stops the
|
||
|
current task, runs the interrupt handler, and then returns to the current
|
||
|
task. A storm of high-priority interrupts can squeeze out normal
|
||
|
processing; this misbehavior is called <I
|
||
|
CLASS="firstterm"
|
||
|
>thrashing</I
|
||
|
> and
|
||
|
is fortunately very hard to induce under modern Unixes.</P
|
||
|
><P
|
||
|
>In fact, the speed of programs is only very seldom limited by the
|
||
|
amount of machine time they can get (there are a few exceptions to this
|
||
|
rule, such as sound or 3-D graphics generation). Much more often, delays
|
||
|
are caused when the program has to wait on data from a disk drive or
|
||
|
network connection.</P
|
||
|
><P
|
||
|
>An operating system that can routinely support many simultaneous
|
||
|
processes is called <SPAN
|
||
|
CLASS="QUOTE"
|
||
|
>"multitasking"</SPAN
|
||
|
>. The Unix family of operating
|
||
|
systems was designed from the ground up for multitasking and is very good
|
||
|
at it — much more effective than Windows or the old Mac OS, which both
|
||
|
had multitasking bolted into them as an afterthought and do it rather poorly.
|
||
|
Efficient, reliable multitasking is a large part of what makes Linux
|
||
|
superior for networking, communications, and Web service.</P
|
||
|
></DIV
|
||
|
><DIV
|
||
|
CLASS="NAVFOOTER"
|
||
|
><HR
|
||
|
ALIGN="LEFT"
|
||
|
WIDTH="100%"><TABLE
|
||
|
SUMMARY="Footer navigation table"
|
||
|
WIDTH="100%"
|
||
|
BORDER="0"
|
||
|
CELLPADDING="0"
|
||
|
CELLSPACING="0"
|
||
|
><TR
|
||
|
><TD
|
||
|
WIDTH="33%"
|
||
|
ALIGN="left"
|
||
|
VALIGN="top"
|
||
|
><A
|
||
|
HREF="devices.html"
|
||
|
ACCESSKEY="P"
|
||
|
>Prev</A
|
||
|
></TD
|
||
|
><TD
|
||
|
WIDTH="34%"
|
||
|
ALIGN="center"
|
||
|
VALIGN="top"
|
||
|
><A
|
||
|
HREF="index.html"
|
||
|
ACCESSKEY="H"
|
||
|
>Home</A
|
||
|
></TD
|
||
|
><TD
|
||
|
WIDTH="33%"
|
||
|
ALIGN="right"
|
||
|
VALIGN="top"
|
||
|
><A
|
||
|
HREF="memory-management.html"
|
||
|
ACCESSKEY="N"
|
||
|
>Next</A
|
||
|
></TD
|
||
|
></TR
|
||
|
><TR
|
||
|
><TD
|
||
|
WIDTH="33%"
|
||
|
ALIGN="left"
|
||
|
VALIGN="top"
|
||
|
>How do input devices and interrupts work?</TD
|
||
|
><TD
|
||
|
WIDTH="34%"
|
||
|
ALIGN="center"
|
||
|
VALIGN="top"
|
||
|
> </TD
|
||
|
><TD
|
||
|
WIDTH="33%"
|
||
|
ALIGN="right"
|
||
|
VALIGN="top"
|
||
|
>How does my computer keep processes from stepping on each other?</TD
|
||
|
></TR
|
||
|
></TABLE
|
||
|
></DIV
|
||
|
></BODY
|
||
|
></HTML
|
||
|
>
|