Lecture2 Introduction To Linux
Lecture2 Introduction To Linux
Lecture No. 2
By Dr. Anwar M. Mirza
Date: August 13, 2009
An Introduction to Linux
Some Facts and Figures:
It is generally said in the OS community that there are more flavors of Unix than most
brands of ice cream! “Linux” belongs to this large family of Unix-like operating systems
such as:
His main aim was to develop a Unix like operating system for IBM compatible
Personal Computers based on Intel’s 80386 microprocessor.
Linux is now available on other architectures including DEC-Alpha, Sun-SPARC,
Motorola MC680X0, Apple’s PowerPC and IBM’s system/390.
1. Linux is free
You can install a complete Unix system at no expense. (Other than the
hardware of course”).
2. Linux is fully customizable in all its components.
You are allowed to freely read and modify the source code of the Kernel and
of all system programs.
3. Linux runs on low-end, cheap hardware platforms
You can even build a network server using an old Intel 80386 with 4MB
RAM.
4. Linux is powerful
Linux systems are very fast, since they fully exploit the features of the
hardware components.
5. Linux has a high standard for source code quality
Linux systems are usually “very stable”; they have a “low failure rate” and
“low system maintenance time”.
6. The Linux Kernel can be very small and compact
Indeed, it is possible t fit both a Kernel image and full root file system
including all fundamental system programs on just one 1.4 MB floppy disk!
None of other commercial Unix variants is able to boot from a single floppy
disk.
7. Linux is highly compatible with many common operating systems
It lets us mount file systems from all versions of MS DOS and MS
WINDOWS, SVR4, OS2, MacOS, Solaris, SunOS, BSD etc.
It is able to operate with many network layers like Ethernet, IBM’s
Token ring etc.
By using suitable libraries, Linux systems are even able to directly run
programs written for other operating systems (like MS DOS, MS
WINDOWS, SVR3 and SVR4, 4.4BSD, SCO Unix, XENIX etc for
Intel’s 80x86 platform).
8. Linux is well-supported
It is lot easier to get patches and updates for Linux than for any other
proprietary operating system.
Level of Description:
The textbooks referred to in this course do not (in fact cannot possible) cover
all lines of this code. Dozens of books will indeed be required, simply to show
all lines of this code.
We will try to cover only few MB of this code------ to get to know the
essentials of how Linux works!
PROCESSING ENVIRONMENT:
1. PROCESS IDENTIFIERS:
Examples are:
PID BSD Unix Solaris Red Hat Linux
0 “Swapper” “Sched” ??????
process responsible Process
for scheduling
Processes are assigned free PIDs of increasing value until the maximum
system value for a process ID is reached.
When the maximum value of PID has been assigned, the system wraps around
and begins to use lower process IDs that are not currently used.
The system call getpid is used to obtain PID. Declared in the system header
file <unistd.h>, the prototype of getpid is
pid_t getpid(void);
b) PARENT PROCESS ID (PPID):
For example, should a process group leader receive a “kill” or “hang-up” signal
causing it to terminate, then all processes in its group will also be passed the same
terminating signal.
A process can find its process group ID from the system call getpgid.
Its prototype in <unistd.h> is :
pid_t getpgid(pid_t pid);
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
EXERCISE 2.2
The manual page entry for the getppid system call does not specially indicate
what is returned by getppid if the parent process is no longer present when the
getppid call is made. Write a program that displays the value returned by getppid
when such an event occurs (the parent predeceases the child). How did you assure that
the parent was not present when the child process made its getppid call?