Module 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

Module 1:

Introduction to Operating
System
Introduction
 Computer system can be divided into three components
 Hardware
 Software
 Users
Basic Concepts
 Hardware – provides basic computing resources such as
CPU, memory, I/O device

 Software is further divided as


 System programs - manages the operation of the computer
itself. Controls and coordinates use of hardware among
various applications and users.
For ex: OS, compilers, firmware etc.

 Application programs – define the ways in which the


system resources are used to solve the computing
problems of the users.
For ex: Word processors, compilers, web browsers,
database systems, video games etc
What is an Operating System?

 Most fundamental system program is the operating system

 A program that acts as an intermediary between a user of a


computer and the computer hardware

 Operating system goals:

 Execute user programs and make solving user problems


easier

 Make the computer system convenient to use

 Use the computer hardware in an efficient manner


User view of an operating system

 Users want convenience, ease of use and good performance.


Don’t care about resource utilization

 Users of dedicate systems such as workstations have


dedicated resources but frequently use shared resources
from servers

 Then the shared computer such as mainframe or


minicomputer need to manages all users.

 Handheld computers requirement are resources, thus


optimize for usability and battery life.
Advantage of using Operating System

 The operating system makes sure that the computer system is


convenient to use.

 Operating System acts as an intermediary among applications and


the hardware components.

 Allows user to hide details of hardware by creating an abstraction.

 It provides the computer system resources with easy to use format.

 Offers an environment in which a user may execute


programs/applications.

 Easy to use with a GUI.


System view of an operating system

1) OS is a resource allocator
 Manages all resources
 Decides between conflicting requests for efficient and
fair resource use

 What is a resource?
 Anything you can run out of…
 Computing power, memory, storage space etc

2) OS is a control program
 Controls execution of programs to prevent errors and
improper use of the computer
Computer System Organization

 Computer-system operation
 One or more CPUs, device controllers connect through
common bus providing access to shared memory

 Concurrent execution of CPUs and devices competing for


memory cycles
Computer System Operation

 I/O devices and the CPU can execute concurrently

 Each device controller manages a particular device type.

 Each device controller has a local buffer.

 CPU moves data from/to main memory to/from local buffers

 I/O is from the device to local buffer of controller

 Device controller informs CPU that it has finished its


operation by causing an interrupt
Storage Structure

 Main memory (primary storage)


 Directly accessible by the CPU
 Volatile
 Typical implementation: Dynamic RAM

 Secondary storage – extension of main memory that provides


large nonvolatile storage capacity.
 Non-volatile
 Frequently accessed during regular operation
 Typical implementation:
 Magnetic disks (hard drives)
 Solid state drives (flash drives)
Caching
 Caching is copying information into faster storage system
temporarily; main memory can be viewed as a last cache for
secondary storage.

 Cache is faster but much smaller than storage being cached.

 Faster storage (cache) checked first to determine if


information is there.

 If it is, information used directly from the cache (fast) and if


not, data is copied to cache and used there.

 Cache management is important design problem


Computer Startup
 Bootstrap program is loaded at power-up or reboot.

 Typically stored in ROM or EPROM, generally known as


firmware.

 Initializes all aspects of system with their device drivers.

 Device Driver for each device controller to manage I/O and


provides uniform interface between controller and kernel

 Loads operating system kernel into main memory and starts


execution.
Multiprogramming /Multitasking system

 Multiprogramming (Multitasking system) is needed for improve of


efficiency

 Single user cannot keep CPU and I/O devices busy at all times.

 Multiprogramming organizes jobs (code and data) so CPU always


has one to execute.

 A subset of total jobs in system is kept in main memory.

 One job selected and run via job scheduling.

 When it has to wait (for I/O for example), OS switches to another


job
Multiprogramming system
 Memory Layout for Multi programmed System is shown
below:
Multiprocessor Architecture

 Multiprocessor systems also known as parallel system or tightly-


coupled systems are growing in use and importance.

 To improve performance of uniprocessor system (with one CPU),


multiple CPUs can be interconnected in such a way that a job can
be divided among them

 Advantages include:
 Increased throughput - because of faster execution.
 Fault tolerant - Increased reliability or graceful degradation.

 Two types of Multiprocessors systems are :


 Asymmetric Multiprocessing – each processor is assigned a
special task.
 Symmetric Multiprocessing – each processor performs all tasks.
Symmetric Multiprocessing Architecture

 Symmetric Multiprocessing – each processor performs all tasks


Operating System Services
 The operating system consists of a set of software that can be used
to manage interactions with the hardware. Below are the main
functions of Operating System:

 Process management:- Process management helps OS to create and


delete processes. It also provides mechanisms for synchronization
and communication among processes.

 Memory management:- Memory management module performs the


task of allocation and de-allocation of memory space to programs
in need of this resources.

 File management:- It manages all the file-related activities such as


organization storage, retrieval, naming, sharing, and protection of
files.
Operating System Services

 Device Management: Device management keeps tracks of all


devices. This module also responsible for this task is known as
the I/O controller. It also performs the task of allocation and de-
allocation of the devices.

 I/O System Management: One of the main objects of any OS is


to hide the peculiarities of that hardware devices from the user.

 Secondary-Storage Management: Systems have several levels of


storage which includes primary storage, secondary storage, and
cache storage. Instructions and data must be stored in primary
storage or cache so that a running program can reference it.
Functions of Operating System

 Security:- Security module protects the data and information of a


computer system against malware threats and unauthorized access.

 Command interpretation: This module is interpreting commands


given by the and acting system resources to process that
commands.

 Networking: A distributed system is a group of processors which


do not share memory, hardware devices, or a clock. The
processors communicate with one another through the network.

 Job accounting: Keeping track of time & resource used by various


job and users.
Operating System Services

 Communication management: Coordination and assignment of


compilers, interpreters, and another software resource of the
various users of the computer systems.
Operating System Components
 Basically, an OS is divided into two parts – Kernel and Shell

 The kernel is the innermost or core part of the operating system.


It is the minimal OS program that is loaded in low memory area
of the main memory when computer perform booting and remain
in memory until the computer is shut down.

 Major functions of Kernel is to manage hardware resources and


provide memory management, processer management, files or
inputs / outputs management services etc.

 This enables communication with the operating system through a


control language, allowing the user to control the device without
knowing the characteristics of hardware, the management of
physical addresses, and so on.
Operating System Components

 The shell is the outer layer of the OS and acts as an


interface between the user and the computer system.

 This enables communication with the operating system


through a control language (also known as system call).

 It gets commands from user, interprets them and forward to


the kernel for necessary action.

 It thus allows the user to control the device without knowing


the characteristics of hardware, the management of physical
addresses, and so on.
System Calls
 A system call is a mechanism that provides the interface between
a process and the operating system. It is a programmatic method in
which a computer program requests a service from the kernel of
the OS.

 In general, system calls are available as assembly language


instructions.

 System calls are usually made when a process in user mode


requires access to a resource. Then it requests the kernel to
provide the resource via a system call.

 System call offers the services of the operating system to the user
programs via API (Application Programming Interface). System
calls are the only entry points for the kernel system.
System Calls
 As can be seen from the figure representing the execution of the
system call , the processes execute normally in the user mode until
a system call interrupts it.

 Then the system call is executed on a priority basis in the kernel


mode. After the execution of the system call, the control returns to
the user mode and execution of user processes can be resumed.
Types of System Calls
 In general, system calls are required in the following situations :

 If a file system requires the creation or deletion of files. Reading


and writing from files also require a system call.
 Creation and management of new processes.
 Network connections also require system calls. This includes
sending and receiving packets.
 Access to a hardware devices such as a printer, scanner etc.
requires a system call etc.

 There are mainly five types of system calls as explained below:

1) Process Control : These system calls deal with processes such as


process creation, process termination etc.
Types of System Calls
2) File Management : These system calls are responsible for file
manipulation such as creating a file, reading a file, writing into a
file etc.

3) Device Management : These system calls are responsible for


device manipulation such as reading from device buffers,
writing into device buffers etc.

4) Information Maintenance :These system calls handle


information and its transfer between the operating system and
the user program.

5) Communication : These system calls are useful for interprocess


communication. They also deal with creating and deleting a
communication connection.
Services provided by system calls

 Some of the examples of all the above types of system calls in


Windows and Unix are given as follows −
Structures of Operating Systems
 The structure of the OS depends mainly on how the various
common components of the operating system are interconnected
and melded into the kernel. Following are different structures of
the operating system:

1) Monolithic Structure

 Monolithic structuring is the simple and oldest approach to design


an operating systems. Such OS do not have well defined structure
and are consisted of a single layer that performed all the functions.

 The interfaces and levels of functionality are not well separated.

 MS-DOS is an example of such operating system. In MS-DOS


application programs can access the basic I/O routines.
Monolithic Structure
 Such operating systems are easy to develop as they are small,
simple and limited systems.

 However overall structure is very complicated as no clear


boundaries exist between modules.

 Extending such OS is also very difficult as modifying one module


can adversely affect other modules.
Layered Structure
 Layered structure is a systemic approach where 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).

 Each layer is built on the top of the lower layer thus forming a
hierarchical structure. 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.
Layered 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.


Micro-kernel based OS structure
 Adding new functionality to kernel made it heavy and unmanageable.

 New structure was designed for 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.

 The microkernel includes most essential functions like CPU


scheduling, low-level memory management, inter-process
communication etc. However other function such as file system
management, I/O with device drivers etc. are implemented as servers
which run in user mode.

 The application program requesting a service sends a message to


microkernel which delivers it to appropriate server to perform task.
Micro-kernel based OS structure
 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.

 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.
Modular Structure

 Best approach for designing an OS involves designing of a


modular kernel using object-oriented programming technique.

 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 since 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, Linux, Solaris OS is organized as shown in the


figure.
Modular Structure
 Many modern operating systems implement loadable kernel
modules where
 Each core component is separate
 Each talks to the others over known interfaces
 Each is loadable as needed within the kernel
Hybrid Structure
 Most modern operating systems have hybrid structure that combines
multiple approaches to address performance, security, and usability needs.

 Linux and Solaris kernels is monolithic, plus modular for dynamic loading
of functionality. Whereas Windows kernel is mostly monolithic, plus
microkernel for different subsystem personalities.

 Apple Mac OS X kernel is hybrid, consisting of Mach microkernel and


BSD Unix parts, plus I/O kit and dynamically loadable modules.
Virtual Machines
 A virtual machine takes the layered approach to its logical
conclusion.

 It treats hardware and the operating system kernel as though they


were all hardware.

 The fundamental idea behind a virtual machine is to abstract the


hardware of a single computer (CPU, memory, disk drives, NIC
etc.) into several execution environments thereby creating the
illusion of multiple processes, each executing on its own
processor with its own (virtual) memory.

 Thus, a virtual machine provides an interface identical to the


underlying bare hardware.
Virtual Machines
 The resources of the physical computer are shared to create the
virtual machines, each running its own operating system.
Benefits of virtual machines
 Important advantage is that the host system is protected as the
virtual-machine concept provides complete protection of system
resources since each virtual machine is isolated from all other
virtual machines. This isolation, however, permits no direct
sharing of resources.

 A virtual-machine system is a perfect vehicle for operating-


systems research and development. System development is done
on the virtual machine, instead of on a physical machine and so
does not disrupt normal system operation.

 Multiple operating system can run on the virtualized workstation


machine thus allowing program developer for rapid porting and
testing of their program in varying environments.
VMware
 The virtual machine concept is difficult to implement due to the
effort required to provide an exact duplicate to the underlying
machine.

 Another method involves writing the virtualization tool to run in


user mode as an application on the top of the operating system.

 VMware workstation is such commercial virtual machine


application that runs on host operating system

 The virtualization layer is the heart of VMware as it abstracts the


physical hardware into isolated virtual machine running as guest
operating system with each virtual machine has its virtual CPU,
memory, devices etc.
VMware Architecture

 VMware virtualization technique thus improve the efficiency of


system administration as well as system resources use.

You might also like