UNIX Case Study PDF
UNIX Case Study PDF
Submitted By
AKASH KUMAR CHOUDHARY – 1714110106
Roll No. - 14
A Report on
Types of UNIX
There are many different versions of UNIX, although they share common similarities.
The most popular varieties of UNIX are Sun Solaris, GNU/Linux, and MacOS X. Here
in the School, we use Solaris on our servers and workstations, and Fedora Core Linux
on the servers and desktop PCs.
History of UNIX
1969: Ken Thompson, Dennis Ritchie started working on a multi-user OS on
PDP-7, Bell Labs.
1970: OS named as UNIX
1973: OS rewritten in C
1975: First Version of Berkeley Software Distribution (BSD)
1982: AT&T announced UNIX System III, first public release.
1983: AT&T announced UNIX System V, the first supported release.
1984: Berkeley releases 4.2BSD, includes TCP/IP. X/Open formed
1984: System V Release 2 introduced. 1,00,000 installations worldwide.
1986: 4.3BSD released, including internet name server. Installed base
2,50,000
1987: System V Release 3 introduced. Around 7, 50,000 installations.
1988: Open Software Foundation formed.
1989: System V Release 4 ships unifying System V, BSD 1.2 million
installations.
Layered Architecture:
UNIX is a layered operating system. The innermost layer is the hardware that
provides the services for the OS. The operating system, referred to in UNIX as the
kernel, interacts directly with the hardware and provides the services to the
user programs. Most well written user programs are independent of the
underlying hardware, making them readily portable to new systems.
Layered Architecture of the UNIX System You can have many users logged into a
system simultaneously, each running many programs. It's the kernel's job to keep
each process and user separate to regulate access to system hardware, including
CPU, memory, disk and other I/O devices.
The main concept that unites all the versions of Unix is the following four basics −
Kernel − The kernel is the heart of the operating system. It interacts with the
hardware and most of the tasks like memory management, task scheduling and file
management.
Shell − The shell is the utility that processes your requests. When you type in a
command at your terminal, the shell interprets the command and calls the program
that you want. The shell uses standard syntax for all commands. C Shell, Bourne Shell
and Korn Shell are the most famous shells which are available with most of the Unix
variants.
Commands and Utilities − There are various commands and utilities which you can
make use of in your day to day activities. cp, mv, cat and grep, etc. are few examples
of commands and utilities. There are over 250 standard commands plus numerous
others provided through 3rd party software. All the commands come along with
various options.
Files and Directories − All the data of Unix is organized into files. All files are then
organized into directories. These directories are further organized into a tree-like
structure called the filesystem.
UNIX System Calls
The UNIX operating system has two separable parts: the kernel and the service programs.
User programs interact with the kernel through a set of standard system calls. These system
calls request services to be provided by the kernel. Such services would include accessing a
file: open close, read, write, link, or execute a file; starting or updating accounting records;
changing ownership of a file or directory; changing to a new directory; creating, suspending,
or killing a process; enabling access to hardware devices; and setting limits on system
resources. The kernel provides control of file system, CPU scheduling, memory management,
and other operating system functions through system calls. System calls de fine the
programmer interface to operating system; the set of systems programs commonly available
defines the user interface. System calls also provide the interface between a running program
and the operating system. The C language allows system calls to be made directly. Typical
system calls are:
Header Files:
Header files define how a system call works. A header file contains a definition of the system
call, and the parameters (variables) required by the call, and the parameters returned by the
system call.
C shell (csh)
Written at the University of California, Berkley. As it name indicates, it provides a C
like language with which to write shell scripts.
TC Shell (tcsh)
Available in the public domain. It provides all the features of the C shell together with
EMACS style editing of the command line.
2. ls — Use the "ls" command to know what files are in the directory you are in. You can see
all the hidden files by using the command “ls -a”.
3. cd — Use the "cd" command to go to a directory. For example, if you are in the home
folder, and you want to go to the download folder, then you can type in “cd Downloads”.
Remember, this command is case sensitive, and you have to type in the name of the folder
exactly as it is.
4. mkdir & rmdir — Use the mkdir command when you need to create a folder or a
directory. Use rmdir to delete a directory. But rmdir can only be used to delete an empty
directory.
5. rm - Use the rm command to delete files and directories. Use "rm -r" to delete just the
directory.
6. touch — The touch command is used to create a file. It can be anything, from an empty txt
file to an empty zip file. For example, “touch new.txt”.
7. man — To know more about a command and how to use it, use the man command. It
shows the manual pages of the command.
8. cp — Use the cp command to copy files through the command line. It takes two arguments:
The first is the location of the file to be copied, the second is where to copy.
9. mv — Use the mv command to move files through the command line. It takes the two
arguments, just like the cp command.
10. locate — The locate command is used to locate a file in a Linux system, just like the
search command in Windows. Using the -i argument with the command helps to ignore the
case (it doesn't matter if it is uppercase or lowercase). So, if you want a file that has the word
“hello”, it gives the list of all the files in your Linux system containing the word "hello" when
you type in “locate -i hello”. If you remember two words, you can separate them using an
asterisk (*). For example, to locate a file containing the words "hello" and "this", you can use
the command “locate -i *hello*this”.
Memory Management
Swapping
1. Easy to implement
Demand Paging
1. Greater flexibility
Swapping
The swap device is a block device in a configurable section of a disk
Kernel allocates contiguous space on the swap device without fragmentation.
It maintains free space of the swap device in an in-core table, called map.
The kernel treats each unit of the swap map as group of disk blocks.
As kernel allocates and frees resources, it updates the map accordingly
Demand Paging
Locality
When a process accesses a page that is not part of its working set, it incurs a page fault.
The kernel suspends the execution of the process until it reads the page into memory
and makes it accessible to the process.
Interrupts:
Interrupts are signal that are sent across IRQ (Interrupt Request Line) by a hardware or
software. Interrupts allow devices like keyboard, serial cards and parallel ports to indicate
that it needs CPU attention. Once the CPU receives the Interrupt Request, CPU will
temporarily stop execution of running program and invoke a special program called Interrupt
Handler or ISR (Interrupt Service Routine).
The Interrupt Service or Interrupt Handler Routine can be found in Interrupt Vector table
that is located at fixed address in the memory. After the interrupt is handled CPU resumes the
interrupted program. At boot time, system identifies all devices, and appropriate interrupt
handlers are loaded into the interrupt table.
The following are two ways of requesting CPU attention:
1. Interrupt based
2. Polling based
All Linux based OS are interrupt driven. When we press a key on keyboard, keyboards says to
CPU that a key has been pressed. But CPU can be busy processing some stuff from RAM,
System Clock, NIC card, may be video or PCI bus. In that case Keyboard places a voltage on
IRQ line assigned to that hardware, here in this case [Keyboard]. This change in voltage
serves as request from device saying that device has a request that needs processing.
IRQ number determines the priority of the interrupt that needs to be handled by the CPU. A
small IRQ number value means higher priority. For example if CPU receives interrupt from
Keyboard and system clock simultaneously. CPU will serve System Clock first since it has IRQ
number 0.
Hardware Interrupts
All of the above discussed scenarios are example of Hardware interrupts.
Hardware interrupts are further classified into two major categories:
1. Non-maskable interrupts [NMI]: As the name suggests these types of interrupts
cannot be ignored or suppressed by the CPU. MNI’s are send over separate interrupt
line and it’s generally used for critical hardware errors like memory error, Hardware
traps indicating Fan failure, Temperature Sensor failure etc.
2. Maskable interrupts: These interrupts can be ignored or delayed by CPU. The
Interrupt Mask Register masks the interrupts being triggered on external pins of cache
controller. Setting a bit by writing a 0, disables the interrupt triggering on the pin
Software Interrupts
These interrupts are generated when the CPU executes an instruction which can cause an
exception condition in the CPU [ALU unit] itself. For example, divide a number by zero which
is not possible, it will lead to divide-by-zero exception, causing the computer to abandon the
calculation or display an error message.
The file /proc/stat is also a file part of the /proc filesystem, which has information about
system kernel statistics, also holds some interrupt information.
References:
1. Unix.org
2. http://marketshare.hitslink.com/operating-system-market-
share.aspx?qprid=8&qpcustomd=0
3. http://marketshare.hitslink.com/operating-system-market-
share.aspx?qprid=8&qpcustomd=0
4. www.studymafia.org