Layers (concentric circles) of Unix: [hardware], kernel,
utilities, shell , user.
Kernel: the operating system proper
--controls processes (creation, scheduling, deletion)
--controls/manages devices (i.e. I/O), CPU, and memory
--manages the file system
Accessible via ~200 system calls (requests for
service, e.g. function calls in C to do device I/O, process
creation/deletion, memory allocation/deallocation, file
creation/access, signal handling). Different Unixes have compatible
system calls but their implementation and system architecture
(internals) can differ. To a program(mer) the system calls
are the system. Shell and utilities use the system calls.
Kernel is the OS. All else is built on top of and from it.
Loaded at boot time. /vmunix or /boot/vmlinuz file.
Original versions were 10,000 lines of C code with 1000 lines of
assembly code for hardware functions unavailable or inconvenient in
C. [Now? cf Multics, Windows]
Linux (strictly is only the kernel): highly customizable, can compile the source with the exact
level and mix of support for the devices and services needed.
Shell:
--command interpreter : prompts user, interprets (parses) the
command line, arranges for command to be carried out (passes
requests to kernel).
--a command line interface between user and kernel.
(a GUI desktop environment (e.g. KDE, GNOME, Aqua) is
also an interface between user and kernel)
--several available: sh (Bourne), csh (C shell and tcsh), ksh
(Korn shell), bash (GNU), etc.
--programmable. Quick and easy programming (scripting), esp. for
file manipulation (themselves and their contents). Can program on
the command line.
--very flexible and thus powerful. vs GUI
what-you-see-is-all-you-get
shell provides services to user. kernel provides services to
programs, including the shell.
The different shells have different syntax. C shell has C-like
syntax and better interaction. Bourne shell is the original. Korn
shell and bash have C shell facilities but in Bourne shell syntax
and are almost POSIX standard.
Reasons to know shell: 1. remote login via telnet or ssh.
2. no GUI available or needed. 3. fast 4. commands that have no GUI
equivalent
Utilities: commands/tools/applications, e.g. compilers,
editors, file manipulation, text formatters/typesetters,
spreadsheets, DBMS, communications, servers, CAD, games, browser
etc.
Users: programs become utilities. Extend Unix.
User programs not distinguished from system programs. eg. your own
ls or more commands. [Exception are commands that require
privilege, eg. passwd via setuid]
CPU in user mode (bit flag in processor) when shell,
utility, or user program executing. Request for OS service issued
with system call (e.g. functions available in C: software
interrupt). CPU switches to kernel mode, performs the
service, returns to caller in user mode. Certain operations, e.g.
I/O instructions and system tables' access, only allowed when in
kernel mode. I/O devices and timers can also signal request
(interrupt) for kernel service. User mode processes can
generate errors (traps) that cause switch to kernel mode;
such errors include attempting to access another process's memory,
accessing memory that is not resident in memory (page
fault), processor errors such as divide by zero and illegal
instruction.