You are on page 1of 44

CHAPTER 1

INTRODUCTION TO
OPERATING SYSTEMS
- ANIKET KORE
TOPICS TO BE COVERED

1. OS Objectives and Functions


2. Evolution of OS
3. OS Design considerations for Multiprocessor Architecture
4. OS Structures
5. System Calls
WHAT IS AN 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.
 An operating system is software that enables applications to interact with a
computer's hardware.
 The software that contains the core components of the operating system is called
the KERNEL.
WHAT IS AN OS ?

• Operating systems are those programs that interface the machine with the
applications programs.
• The main function of these systems is to dynamically allocate the shared system
resources to the executing programs.
• As such, research in this area is clearly concerned with the management and
scheduling of memory, processes, and other devices.
• Computer system can be divided into four components
1. Hardware – provides basic computing resources
• CPU, memory, I/O devices
2. Operating system
• Controls and coordinates use of hardware among various applications and users
3. System/Application programs – define the ways in which the system
resources are used to solve the computing problems of the users
• Word processors, compilers, web browsers, database systems, video games
• OS controls and coordinates use of h/w among various application programs.
4. Users
• People, machines, other computers
COMPUTER HARDWARE AND SOFTWARE
INFRASTRUCTURE
a set of
system
programs

implement
frequently
used functions
that assist in
program
creation, the
management
of files, and
the control of
I/O devices
FEATURES OF OPERATING SYSTEM
Operating system has the following features:
1. Convenience: An OS makes a computer more convenient to use.
2. Efficiency: An OS allows the computer system resources to be used efficiently.
3. Ability to Evolve: An OS should be constructed in such a way as to permit the
effective development, testing, and introduction of new system functions at the
same time without interfering with service.
4. Throughput: An OS should be constructed so that It can give
maximum throughput (i.e. Number of tasks per unit time).
MAJOR FUNCTIONALITIES OF OPERATING
SYSTEM
1. Resource Management: When parallel accessing happens in the OS, means when
multiple users are accessing the system, the OS works as Resource Manager. Its
responsibility is to provide hardware to the user and decrease the load in the
system.
2. Process Management: It includes various tasks like scheduling and termination of
the process. It is done with the help of CPU Scheduling algorithms.
3. Program development: The OS provides a variety of facilities and services, such
as editors and debuggers, to assist the programmer in creating programs.
Typically, these services are in the form of utility programs that, while not strictly
part of the core of the OS, are supplied with the OS and are referred to as
application program development tools.
4. Program execution: A number of steps need to be performed to execute a
program. Instructions and data must be loaded into main memory, I/O devices and
files must be initialized, and other resources must be prepared. The OS handles
these scheduling duties for the user.
5. Access to I/O devices: Each I/O device requires its own peculiar set of instructions
or control signals for operation. The OS provides a uniform interface that hides
these details so that programmers can access such devices using simple reads and
writes.
6. Controlled access to files: For file access, the OS must reflect a detailed
understanding of not only the nature of the I/O device (disk drive, tape drive) but
also the structure of the data contained in the files on the storage medium. In the
case of a system with multiple users, the OS may provide protection mechanisms to
control access to the files.
7. System access: For shared or public systems, the OS controls access to the system
as a whole and to specific system resources. The access function must provide
protection of resources and data from unauthorized users and must resolve conflicts
for resource contention.
8. Error detection and response: A variety of errors can occur while a computer
system is running. These include internal and external hardware errors, such as a
memory error, or a device failure or malfunction; and various software errors, such
as division by zero, attempt to access forbidden memory location, and inability of
the OS to grant the request of an application. In each case, the OS must provide a
response that clears the error condition with the least impact on running
applications. The response may range from ending the program that caused the
error, to retrying the operation or simply reporting the error to the application.
EVOLUTION OF OPERATING SYSTEM
A major OS will evolve over time for a number of reasons
such as:

Hardware upgrades

New types of hardware

New services

Fixes
EVOLUTION OF OPERATING SYSTEM

The evolution process of


Operating Systems consisted
of the following stages:

Time Sharing
Systems
Multiprogrammed
Batch Systems

Simple Batch
Systems

Serial
Processing
1. SERIAL PROCESSING

•It involved the Earliest Computers. Problems:


•No operating system •Scheduling:
• programmers interacted directly with the -most installations used a hardcopy
computer hardware sign-up sheet to reserve computer
time.
•Computers ran from a console with -Time allocations could run short or
display lights, toggle switches, some long, resulting in wasted computer
time
form of input device, and a printer
•Setup time:
•Users have access to the computer in
-a considerable amount of time was
“series” spent just on setting up the program
to run
SERIAL PROCESSING
SYSTEMS
2. SIMPLE BATCH SYSTEMS

• Early computers were very expensive.


• important to maximize processor utilization

• Monitor concept was introduced.


• user no longer has direct access to the machine.
• job are batched together and placed on an input
device.
• program branches back to the monitor when
finished.
OVERHEAD IN SIMPLE BATCH SYSTEM
Processor time alternates between execution of user programs and execution of the
monitor
• Sacrifices:
• some main memory is now given over to the monitor
• some processor time is consumed by the monitor
• Despite overhead, the simple batch system improves
utilization of the computer.
3. MULTIPROGRAMMED BATCH SYSTEMS
• In previous generations, Processor is often idle
• even with automatic job sequencing
• I/O devices are slow compared to processor

• The processor spends a certain amount of time executing, until it reaches


an I/O instruction; it must then wait until that I/O instruction concludes
before proceeding
• There must be enough memory to hold the OS (resident monitor)
and one user program
• When one job needs to wait for I/O, the processor can switch to the
other job, which is likely not waiting for I/O
Multiprogramming
• also known as multitasking
• memory is expanded to hold three, four, or more programs
and switch among all of them
4. TIME-SHARING SYSTEMS

• Can be used to handle multiple interactive jobs.


• Processor time is shared among multiple users.
• Multiple users simultaneously access the system through terminals, with the OS
interleaving the execution of each user program in a short burst or quantum of
computation.
TYPES OF OPERATING SYSTEMS
Batch Operating System- Sequence of jobs in a program on a computer without
manual interventions.
Time-sharing operating System- allows many users to share computer resources. (Max
utilization of the resources).
Distributed operating System- Manages a group of different computers and makes
appear to be a single computer.
Network operating system- computers running in different operating systems can
participate in a common network (It is used for security purposes).
Real-time operating system – used where any or all the jobs have strict time
constraints.
SYMMETRIC MULTIPROCESSOR OS CONSIDERATIONS

A multiprocessor OS must provide all the functionality of a multiprogramming


system plus additional features to accommodate multiple processors
MULTICORE OS CONSIDERATIONS

• The design challenge for a multiple-core system is to


efficiently harness the multicore processing power and
intelligently manage the substantial on-chip resources
efficiently.
hardware parallelism within each core
processor, known as instruction level
• Potential for parallelism exists at parallelism

three levels:
potential for multiprogramming and
multithreaded execution within each
processor

potential for a single application to execute in


concurrent processes or threads across multiple
cores
OPERATING SYSTEM OPERATIONS

• An operating system is a construct that allows the user


application programs to interact with the system hardware.
• Operating system by itself does not provide any function
but it provides an atmosphere in which different applications
and programs can do useful work.
• The major operations of the operating system are
1. Process Management
2. Memory Management
3. Device Management
4. File Management
1. Process Management
• The operating system is responsible for managing the processes i.e assigning the
processor to a process at a time.
• This is known as process scheduling. The different algorithms used for process
scheduling are FCFS (first come first served), SJF (shortest job first), priority
scheduling, round robin scheduling etc.
• There are many scheduling queues that are used to handle processes in process
management.
• When the processes enter the system, they are put into the job queue. The processes
that are ready to execute in the main memory are kept in the ready queue. The
processes that are waiting for the I/O device are kept in the device queue.
2. Memory Management
• It deals with memory and the moving of processes from disk to primary
memory for execution and back again.
• The activities performed by the operating system for memory management
are −
1. The operating system assigns memory to the processes as required. This can be
done using best fit, first fit and worst fit algorithms.
2. All the memory is tracked by the operating system i.e. it notes what memory
parts are in use by the processes and which are empty.
3. The operating system deallocates memory from processes as required. This
may happen when a process has been terminated or if it no longer needs the
memory.
3. Device Management
• There are many I/O devices handled by the operating system such as mouse,
keyboard, disk drive etc.
• There are different device drivers that can be connected to the operating system to
handle a specific device.
• The device controller is an interface between the device and the device driver.
• The user applications can access all the I/O devices using the device drivers, which
are device specific codes.
4. File Management
• Files are used to provide a uniform view of data storage by the operating system.
• All the files are mapped onto physical devices that are usually non volatile so data is
safe in the case of system failure.
• The files can be accessed by the system in two ways i.e. sequential access and direct
access −
1. Sequential Access: The information in a file is processed in order using sequential
access. The files records are accessed on after another. Most of the file systems
such as editors, compilers etc. use sequential access.
2. Direct Access: In direct access or relative access, the files can be accessed in
random for read and write operations. The direct access model is based on the
disk model of a file, since it allows random accesses.
MODES OF OPERATION

User Mode Kernel Mode


• user program executes in • monitor executes in kernel
user mode mode
• certain areas of memory • privileged instructions may
are protected from user be executed
access • protected areas of
• certain instructions may not memory may be accessed
be executed
• Dual-mode operation allows OS to protect itself and other system
components
• The 2 modes are User mode and kernel mode
• Mode bit provided by hardware
• Provides ability to distinguish when system is running user code or kernel code
• Some instructions designated as privileged, only executable in kernel mode
• System call changes mode to kernel, return from call resets it to user

• Increasingly CPUs support multi-mode operations


• i.e. virtual machine manager (VMM) mode for guest VMs
TRANSITION FROM USER TO KERNEL MODE
• Timer to prevent infinite loop / process hogging resources
• Timer is set to interrupt the computer after some time period
• Keep a counter that is decremented by the physical clock.
• Operating system set the counter (privileged instruction)
• When counter zero generate an interrupt
• Set up before scheduling process to regain control or terminate program that exceeds
allotted time
OPERATING SYSTEM STRUCTURE
• Operating system can be implemented with the help of various structures. The
structure of the OS depends mainly on how the various common components of the
operating system are interconnected and melded into the kernel.
• Depending on this we have following structures of the operating system:
Simple structure
Layered
Microkernel
Modular
1. Simple structure
• Such operating systems do not have well defined
structure and are small, simple and limited systems.
• The interfaces and levels of functionality are not well
separated.
• MS-DOS is an example of such operating system. In
MS-DOS application programs are able to access
the basic I/O routines.
• These types of operating system cause the entire
system to crash if one of the user programs fails.
Advantages of Simple structure:
• It delivers better application performance because of the few interfaces between the
application program and the hardware.
• Easy for kernel developers to develop such an operating system.

Disadvantages of Simple structure:


• The structure is very complicated as no clear boundaries exists between modules.
• It does not enforce data hiding in the operating system.
2. LAYERED STRUCTURE

• An OS can be broken into pieces and retain


much more control on system.
• In this structure the OS is broken into number of
layers (levels).
• The bottom layer (layer 0) is the hardware and
the topmost layer (layer N) is the user interface.
• These layers are so designed that each layer
uses the functions of the lower level layers only.
• This simplifies the debugging process as if lower
level layers are debugged and an error occurs
during debugging then the error must be on that
layer only as the lower level layers have
already been debugged.
Advantages of Layered structure:
• Layering makes it easier to enhance the operating system as implementation of a layer can
be changed easily without affecting the other layers.
• It is very easy to perform debugging and system verification.

Disadvantages of Layered structure:


• In this structure the application performance is degraded as compared to simple structure.
• The main disadvantage of this structure is that at each layer, the data needs to be modified
and passed on which adds overhead to the system.
• Moreover careful planning of the layers is necessary as a layer can use only lower level
layers. UNIX is an example of this structure.
3. MICRO-KERNEL

• This structure designs the operating system by removing all non-essential components
from the kernel and implementing them as system and user programs.
• This result in a smaller kernel called the micro-kernel.
• Advantages of this structure are that all new services need to be added to user
space and does not require the kernel to be modified.
• Thus it is more secure and reliable as if a service fails then rest of the operating
system remains untouched. Mac OS is an example of this type of OS.
Advantages of Micro-kernel structure:
• It makes the operating system portable to various platforms.
• As microkernels are small so these can be tested effectively.

Disadvantages of Micro-kernel structure:


• Increased level of inter module communication degrades system performance.
4. MODULAR STRUCTURE
• It is considered as the best approach for an OS.
• It involves designing of a modular kernel.
• The kernel has only set of core components and
other services are added as dynamically
loadable modules to the kernel either during run
time or boot time.
• It resembles layered structure due to the fact that
each kernel has defined and protected interfaces
but it is more flexible than the layered structure
as a module can call any other module.

• For example Solaris OS is organized as shown in


the figure.
SYSTEM CALLS
• In computing, a system call is the programmatic way in which a computer program
requests a service from the kernel of the operating system it is executed on.
• A system call is a way for programs to interact with the operating system.
• A computer program makes a system call when it makes a request to the operating
system’s kernel.
• System call provides the services of the operating system to the user programs via
Application Program Interface(API).
• It provides an interface between a process and operating system to allow user-level
processes to request services of the operating system.
• System calls are the only entry points into the kernel system. All programs needing
resources must use system calls.
Services Provided by System Calls:
• System call is must when a file system wants to create or delete a file.
• Network connections require the system calls to send and receive data
packets.
• If you want to read or write a file, you need to system calls.
• If you want to access hardware devices, including a printer, scanner, you need
a system call.
• System calls are used to create and manage new processes.
Types of System Calls
• There are 5 different categories of system calls –
1. Process control
Eg: end, abort, create, terminate, allocate and free memory.
2. File management
Eg: create, open, close, delete, read file etc.
3. Device management
4. Information maintenance
5. Communication
Examples of Windows and Unix system calls
Process Windows Unix

CreateProcess() Fork()
Process Control ExitProcess() Exit()
WaitForSingleObject() Wait()

CreateFile() Open()
ReadFile() Read()
File Manipulation WriteFile() Write()
CloseHandle() Close()

SetConsoleMode() Ioctl()
Device Management ReadConsole() Read()
WriteConsole() Write()

GetCurrentProcessID() Getpid()
Information Maintenance SetTimer() Alarm()
Sleep() Sleep()

CreatePipe() Pipe()
Communication CreateFileMapping() Shmget()
MapViewOfFile() Mmap()

You might also like