OS - Unit I 1
OS - Unit I 1
Definition of OS:
An Operating System (OS) is an interface between a computer user and
computer hardware. An operating system is a software which performs
all the basic tasks like file management, memory management, process
management, handling input and output, and controlling peripheral
devices such as disk drives and printers.
1|Page
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
2|Page
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
• Program execution
• I/O operations
• File System manipulation
• Communication
• Error Detection
• Resource Allocation
• Protection
Program execution
Operating systems handle many kinds of activities from user programs to system
programs like printer, name servers, file server, etc. Each of these activities is
encapsulated as a process.
A process includes the complete execution context (code to execute, data to
manipulate, registers, OS resources in use).
I/O Operation
An I/O subsystem comprises of I/O devices and their corresponding driver software.
Drivers hide the peculiarities of specific hardware devices from the users.
I/O operation means read or write operation with any file or any specific I/O device.
Communication
• Two processes often require data to be transferred between them
• Both the processes can be on one computer or on different computers, but
are connected through a computer network.
• Communication may be implemented by two methods, either by Shared
Memory or by Message Passing.
3|Page
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
Error handling
• The OS constantly checks for possible errors.
• The OS takes an appropriate action to ensure correct and consistent
computing.
Resource Management
• The OS manages all kinds of resources using schedulers.
• CPU scheduling algorithms are used for better utilization of CPU.
Protection
• The OS ensures that all access to system resources is controlled.
• The OS ensures that external I/O devices are protected from invalid access
attempts.
• The OS provides authentication features for each user by means of
passwords.
1. Process Management
o Process is a program in execution --- numerous processes to choose
from in a multiprogrammed system,
o Process creation/deletion (bookkeeping)
o Process suspension/resumption (scheduling, system vs. user)
o Process synchronization
o Process communication
o Deadlock handling
2. Memory Management
4|Page
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
4. File System
o File creation/deletion.
o Support for hierarchical file systems
o Update/retrieval operations: read, write, append, seek
o Mapping of files to secondary storage
5. Protection
6. Network Management
8. User Interface
6|Page
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
Disadvantages −
• Lack of interaction between the user and the job.
• CPU is often idle, because the speed of the mechanical I/O
devices is slower than the CPU.
• Difficult to provide the desired priority.
Time-sharing operating systems
Time-sharing is a technique which enables many people, located at
various terminals, to use a particular computer system at the same time.
Time-sharing or multitasking is a logical extension of multiprogramming.
Processor's time which is shared among multiple users simultaneously is
termed as time-sharing.
The main difference between Multiprogrammed Batch Systems and
Time-Sharing Systems is that in case of Multiprogrammed batch
systems, the objective is to maximize processor use, whereas in Time-
Sharing Systems, the objective is to minimize response time.
Advantages −
• Problem of reliability.
• Question of security and integrity of user programs and data.
• Problem of data communication.
Distributed operating System
Distributed systems use multiple central processors to serve multiple
real-time applications and multiple users. Data processing jobs are
distributed among the processors accordingly.
The processors communicate with one another through various
communication lines (such as high-speed buses or telephone lines).
These are referred as loosely coupled systems or distributed systems.
Advantages-
• With resource sharing facility, a user at one site may be able to use
the resources available at another.
7|Page
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
Disadvantages-
• These types of systems are not readily available as they are very
expensive. Not only that the underlying software is highly complex
and not understood well yet.
Disadvantages −
• High cost of buying and running a server.
• Dependency on a central location for most operations.
• Regular maintenance and updates are required.
8|Page
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
the response time. So in this method, the response time is very less as
compared to online processing.
Real-time systems are used when there are rigid time requirements on
the operation of a processor or the flow of data and real-time systems
can be used as a control device in a dedicated application.
There are two types of real-time operating systems.
Hard real-time systems
Hard real-time systems guarantee that critical tasks complete on time. In
hard real-time systems, secondary storage is limited or missing and the
data is stored in ROM.
Soft real-time systems
Soft real-time systems are less restrictive. A critical real-time task gets
priority over other tasks and retains the priority until it completes. Soft
real-time systems have limited utility than hard real-time systems.
Advantages –
• Priority Based Scheduling
• Abstracting Timing Information
• Maintainability/Extensibility
• Modularity
• Promotes Team Development
• Easier Testing
Disadvantages –
• Limited Tasks
• Use Heavy System resources
• Complex Algorithms
• Device driver and interrupt signals
9|Page
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
10. Job accounting: Keeping track of time & resource used by various job
and users.
Storage Structure
A typical instruction execution cycle, as executed on a system with a Von-
Neumann architecture, first fetches an instruction from memory and stores
that instruction in the instruction registers.
The instruction is then decoded and may cause operands to be fetched from
memory and stored in some internal register. After the instruction on the
operands has been executed, the result may be stored back in memory.
10 | P a g e
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
The memory unit sees only a stream of memory addresses; it does not know
how they are generated. Main memory is usually too small to store all needed
programs and data permanently.
Thus, most computer system provides secondary storage as an extension of
main memory, which is able to store large quantities of data permanently. The
most common secondary storage device is a magnetic disk, which provides
storage for both programs and data.
register
cache
main memory
electronic disk
magnetic disk
optical disk
magnetic tapes
Storage device hierarchy
In the hierarchy shown above the storage systems above the electronic disk are
volatile where as those below are non-volatile.
Another form of electronic disk is Flash memory, which is popular in camera and
PDAs, which slower than DRAM but needs no power to return its contents.
11 | P a g e
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
System Calls
System calls provide an interface to the services made available by an OS.
These calls are generally available as routines written in C and C++, although
certain low-level tasks may need to be written using assembly language
instruction.
12 | P a g e
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
Once the two files names are obtained the program must open the input file
and create the output file. Each of these operations requires system call.
If the input file already exists, is missing or is protected against access then a
system call is generated to print a message for abnormal termination.
If the output file already exists then a system call is generated, we may delete
or replace the existing file to store the new one.
❖ Process Control
➢ End, abort
➢ Load, execute
➢ Create process, terminate process
➢ Get process attributes, set process attributes
➢ Wait for time
➢ Wait event, signal event
➢ Allocate and free memory
❖ File manipulation
➢ Create file, delete file
➢ Open, close
➢ Read, write, reposition
➢ Get file attributes, set file attributes
❖ Device management
➢ Request device, release device
➢ Read, write, reposition
➢ Get device attributes, set device attributes
➢ Logically attach or detach devices
13 | P a g e
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
❖ Information maintenance
➢ Get system time, set system time
➢ Get system date, set system date
➢ Get process, file or device attributes
➢ Set process, file or device attributes
❖ Communication
➢ Create, delete communication connection
➢ Send, receive message
➢ Transfer status information
➢ Attach or detach remote devices
System Programs
System program provide a convenient environment for program development
and execution. Some of them are simply user interfaces to system calls. Others
are considerably more complex.
They can be divided into these categories:
1. File management
These programs create, delete, copy, rename, print, list and generally
manipulate files and directories.
2. Status information
Some programs simply ask for the system for the date, time, amount of
available memory or disk space, number of users, or similar status
information.
3. File modification
Several text editors may be available to create and modify the content of
files stored on disk or other storage devices.
14 | P a g e
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
6. Communications
These programs provide the mechanism for creating virtual connections
among processes, users and computer systems. They allow users to send
messages to one another’s screen, to browse webpages, to send e-mail
messages to login remotely, onto transfer file from one machine to
another.
Virtual Machines
The fundamental idea behind a virtual machine is to abstract the h/w of a
single computer into several different execution environments, thereby
creating the illusion that each separate execution environment is running its
own private computer.
In this environment there is complete protection of the various system
resources. Each virtual machine is completely isolated from all other virtual
machines.
The virtual machine software can run in kernel mode. Since it is the OS it can
itself execute only in user mode.
Consider a scenario that a developer wants to test an application on Linux,
Free BSD and on Windows NT. One option is that we can use three different
system to install the OS individually and test the application distinctly. This
option is time consuming and is expensive as it requires individual systems for
each type of OS.
But we can accomplish the testing on a single physical computer by using
VMWare. In this case the programmer can test the application on a host OS
and on two guest OS with each system running as a separate virtual machine.
15 | P a g e
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
Java objects are specified with the class construct; a java program consists of
one or more classes. For each java class, the complier produces an
architecture-neutral bytecode output (.class) file that will run on any
implementation of the JVM.
OS Implementation
Once an OS is designed then it is implemented.
Traditionally OS have been written in assembly language but now they are
mostly written in High level language such as C or C++.
The advantage of using a high-level language for implementing OS are the
same as those occurred when the language is used for application programs.
The codes can be written faster and is easier to understand and debug.
It improves the compiler where the generated code for the OS by simple
recompilation.
16 | P a g e
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
Multiprocessor System
It is also known as parallel system or tightly coupled system.
These systems have two or more processors enclosed communication sharing
the computer bus and sometimes the clock and memory and peripheral
devices.
The multiprocessor system has 3 main advantages: -
1) Increased throughput
2) Economy of scale
3) Increased reliability
Clustered System
Like multiprocessor systems, clustered systems gather together multiple CPUs
to accomplish computational work.
Clustered systems differ from multiprocessor systems. However, in that they
are composed of two or more individual system coupled together.
17 | P a g e
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
The generally accepted definition is that clustered systems share storage and
are closely linked via a LAN.
18 | P a g e
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
It is the job of security to defend a system from external and internal attacks.
Such attacks spread across a huge range and include viruses and worms, denial
of service attacks (which use all of a system’s resources and so keep legitimate
users out of the system) identify theft, and theft of service (unauthorized use
of a system).
19 | P a g e
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
Layered Approach
With proper hardware support, OS can be broken into pieces, that are smaller
and more appropriate than those allowed by the original MS-DOS systems.
A system can be made modular in may ways. The layer approach is one
method in which the OS is broken up into a number of layers. The bottom layer
is the hardware and the highest layer is in the user interface.
Micro kernels
As the OS expanded, the kernel become large and difficult to manage, but an
OS was developed called MAC that modularized the kernel using the
microkernel approach.
The main function of the microkernel is to provide a communication facility
between the client program and the various services that are also running in
user space.
One benefit of the microkernel approach is ease of extending the operating
system.
Modules
Perhaps the best current methodology for operating system design involve
using object-oriented program technique to create a modular kernel. Here the
kernel has a set of cores of components and dynamically links in additional
services either during boot time or during run time.
Ex: -
Solaris OS structure shown in fig is organized around a core kernel with 7 types
of loadable kernel modules.
20 | P a g e
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
7 2
Core
Solaris
6 kernel 3
5 4
1. Scheduling classes
2. File systems
3. Loadable system calls
4. Executable formats
5. Streams modules
6. Miscellaneous
7. Device and bus drivers
21 | P a g e
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
For e.g. Unix and Linux systems have several shells available such as
• BOURNESHELL
• CSHELL
2. Graphical User Interface
A GUI provides a mouse-based windows and a menu system as an interface.
It provides a Desktop metaphor where the mouse is moved to position its
pointer on images on icons on the screen (Desktop) that represents
programmes, files, directories and system functions.
Multiprogramming
A computer running more than one process at a time is known as
multiprogramming.
In the modern computer system, several concurrent application processes
want to execute. It is the responsibility of OS to manage them.
These processes are also known as Jobs, now the main memory is too small to
accommodate all of these jobs into it, thus these processes are initially kept in
Jobpool. Selects one Job out of these waiting Jobs, brings it from the Jobpool
to the main memory and start executing it.
The processor executes one job until it is interrupted by some external factors.
Multiprocessing
Multiprocessing is the use of two or more CPUs in a single computer system.
The term also refers to the ability of a system to support more than one
processor within a single computer system.
These multiprocessors can be executed at a time. Share the computer Bus
sometimes the clock memory and peripheral devices.
22 | P a g e
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
Multitasking
It is a logical extension of multiprogramming. The major way in which
multitasking differs from multiprogramming is that multiprogramming works
solely on the concept of context switching where as multitasking is based on
time sharing along side the concept of context switching.
The CPU makes the process to share time slices between them and execute
accordingly as soon as quantum timing of one process expires another process
begins its execution.
Multithreading
A thread is the basic unit of CPU utilization. Multithreading is an execution
model that allow a single process to have multiple code segment running
concurrently within the context of that process.
Multithreading is the ability of a process to manage its use by more than one
user at a time and to manage multiple requests by the same user without
having to have multiple copies of the program.
Multiprocessor system
Multiprocessing is the use of two or more central processing units (CPUs)
within a single computer system. The term also refers to the ability of a system
to support more than one processor and/or the ability to allocate tasks
between them.[1] There are many variations on this basic theme, and the
definition of multiprocessing can vary with context, mostly as a function of
how CPUs are defined.
Advantage:
1.increase throughput
2.Economy of scale
3. Increased reliability
Disadvantage:
1) If one processor fails then it will affect in the speed
2) multiprocessor systems are expensive
3) complex OS is required
4) large main memory required.
23 | P a g e
Contact: 7008443534, 9090042626
Subject: Operating System
Created By: Asst. Prof. SK ABDUL ISRAR College: ABA, BLS
Q) When caches are useful? What problems do they solve? What problems do they
cause? If a cache can be made as large as the device for which it is caching why not
make it that large and eliminate the device?
24 | P a g e
Contact: 7008443534, 9090042626