Re: [SLUG] multitasking in linux

From: Bryan-TheBS-Smith (b.j.smith@ieee.org)
Date: Mon Oct 15 2001 - 11:01:59 EDT


Justin Keyes wrote:
> I've read that Linux is a "true multi-tasking operating system."
> (I guess they meant "kernel"... or, if multi-tasking is handled
> by the operating system, then they meant GNU).

Linux/UNIX has always been not only a "true multi-tasking" OS, but a
"true multi-user" OS.

True multi-tasking OSes allow the kernel to pre-empty all other
operations to maintain stability. It also means that the kernel
handles all direct access to hardware and other resources. On the
Intel i386 hardware, only the kernel can control the memory
management unit (MMU) functions of the processor. In fact, the
first general OS to take full advantage of the i386 MMU was Linux.

[ Side note: Linus basically wrote it against the Intel 386
Programmers' Guide, and was chastized by one very respected
authority on OS/architecture design (Andrew S. Tannebaum, had two of
his books in college ;-). What Tannebaum and other CS researchers
failed to realize is that the i386 MMU became a model that most
other processors followed in the 90s and on-ward. Today, we have
uCLinux (microcontroller Linux) for processors without an MMU, like
certain ARM chips, old 186/286 processors, etc... ]

True multi-user OSes allow multiple users to run full interactive
sessions simultaneously. UNIX further enhances this by having a
network-aware GUI (X-Windows) and network-aware 3D API (GLX, OpenGL
on X-Windows) that allows systems without graphics hardware to
display their buffers/renderings on other systems -- including
multiple buffers/frames of different users simultaneously.

Now when it comes to multi-threading, the Linux kernel is NOT
multi-threaded. We also call this re-entrant, where more than one
process can use a kernel service at the same time. It is also a
monolithic, non micro-kernel architecture. This is in stark
contrast to traditional CS though. Linus has proven time and time
again that monolithic kernels are not only much simplier to design,
debug and write drivers for (all very important for stability), but
can actually outperform multi-threaded/micro-kernel designs under
even heavy loads because of overhead issues.

The Linux 2.4 kernel uses some very unique approaches to handling
heavy loads, especially in the VM subsystem and IP stack. The
former has led to some "nagging issues" in 2.4.x that are slowly
being worked out. For multi-processor, the kernel is actually
partially re-entrant, which allows different processors to use the
same kernel routines simultaneously. AFAIK, Linux is the only OS
that takes this approach -- it is "virtually multi-threaded" on
multiprocessors because each processor has its own entry. I think
this is yet another innovative approach where Linus smashes
traditional CS thought and does better!

Now the GNU C Libraries (GLibC), the "main" libraries that all
programs are compiled against when developed with the GNU Toolchain
(99.9% of Linux programs), _are_ fully multi-threaded as of version
2 (e.g., RedHat 5+). This improved multi-tasking significantly 5
years ago.

There is a multi-threaded, "hard" real-time capable Linux kernel mod
called RT/Linux that is basically compiled as a Linux module, but is
actually the controlling, pre-emptive kernel that runs the full
monolithic kernel atop it. Long story on that one, but I believe
that the number of applications that need RT/microkernels are
extremely limited. And when you do need them, RT/Linux fits the
bill.

[ Side note: The RTAI modification, based on the RT/Linux approach,
allows much of the kernel to be transitioned to a "soft" real-time
one. Again, long story. ]

> What does this mean exactly when compared to windows?

MS-DOS, including MS-DOS 7.x (aka Windows 9x/ME) uses a "task
switching" mechanism where programs must "give up" control for the
next program to work. One program can bring down the whole system.
Programs can also directly access hardware. This includes the MMU
of the i386 in some instances. In fact, the way MS-DOS' "task
switching" works on the i386 is by switching between protected mode
and virtual x86 mode constantly.

NT, including version 5 (aka Windows 2000) and 6 (aka XP), use a
true multi-tasking kernel. Unfortunately, it is not a true
multi-user kernel. Citrix introduced a pseudo-multi-user
implementation with WinFrame, which is now the basis of NT Terminal
Server. But the security implementation and overall handling of
multi-user in WinFrame/NTTS is nowhere near that of UNIX/Linux
(e.g., you'd _never_ put a WF/NTTS system on the Internet for
security reasons).

Despite published reports, NT is monolithic, like Linux, although it
does have threaded libraries like GLibC. And like Linux, there is a
pre-emptive, micro-kernel 3rd party implementation you can run to
get "soft" real-time on NT, actually 2 different products. Not
surprisingly, they both use the RT/Linux approach and are licensees
of the FSMLabs' patent (the guys behind RT/Linux).

> I've noticed that I love the way GNU/Linux handles programs compared
> to windows.... but what exactly is the underlying difference?

I think I've answered most questions above. Feel free to post
follow-ups.

> Also, how exactly does the linux kernel, the gnu operating system, and
> the bash shell (and anything I'm missing) work together?

The kernel is the master of the system. It is the only program that
is always in memory.

GNU is the support library, development system, select programs.
It's user-space, although very important still.

Bash is just another user-space program that provides a basic
interface layer for users. It's not required at all.

-- TheBS

-- 
Bryan "TheBS" Smith    mailto:b.j.smith@ieee.org   chat:thebs413
Engineer  AbsoluteValue Systems, Inc.  http://www.linux-wlan.org
President     SmithConcepts, Inc.   http://www.SmithConcepts.com
----------------------------------------------------------------
The US recording and software industries have choosen to "honor"
the victims of 9/11 by pushing their political agendas even fur-
ther through so-called "anti-terrorism" legislation in Congress.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 15:20:10 EDT