THEJAS KUMAR.
B
711720205053
OPERATING SYSTEM
CASE STUDY: LINUX
A. Development of Linux:
Before Linux:
In 80’s, Microsoft’s DOS was the dominated OS for PC
single-user, single-process system
Apple MAC is better, but expensive
UNIX is much better, but much much expensive. Only for minicomputer for commercial
applications
People was looking for a UNIX based system, which is cheaper and can run on PC
Both DOS, MAC and UNIX are proprietary, i.e., the source code of their kernel is protected
Beginning of Linux:
A famous professor Andrew Tanenbaum developed Minix, a simplified version of UNIX that
runs on PC
Minix is for class teaching only. No intention for commercial use
In Sept 1991, Linus Torvalds, a second year student of Computer Science at the University of
Helsinki, developed the preliminary kernel of Linux, known as Linux version 0.0.1
It was put to the Internet and received enormous response from worldwide software
developersBy December came version 0.10. Still Linux was little more than in skeletal form.
Linux Today
Linux has been used for many computing platforms
PC, PDA, Supercomputer..
Current kernel version 2.6.13
Not only character user interface but graphical user interface, thanks to the X-Window
technology
Commercial vendors moved in Linux itself to provide freely distributed code.
They make their money by compiling up various software and gathering them in a
distributable format
Red Hat, Slackware, etc
Advantages over Windows
It's almost free to relatively inexpensive
Source code is included
Bugs are fixed quickly and help is readily available through the vast support in Internet
KGiSL INSTITUTE OF TECHNOLOGY
THEJAS KUMAR.B
711720205053
Linux is more stable than Windows
Linux is truly multi-user and multi-tasking
multiuser: OS that can simultaneously serve a number of users
multitasking: OS that can simultaneously execute a number of programs
Linux runs on equipment that other operating systems consider too underpowered, e.g. 386
systems, PDA, etc
Disadvantages compared with Windows
Isn't as popular as Windows
No one commercial company is responsible for Linux
Linux is relatively hard to install, learn and use
Hence currently, Linux is mainly used in commercial applications, server implementation
More than 75% current network servers are developed based on Linux or Unix systems
Due to the relatively high reliability
COMPONENTS OF OS
KGiSL INSTITUTE OF TECHNOLOGY
THEJAS KUMAR.B
711720205053
B.LINUX SYSTEM ARCHITECTURE
Kernel
The part of an OS where the real work is done
System call interface
Comprise a set of functions (often known as Application Progarmmer’s Interface
API) that can be used by the applications and library routines to use the services
provided by the kernel
Application User’s Interface
Interface between the kernel and user
Allow user to make commands to the system
Divided into text based and graphical based
File Management
Control the creation, removal of files and provide directory maintenance
For a multiuser system, every user should have its own right to access files and
directories
KGiSL INSTITUTE OF TECHNOLOGY
THEJAS KUMAR.B
711720205053
Process Management
For a multitask system, multiple programs can be executed simultaneously in the
system
When a program starts to execute, it becomes a process
The same program executing at two different times will become two different
processes
Kernel manages processes in terms of creating, suspending, and terminating them
A process is protected from other processes and can communicate with the others
Memory management
Memory in a computer is divided into main memory(RAM) and secondary storage
(usually refer to hard disk)
Memory is small in capacity but fast in speed, and hard disk is vice versa
Data that are not currently used should be saved to hard disk first, while data that
are urgently needed should be retrieved and stored in RAM
The mechanism is referred as memory management
Device drivers
Interfaces between the kernel and the BIOS
Different device has different driver
B.1 User interface
Linux User Login
Linux is a multiuser OS
Allow multiple users to use the resource of a computer at the same time
Every user needs to login the system with the password provided to identify their
right in using the resource
Require for both client-server based system or desktop
KGiSL INSTITUTE OF TECHNOLOGY
THEJAS KUMAR.B
711720205053
Linux User Interface
Traditional Linux (Unix also) uses commanddriven interface (or text-based interface)
User needs to type lines of command to instruct the computer to work, similar to
DOS
Advantage: fast in speed. Very few resource is required for its implementation
Disadvantages: user needs to type, hence can easily make error.
Besides, user needs to memorize all commands
Suitable for expert users and for the systems that interaction with user is not
frequent, such as servers
By adopting the X-Window technology, graphical user interface (GUI) is
available for Linux:
Uses pointing devices (e.g. mouse) to control the system, similar to Microsoft’s
Windows
Provide menu-driven and/or icon-driven interfaces
menu-driven: user is provided with a menu of choices. Each choice refers to a
particular task
icon-driven: tasks are represented by pictures (icon) and shown to user. Click on
an icon invokes one task
Advantages: No need to memorize commands.
Always select task from menus or icons
Disadvantages: Slow and require certain resource for its implementation Suitable
for general users and systems, such as PC
Linux Shell:
KGiSL INSTITUTE OF TECHNOLOGY
THEJAS KUMAR.B
711720205053
Different shell has similar but different functionality
Bash is the default for Linux
Graphical user interface of Linux is in fact an application program work on the shell
Frequently used commands available in most shells:
ls : to show (list) the names of the file in the current directory
cd : change directory,
e.g. cd / change to the root directory
cd .. change to the parent of that directory
cp : copy one file to another
e.g. cp abc.txt xyz.txt copy abc.txt to xyz.txt
rm : remove a file
man : ask for the manual (or help) of a command
e.g. man cd ask for the manual of the command cd
pwd : show the name of the present working directory
cat : to show the content of a text file
e.g. cat abc.txt show the content of abc.txt
whoami : to show the username of the current user
B.2 File management
According to the File System Standard (FSSTND) proposed in 1994, every LINUX system
should contain a set of standard files and directory
KGiSL INSTITUTE OF TECHNOLOGY
THEJAS KUMAR.B
711720205053
Linux File Access Privilege
Linux is a multiuser system, the files of all users are stored in a single file structure
Mechanism is required to restrict one user to access the files of another user, if he is
not supposed to use
User can impose access permission to each file to restrict its access
The term “access permission” refers to
read permission
write permission
execute permission
Access permission can also be assigned to a directory
Directory is also a file that contains the attributes of the files inside it
If read permission is not given to a directory
cannot show the structure of this directory
e.g. cannot use ls
If write permission is not given to a directory
cannot modify anything of the directory structure
e.g. cannot copy a file into this directory since it will modify the directory structure
by adding one more file
If execute permission is not given to a directory
nearly nothing can be done with this directory, even cd
File Storage in Linux
Data storage on hard disk
Data in a hard disk are stored on a magnetic flat plate
Disk’s surface needs to be partitioned and labeled so that computer can go directly
to a specific point on it
Achieve by low level formatting the disk
Create magnetic concentric circles called tracks
Each track is split into smaller parts called sectors and numbered
Each sector: hold 512 bytes data
E.g. 80 tracks (from outer to inner 0 .. 79), 18 sectors disk can store 80x18x512 bytes
data.
KGiSL INSTITUTE OF TECHNOLOGY
THEJAS KUMAR.B
711720205053
Must read or write whole sector at a time
OS allocates groups of sectors called cluster to files
Files smaller than the cluster will still be allocated the whole cluster, but the rest left
unused
In Linux, every file is associated with an inode that records its location in the disk
The inode of all files are put together in a data structure called inode table
In the directory, every file is associated with a inode number that points to an entry
of the inode table
B.3 Process management
Linux Process Management
Linux is a multitasking system
Multiple programs can be executed at the same time
Ultimately, a program needs to be executed by a CPU
If there is only one CPU, how multiple programs can be executed at the same time?
KGiSL INSTITUTE OF TECHNOLOGY
THEJAS KUMAR.B
711720205053
⇒ By time sharing
That is, all programs are claimed to be executing. In fact, most of them are
waiting for the CPU
A process is basically a program in execution. The execution of a processmust
progress in a sequential fashion.
A process is defined as an entity which represents the basic unit of work to be
implemented in the system.
When a program is loaded into the memory and it becomes a process, it can
be divided into four sections ─ stack, heap, text and data.
Stack - The process Stack contains the temporary data such as method/function
parameters, return address and local variables.
Heap - This is dynamically allocated memory to a process during its run time.
Text - This includes the current activity represented by the value of Program
Counter and the contents of the processor's registers.
Data - This section contains the global and static variables
States diagram
New - A program which is going to be picked up by the OS into the main memory is
called anew process.
Ready - Whenever a process is created, it directly enters in the ready state, in which, it
waits for the CPU to be assigned.
The OS picks the new processes from the secondary memory and put all of them in the
main memory.
KGiSL INSTITUTE OF TECHNOLOGY
THEJAS KUMAR.B
711720205053
The processes which are ready for the execution and reside in the main memory are
called ready state processes.
There can be many processes present in the ready state
Running - One of the processes from the ready state will be chosen by the OS
depending upon the scheduling algorithm. Hence, if we have only one CPU in our
system, the number of running processes for a particular time will always be one. If we
have n processors in thesystem then we can have n processes running simultaneously.
Block or wait - From the Running state, a process can make the transition to the block
or wait state depending upon the scheduling algorithm or the intrinsic behavior of the
process.
When a process waits for a certain resource to be assigned or for the input from the
user then the OS move this process to the block or wait state and assigns the CPU to the
other processes
Completion or termination
When a process finishes its execution, it comes in the termination state.
All the context of the process (Process Control Block) will also be deleted the process will
be terminated by the Operating system
Suspend ready
A process in the ready state, which is moved to secondary memory from the main
memory due to lack of theresources (mainly primary memory) is called in the suspend
ready state.
If the main memory is full and a higher priority process comes for the execution then
the OS have to make the room for the process in the main memory by throwing the
lower priority process out into the secondary memory.
The suspend ready processes remain in the secondary memory until the main memory
gets available
Disk Scheduling Algorithms
FCFS scheduling algorithm.
SSTF (shortest seek time first) algorithm.
SCAN scheduling.
C-SCAN scheduling.
LOOK Scheduling.
C-LOOK scheduling.
FCFS:
FCFS is the simplest of all the Disk Scheduling Algorithms. In FCFS, the requests are
addressed in the order they arrive in the disk queue
KGiSL INSTITUTE OF TECHNOLOGY
THEJAS KUMAR.B
711720205053
SSTF:
In SSTF (Shortest Seek Time First), requests having shortest seek time are executed
first. So, the seek time of every request is calculated in advance in the queue and then
they are scheduled according to their calculated seek time. As a result, the request near
the disk arm will get executed first. SSTF is certainly an improvement over FCFS as it
decreases the average response time and increases the throughput of system.
SCAN: In SCAN algorithm the disk arm moves into a particular direction and services the
requests coming in its path and after reaching the end of disk, it reverses its direction and
again services the request arriving in its path. So, this algorithm works as an elevator and
hence also known as elevator algorithm.
C-SCAN: In SCAN algorithm, the disk arm again scans the path that has been scanned,
after reversing its direction. So, it may be possible that too many requests are waiting at
the other end or there may be zero or few requests pending at the scanned area.
LOOK: It is similar to the SCAN disk scheduling algorithm except for the difference that
the disk arm in spite of going to the end of the disk goes only to the last request to be
serviced in front of the head and then reverses its direction from there only. Thus it
prevents the extra delay which occurred due to unnecessary traversal to the end of the
disk.
C-LOOK: As LOOK is similar to SCAN algorithm, in similar way, C-LOOK is similar to CSCAN
disk scheduling algorithm. In CLOOK, the disk arm in spite of going to the end goes only to
the last request to be serviced in front of the head and then from there goes to the other
end’s last request. Thus, it also prevents the extra delay which occurred due to
unnecessary traversal to the end of the disk.
The operating system is responsible for using hardware efficiently — for the disk
drives, this means having a fast access time and disk bandwidth
❖Minimize seek time
❖Seek time ≈ seek distance
❖Disk bandwidth is the total number of bytes transferred, divided by the total
time between the first request for service and the completion of the last
transfer
---------------------------**********----------------------------
KGiSL INSTITUTE OF TECHNOLOGY