Professional Documents
Culture Documents
Lecture Notes On Introduction To Operating System I: Course Facilitator: MR Fotso Alain
Lecture Notes On Introduction To Operating System I: Course Facilitator: MR Fotso Alain
OPERATING SYSTEM I
2. It acts as an interface between the user and the physical machine that is it provides a stable,
consistent way for applications to deal with the hardware without having to know all the
details of the hardware.
Historically operating systems have been tightly related to the computer architecture. Operating
systems have evolved through a number of distinct phases or generations which corresponds roughly
to the decades.
Almost all operating systems have a user interface (UI). This interface can take several forms.
V.4 Interrupt
An interrupt in an interruption in the normal execution of the program. When the CPU is interrupt,
then it stops its current activities like execution of the program. And transfer the control to interrupting
device to check the interrupt. The three types of interrupts are
Following are few of the important types of operating system which are most commonly used.
This is the type of operating system most people use on their desktop and laptop computers today.
Microsoft's Windows and Apple's MacOS platforms are both examples of operating systems that will
let a single user have several programs in operation at the same time.
VI.4 Multi-user
A multi-user operating system allows many different users to take advantage of the computer's
resources simultaneously. Unix, VMS and mainframe operating systems, such as MVS, are examples
of multi-user operating systems.
VI.5 Multiprocessing OS
Multiprogramming OS have two or more processors for a single running process. Processing
takes place in parallel and is also called parallel processing. Each processor works on different
parts of the same task, or, on two or more different tasks. Linux, UNIX and Windows 7 are examples
of multiprocessing OS.
Multitasking or time sharing refers to term where multiple jobs are executed by the CPU
simultaneously by switching between them. Switches occur so frequently that the users may interact
with each program while it is running.
1) Both are same beast with different name or when this beast is sleeping (not
executing) it is called program and when it is executing becomes process.
2) Program is a static object whereas a process is a dynamic object.
3) A program resides in secondary storage whereas a process resides in main memory.
4) The span time of a program is unlimited but the span time of a process is limited.
5) A process is an 'active' entity whereas a program is a 'passive' entity.
6) A program is an algorithm expressed in programming language whereas a
process is expressed in assembly language or machine language.
A Process when first created will be in New stage, then when it is waiting for CPU time in
order to get executed will in ready stage. In Ready stage Process will be waiting for CPU
time in Ready Queue (A queue where Process waits for the CPU).
Once the CPU become free and process acquires it, Process will enter into Running stage
where it will execute its instructions. If during this stage any interrupt occurs then it will move
back to ready stage and wait for the scheduler dispatcher. If it has I/O operation then it will
move to Waiting stage where it will perform I/O operation and then move back to ready stage
and waits for the scheduler dispatcher.
After the process get executed it will terminate.
The change of the state of the process from one form to another is called context change and this
course of action is known as context switching.
Process Control Block is a data structure that contains information of the process related
to it. The process control block is also known as a task control block, entry of the process
table, etc:
The following is stored inside the PCB
Process State - It can be running, waiting etc.
Process ID and parent process ID.
CPU registers and Program Counter.
Program Counter holds the address of the next instruction to be executed for that
process.
CPU Scheduling information - Such as priority information and pointers to scheduling
queues.
Memory Management information - Eg. page tables or segment tables.
Accounting information - user and kernel CPU time consumed, account numbers, limits, etc.
I/O Status information - Devices allocated, open file tables, etc.
Process Scheduling Queues
Job Queue: This queue consists of all processes in the system; those
processes are entered to the system as new processes.
Ready Queue: This queue consists of the processes that are residing in
main memory and are ready and
waiting to execute by CPU. This queue is generally stored as a linked list.
A ready-queue header contains pointers to the first and final PCBs in the list.
Each PCB includes a pointer field that points to the next PCB in the ready
queue.
Device Queue: This queue consists of the processes that are waiting
for a particular I/O device. Each device has its own device queue.
Schedulers
The long-term scheduler or job scheduler selects processes from discs and
loads them into main memory for execution. It executes much less
frequently.
It controls the degree of multiprogramming (i.e., the number of processes in
memory).
Because of the longer interval between executions, the long-term
scheduler can afford to take more time to select a process for execution.
Medium-term scheduler
Context Switch
Dispatch latency – time it takes for the dispatcher to stop one process and start
another running.
VII.3 Process Scheduling
In a multiprogrammed system, at any given time, several processes will be competing for the CPU
time. Thus, a choice has to be made which process to allocate the CPU next. This procedure of
determining the next process to be executed on the CPU is called process scheduling and the module
of operating system that makes this decision is called a scheduler.
Preemptive scheduling allows a process to be interrupted in the midst of its execution, taking the
CPU away and allocating it to another process. Nonpreemptive scheduling ensures that a process
relinquishes control of the CPU only when it finishes with its current
CPU burst.
CPU-scheduling decisions may take place under the following four circumstances:
1. When a process switches from the running state to the waiting state (for example, as the
result of an I/O request,…).
2. When a process switches from the running state to the ready state (for example, when an
interrupt occurs).
3. When a process switches from the waiting state to the ready state (for example, at
completion of I/O, on a semaphore, or for some other reason).
4. When a process terminates.
For situations 1 and 4, there is no choice in terms of scheduling. A new process (if one exists in the
ready queue) must be selected for execution.
There is a choice, however, for situations 2 and 3. When scheduling takes place only under
circumstances 1 and 4, we say that the scheduling scheme is nonpreemptive or cooperative;
otherwise, it is pre-emptive.
The scheduler uses some scheduling procedure to carry out the selection of a process for execution.
The efficiency of each algorithm is judged according to the average waiting time and the average
turnaround time.
1. Arrival time: This is the time at which a process enters the ready queue.
2. Waiting Time: the amount of time spent by the process waiting in the ready queue for getting the
CPU
Waiting Time = Turnaround Time – burst Time
Burst Time: This is the amount of time required by a process for executing on CPU
3. Completion Time: Time at which process completes its execution.
2. TURN ARROUNG TIME: this is the total t i m e s p e n t b y a p r o c e s s i n t h e s y s t e m .
TURN ARROUND TIME = BURST TIME + WATING TIME OR
Turn Around Time: Time Difference between completion time and arrival time.
turnaroundTime = burstTime + waitingTime = finishTime- arrivalTime)
Example:
Process Arrival time Burst time Service Time Wait Time : Service Time -
Arrival Time
P0 0 5 0 0-0=0
P1 1 3 5 5-1=4
P2 2 8 8 8-2=6
P3 3 6 16 16 - 3 = 13
2) Round Robin:
Here each process is provided a fix time to execute called quantum or slice time. After this time has
elapsed, the process is preempted and added to the end of the ready queue and other process executes
for given time period. Context switching is used to save states of preempted processes.
Example: Quantum = 3
14 17 19 21
Process Arrival time Bust Time Wait Time : Service Time - Arrival Time
P0 0 5 (0-0) + (12-3) = 9
P1 1 3 (3-1) = 2
P2 2 8 (6-2) + (14-9) + (19-17) = 11
P3 3 6 (9-3) + (17-12) = 11
Average Wait Time: (9+2+11+11) / 4 = 8.25
Process Arrival time Burst time Service Time Wait Time : Service Time -
Arrival Time
P0 0 5 0 0-0=0
P1 1 3 5 5-1=4
P2 2 8 14 14 - 2 = 12
P3 3 6 8 8-3=5
P3 P2
4) Priority Scheduling
Each process is assigned a priority. Process with highest priority is to be executed first and so on.
Processes with same priority are executed on first come first serve basis. Priority can be decided based
on memory requirements, time requirements or any other resource requirement. A major problem with
priority-scheduling algorithms is indefinite blocking of one or more processes (call starvation).
P0 P3 P1
5 11 14
b) Process Termination
By making the exit(system call), typically returning an int, processes may request their own
termination. This int is passed along to the parent if it is doing a wait(), and is typically zero on
successful completion and some non-zero code in the event of any problem.
Processes may also be terminated by the system for a variety of reasons, including :
When a process ends, all of its system resources are freed up, open files flushed and closed, etc.
The process termination status and execution times are returned to the parent if the parent is
waiting for the child to terminate, or eventually returned to init if the process already became an
orphan.
The processes which are trying to terminate but cannot do so because their parent is not waiting
for them are termed zombies. These are eventually inherited by init as orphans and killed off.
As each thread has its own independent resource for process execution, multiple processes can
be executed parallel by increasing number of threads.
Why Multithreading?
Thread is also known as lightweight process. The idea is achieve parallelism by dividing a
process into multiple threads. For example, in a browser, multiple tabs can be different threads.
MS word uses multiple threads, one thread to format the text, other thread to process inputs etc.
More advantages of multithreading are discussed below
Process vs Thread?
The typical difference is that threads within the same process run in a shared memory space,
while processes run in separate memory spaces.
Threads are not independent of one other like processes as a result threads shares with other threads their
code section, data section and OS resources like open files and signals. But, like process, a thread has its
own program counter (PC), a register set, and a stack space. Advantages of Thread over Process
1. Responsiveness: If the process is divided into multiple threads, if one thread completed its
execution, then its output can be immediately responded.
2. Faster context switch: Context switch time between threads is less compared to process context
switch. Process context switch is more overhead for CPU.
3. Effective Utilization of Multiprocessor system: If we have multiple threads in a single process, then we
can schedule multiple threads on multiple processor. This will make process execution faster.
4. Resource sharing: Resources like code, data and file can be shared among all threads within a process.
Note : stack and registers can’t be shared among the threads. Each thread have its own stack and registers.
5. Communication: Communication between multiple thread is easier as thread shares common address
space. while in process we have to follow some specific communication technique for communication
between two process.
6. Enhanced Throughput of the system: If process is divided into multiple threads and each thread
function is considered as one job, then the number of jobs completed per unit time is increased. Thus,
increasing the throughput of the system.
VIII DEADLOCK
Page 22 of 31
Other examples of deadlocks
Explanation: Resources cannot be removed from the processes are used to completion or released
voluntarily by the process holding it.
Page 23 of 31
4. Circular Wait Condition: The processes in the system form a circular list or chain where each
process in the list is waiting for a resource held by the next process in the list. There exists a set {P0,
P1, …, P0} of
waiting processes such that P0 is waiting for a resource that is held by P1, P1 is waiting for a resource
that is
held by P2, …, Pn–1 is waiting for a resource that is held by Pn, and P0 is waiting for a resource that is
held by P0.
Note: It is not possible to have a deadlock involving only one single process. The deadlock involves a circular
“hold-and-wait” condition between two or more processes, so “one” process cannot hold a resource, yet be
The deadlock conditions can be modelled using a directed graph called a resource allocation graph (RAG).
Below is the Resource Allocation Graph,
NB: The presence of a cycle in a RAG is a necessary and not a sufficient condition for the deadlock to occur. It
becomes sufficient when there is only one instance of each resource.
Page 24 of 31
VIII.4 Methods for Handling Deadlocks
Generally speaking there are three ways of handling deadlocks:
1) Deadlock prevention or avoidance: The idea is to not let the system into deadlock state.
2) Ignore the problem all together: If deadlock is very rare, then let it happen and reboot the system.
Both Windows and UNIX take this approach.
2) Deadlock detection and recovery: Let deadlock occur, then do preemption to handle it once occurred.
3) Deadlock detection and recovery: Let deadlock occur, then do preemption to handle it once occurred. In
resource preemption, the operator or system preempts some resources from processes and give these
resources to other processes until the deadlock cycle is broken.
If preemption is required to deal with deadlocks, then three issues need to be addressed:
1. Selecting a victim: The system or operator selects which resources and which processes are
to be preempted based on cost factor.
2. Rollback: The system or operator must roll back the process to some safe state and restart it from that
state.
3. Starvation: The system or operator should ensure that resources would not always be pre-empted from the
same process. i.e a process should not be indefinitely allow in a blocking state?
X FILE MANAGEMENT
Page 25 of 31
A file management system is that set of system software that provides services to users and applications in the
use of files. Following objectives for a file management system:
To meet the data management needs and requirements of the user which include storage of data and the
ability to perform the aforementioned operations.
To guarantee, to the extent possible, that the data in the file are valid.
To optimize performance, both from the system point of view in terms of overall throughput.
To provide I/O support for a variety of storage device types.
To minimize or eliminate the potential for lost or destroyed data.
To provide a standardized set of I/O interface routines to use processes.
X.2 What is a File system?
1) Definition
File system is a system for organizing directories and files, generally in terms of how it is implemented in the
disk operating system. While the memory manager is responsible for the maintenance of primary memory, the
file manager is responsible for the maintenance of the file system.
→ Ext2, Ext3, Ext4 - 'native' Linux file system. This file system falls under active developments and
improvements. Ext4 file system is frequently used as 'root' file system for most Linux installations.
→ ReiserFS - alternative Linux file system designed to store huge amount of small files.
→ XFS - file system derived from SGI company that initially used it for their IRIX servers. Now XFS
specifications are implemented in Linux.
→ JFS - file system developed by IBM for their powerful computing systems. Currently this file system is
open-source and is implemented in most modern Linux distributions.
Page 26 of 31
→ UFS (Unix File System) also often referred to FFS (Fast File System – fast compared to a previous file
system used for Unix).
→ ZFS for Solaris,
XI DEVICE MANAGEMENT
Device management in an operating system refers to the process of managing various devices connected to the
computer. The device manager manages the hardware resources and provides an interface to the hardware for
application programs. A device communicates with the computer system by sending signals over a cable. The
device communicates with the machine through a connection point called port.
Broadly, managing input and output is a matter of managing queues and buffers. A buffer is a temporary storage
area that takes a stream of bits from a device like keyboard to a serial communication port. Buffers hold the bits
and then release them to the CPU at a convenient rate so that the CPU can act on it.
Spooling: SPOOL stands for simultaneous peripheral operation on-line. Spooling refers to storing jobs in a
buffer so that CPU can be efficiently utilized. Spooling is useful because devices access data at different rates.
The buffer provides a waiting station where data can rest while the slower device catches up. The most common
spooling application is print spooling. In print spooling, documents are loaded into a buffer, and then the printer
pulls them off from the buffer at its own rate.
Security in terms of a computer system covers every aspect of its protection in case of a catastrophic event,
corruption of data, loss of confidentiality and so on. Security requires ample protection not only within the system,
but also from the external environment, in which the system operates. Various security techniques employed by
the operating system to secure the information are user authentication and backup of data.
1) User Authentication
The process of authenticating users can be based on a user's possession like a key or card, user information
like the username and password or user attributes like fingerprints and signature. Among these techniques,
user information is often the first and most significant line of defence in a multiuser system. Unfortunately,
passwords can often be guessed, illegally transferred or exposed. To avoid such situations, a user should keep the
following points in mind:
1) Password should be at least six characters in length.
2) The system should keep track of any event about any attempt to break the password.
3) The system should allow limited number of attempts for submitting a password on a particular
system.
4) Password based on dictionary words should be discouraged by the system. Alphanumeric
passwords, such as PASS011, should be used.
2) Backup of Data
To backup is to copy files to a second medium (a disk or tape) as a precaution in case the first medium fails. One
of the cardinal rules in using computers is back up your files regularly. Operating system should provide a feature
Page 27 of 31
of backing up of data, for example, from a disk to another storage device such as a floppy disk or an optical disk.
The purpose of keeping backups is to be able to restore individual files or complete file system in case of data
loss.
3) Data encryption
Encryption is the conversion of data (called plaintext) into a form (called a cyphertext) that cannot be easily
understood by unauthorised user. Before being able to understand the content of the data, the receiver must be in
possession of an encryption key used to decrypt the cyphertext.
XIII EXAMPLES OF OS
1. DOS (Disk Operating System): MS- DOS was the widely used operating system before the introduction of
the Windows operating system. Even now the MS- DOS commands are used for carrying out many jobs like
copying the files, deleting the files etc. The main functions of DOS are to manage files, allocate system
resources according to the requirement. It provides essential features to control hardware devices such a
keyboard, screen, disk drives, printers, modems etc.
2. Windows: Microsoft launched Windows 1.0 operating system in 1985 and since then Windows has ruled the
world’s software market. Various versions of Windows have been launched like Windows 95, 98, Win NT,
XP, 7 and the latest being Windows 8.
3. Linux: Linux is a free and open software which means it is freely available for use and its source code is
also available so anybody can use it, modify it and redistribute it. It is a very popular operating system used
and supported by many companies.
4. MAC OS (Macintosh operating system): It is the operating system developed by Apple for Mac computers
5. BOSS (Bharat Operating System Solutions): This is an Indian distribution of GNU/Linux. It consists
of Linux operating system kernel, office application suite, Bharateeya OO, Internet browser (Firefox),
multimedia applications and file sharing.
6. UNIX: It is a multitasking, multiuser operating system originally developed in 1969 at Bell Labs. It
was one of the first operating systems developed in a high level language, namely C. Due to its portability,
flexibility and power, UNIX is widely being used in a networked environment.
7. Solaris: It is a free Unix based operating system introduced by Sun Microsystems in 1992. It is now also
known as Oracle Solaris.
XIII.2 Mobile Operating Systems (Mobile OS)
It is the operating system that operates on digital mobile devices like smart phones and tablets. It extends the
features of a normal operating system for personal computers so as to include touch screen, Bluetooth, Wi-
Fi, GPS mobile navigation, camera, music player and many more. The most commonly used mobile
operating systems are Android and Symbian
Android: It is a Linux derived Mobile OS released on 5th November 2007 and by 2011 it had more than 50% of
the global Smartphone market share. Google’s open and free software includes an operating system, middleware
Page 28 of 31
and some key applications for use on mobile devices. Various versions of Android OS have been released like
1.0, 1.5, 1.6, 2.x, 3.0 etc.
Symbian: This Mobile OS by Nokia designed for smartphones. It offers high level of functional integration
between communication and personal information management. It has an integrated mail box and it completely
facilitates the usage of all Google applications in your smartphone easily. Various versions like S60 series,
S80 series, S90 series, Symbian Anna etc have been released
a. draw its corresponding Gantt chart for each of the following scheduling method:
( 4 mark )
FCFS
SRT
b. Calculate the Turnaround Time, Wainting Time for each and the average waiting time for all the
processes. ( 5 mark )
c. What can you conclude about the two scheduling methods? ( 1 mark )
2. Discuss the following types Operating systems giving examples (2marksx8 = 16 marks)
Page 30 of 31
a. Batch processing OS
b. Online OS
c. Embedded OS
d. Real time OS
e. Mobile OS
f. Network OS
g. Mono tasking OS
h. Multiprocessing OS
Page 31 of 31