Design and Analysis of Algorithms

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 59

Design and Analysis of

Algorithms
MS. UMA.S
ASSISTANT PROFESSOR
COMPUTER SCIENCE/COMPUTER APPLICATIONS
THIRUVALLUVAR UNIVERSITY COLLEGE OF ARTS AND SCIENCE
TIRUPATTUR – 635901
Unit I
Operating Systems Basics
 UNIT-I (II M.Sc)
 Algorithm Analysis – Time Space Tradeoff – Asymptotic Notations – Conditional
asymptotic notation – Removing condition from the conditional asymptotic
notation - Properties of big-Oh notation – Recurrence equations – Solving
recurrence equations – Analysis of linear search.
 UNIT -I: ALGORITHM AND ANALYSIS
 What is an Algorithm? - Algorithm Specification- Performance Analysis-
Randomized Algorithms.
Unit I
 Basic Concepts of Operating System
 Services of Operating System
 Classification of Operating System
 Architecture and Design of an Operating System
 Process Management
 Introduction to Process-Process State
 PCB
 Process Scheduling
 Interprocess Communication
Basic Concepts of Operating Systems

 Introduction
 Definition – OS
 Goals of OS
 Types of OS
INTRODUCTION

 OPERATING SYSTEMS – OS
 An important part of almost every computer systems
 A computer system can be divided into 4 components
:
 The hardware
 Operating system
 Application programs
 User
 Hardware - CPU, memory and I/O devices –
 Provides the basic computing resources
 Application Programs - compilers, database systems,
games and business programs
 Define the ways in which these resources are used to solve the
computing problems of the users.
 Users
 Many different users –people, machines, other computers
 Trying to solve different problems
 Accordingly there may be many different applications
 Operating System – controls and coordinates
 the use of the hardware among the various
application programs for the various users
 OS – Government
 Components of the computer systems
 Hardware

 Software

 Data

 OSprovides the means for the proper use of


these resources in the operation of the computer
system
 Like government – OS provides no useful function
by itself.

 Itsimply provides an environment within which


other programs can do useful work
 OS- viewed as an resource allocator
 Computer system has many resources that may be required
to solve a problem
 CPU time
 Memory space
 File storage spaces
 I/O devices …
 OS acts as a manager of these resources and allocates
them to specific programs and users
 OS decides which requests are allocated resources to
operate the computer system efficiently and fairly
 OS – focuses on the need to control the various
I/O devices and user programs
 OS – control program
 ControlProgram controls the execution of user
programs to prevent error and improper use of
the computer.
 Concerns with the operation and control of I/O
devices.
 Fundamental goal of computer systems is
 To execute user programs and to make solving user
problems easier
 Towards this goal, computer hardware is
constructed.
 Since bare hardware alone is not particularly easy
to use; applications programs are developed.

 These various programs require certain common
operations
 Controlling the I/O devices
 The common functions of controlling and allocating
resources – done by OS
Definition
 Is a program that acts as an intermediary between a user of a
computer and the computer hardware
 Purpose of OS
 To provide an environment in which a user can execute programs
 Primary Goal :
 To make the computer system convenient to use. [convenience for the
user]
 Secondary Goal :
 To use the computer hardware in an efficient manner [ Efficient operation
of computer system]
Services of Operating System

 OS provides an environment for the execution of program


 OS services are provided for the convenience of the
programmer to make the programming task easier.
 Program Execution :
 System must be able to load a program into memory and to run it.
 Program must be able to end its execution either normally or
abnormally
 I/O Operations :
A running program may require I/O
 I/O may involve a file or an I/O device,
 Specific devices may require special function.
 File-System Manipulation :
 Programs need to read and write files, create and
delete files by name.
 Communication :
 Oneprocess needs to exchange information with another
process.
 Two major ways in which communication occurs
 1)Communication takes place between processes executing on the
same computer
 2) Communication takes place between processes executing on
different computer system through computer network
 Communications may be implemented via
 Shared Memory or
 Message passing
 Error detection
 OS needs to be aware of possible errors.
 Errors may occur in the
 CPU

 Memory hardware
 I/O devices
 User Programs
 For each type of error, OS should take the appropriate
action to ensure correct and consistent computing
 Resource Allocation
 Many different types of resources are managed by the
OS.
 When there are multiple users or multiple jobs running
at the same time, resources must be allocated to each
of them
 Accounting
 To keep track
which users used
how much and what kinds of computer resources
 Record keeping may be for
Accounting or accumulating usage statistics. (to
improve the computing services)
 Protection
 When several disjoint processes execute concurrently
 it should not be possible for one process to interfere with
the other or with the OS itself
 Protection involves ensuring that all access to system
resources is controlled.
 Security from outsiders is also important
 Requires authentication - Passwords
Classification of Operating System

 Simple batch Systems


 Multi Programming Systems
 Time Sharing Systems
 Multi Processor System
 Distributed Operating Systems
 Real Time Operating Systems
Simple batch Systems

 In this type of system, there is no direct interaction


between user and the computer.
 Each user prepares his job on an off-line device like punch
cards and submits it to the computer operator.
 To speed up processing, jobs with similar needs are
batched together and run as a group.
 Then a special program, the monitor, manages the
execution of each program in the batch.
 In early computers, OS was fairly simple
 Major task : transfer control automatically from one
job to the next
 OS was always resident in the memory
 Disadvantanges
 Inthis execution environment, the CPU is often idle
because the speeds of the I/O devices are much slower
than the speed of the CPU.
 User has no direct interaction with the system.
 Waiting time is more for a user/program.
 No mechanism to prioritize processes.
Simple Batch systems – Memory Layout
Multi Programming system

 Multiprogramming is a technique to execute number of


programs simultaneously by a single processor.
 In multiprogramming, number of processes resides in main
memory at a time.
 The OS picks and begins to execute one of the jobs in
main memory.
 If any I/O wait happened in a process, then CPU switches
from that job to another job.
 Hence in Multiprogramming system, CPU will
never be idle and keeps on processing.
 Ifseveral jobs are ready to run at the same time,
then system chooses which one to run (using CPU
Scheduling).
Advantages

 Efficient memory utilization


 Throughput increases
 CPU is never idle, so performance increases.
 Waiting time is limited in multiprogramming.
Disadvantages

 User can not interact directly with the system.


Time Sharing Systems
 Multiprogramming systems provide an
environment in which various system resources
like CPU, memory, I/O devices were utilized
effectively.
 Does not provide user interaction with the computer
system.
 Timesharing or multitasking is a logical extension
of multiprogramming.
 user interacts with the system.
 Multiple
jobs are executed by switching the
CPU between them
 The switches occur so frequently that users can
interact with each program while it is running
and
 User can assume that he is only working on the
system, but actually CPU is shared among
different users.
 CPU time is shared by different processes - system is
called as time sharing system.
 The CPU scheduler selects a job from the ready queue and
switches the CPU to that job. When the time slot expired,
the CPU switches from this job to another job.
 The time slice is given by the OS for sharing CPU time
between processes.
 Time sharing system uses
 CPU scheduling
 Multiprogramming

 Memory management scheme


 UNIX is a time shared system.
Advantages

 Themain advantage of time sharing system


over the batch system is,
 the user can interact with the job while it is
executing, but it is not possible in batch
system.
 Efficient CPU utilization
Disadvantages

 As numbers of users are interacting with the processor


at the same time, it is complex than multiprogrammed
OS.
 System must have memory management and protection,
since several jobs are kept in memory at the same time.
 Disk management is also required.
 Itprovides mechanism for concurrent execution which
requires complex CPU scheduling scheme.
Multiprocessor System
 Single processor systems have only one CPU, however in
multiprocessor system have more than one processor.
 These systems are also known as parallel systems or
tightly coupled systems.
 Here the processors share
 Computer Bus
 Memory

 Clock

 Peripheral Devices
  
 It is called parallel system, because numbers of
processors are executing their jobs in parallel.
A multiprocessor OS controls and manages hardware and
software resources
 such that user can view the entire system as a
powerful uniprocessor system as he is not aware of
multiprocessor system and interconnection network.
The major issues of Multiprocessor OS
are

 Process synchronization
 Task scheduling
 Memory management
 Security and protection,
 sincemain memory is shared among many physical
processors.
 Multiprocessor systems can be
 Symmetric Multiprocessing System
 Each processor runs an identical copy of the OS and these copies
communicate with one another as needed.
 Asymmetric Multiprocessing Systems
 Each processor is assigned a specific task
 A master processor controls the system, others gets instruction from
master
 Master-Slave relationship
 Master Processor Schedules and allocates work to the slave processors
Advantages

 Multiprocessor systems have advantages like:


 Increased throughput
 Economy of scale
 Increased reliability
Distributed Operating System

 Distributed OS are the OS for a network of autonomous


computers, connected by a communication network, that
follows message passing mechanism.
 In this system, processors cannot share memory or clock.
Each processor has its own local memory.
 The processors communicate with one another through
various communication lines such as high speed bus.
 Loosely Coupled Systems
A distributed OS controls and manages the software
and hardware resources of a distributed system.
 When a program is executed on a distributed system,
user is not aware of where the program is executed,
on which location etc..
 Processor in Distributed System varies in
Size and function
 Processors are referred by different names
 Sites
 Nodes
 computers
 The basic design issue of distributed operating
system is:
 Process Synchronization
 Deadlock

 Inter process communication


 Memory Management
 CPU scheduling
 Nearly
all systems today are distributed in
some way i.e.
 They use email
 Access files over a network
 Receive audios and videos etc.
 Examples
of distributed OS are Alpha,
Amoeba, Mach etc.
Advantages

 Resource sharing
 Computation Speedup
 Reliability
 Communication
 Resource Sharing
 Sharing of files at remote sites
 Processing information in a distributed DB
 Printing files at remote sites
 Computation SpeedUp
 Computation – Partitioned into a number of Sub
computations
 Runs Concurrently
 Ifany site is currently overloaded with jobs, some of
them may be moved to other, lightly loaded sites
 Load Sharing
 Reliability
 If one site fails in a distributed systems, the remaining
sites can continue operating.
 Communication
 Processes at different sites can exchange information
Real Time Operating System
 Real-time systems is used when there are rigid time
requirements on the operation of a processor or the flow of
data.
 Used as a control device in a dedicated application
 Systems that control
 scientific experiment
 Medical imaging systems
 Industrial control systems
 Fuel-injection systems
 Home-Appliances controllers
 Weapon Systems
 defined as those systems in which the correctness of the system depends not
only on the logical result produced, but also the time at which the result
produced.
 User convenience and resource utilization are secondary concern to these
systems.
 Real time systems have many events that must be accepted and processed in
a short time or within certain deadline.
 RTOS – has well-defined constraints or the system
will fail.
 RTSystem is considered to function correctly
only if it returns the correct result within any
time constraints
 Such applications include:
 Rocket lunching
 Flight control
 Robotics
 Telephone switching equipment
 Fire and smoke sensor etc.
 Real time systems are classified into two categories:
 Hard Real Time System
 Soft Real Time System
Hard Real Time System

 A system is said to be hard real time system if the


deadline is not met the system is said to have failed.
 Examples: : Industrial control applications
 On-board computers
  Robots
 These systems guarantee that critical tasks should be
completed on time.
Soft Real Time System

 A system is said to be soft real time system, If a deadline


is missed, the system does not fail.
 Only the performance of the system is said to have
degraded.
 The utility of a result decreases with time after the
deadline.
 Examples: Railway reservation system, video on demand
system

You might also like