You are on page 1of 44

Lecture 1- Introduction to Operating Systems

MN404 Fundamentals of Operating Systems and


programming
Compiled by : Dr Nandini Sidnal
Moderated by A/Prof Savitri Bevinakoppa

Acknowledgement: Slides are taken from Cengage instructors resources - Greg


Tumsho, Guide to Operating Systems, 5th Edition, Cengage Learning, 2016
Objectives

 After completing this chapter, you should be able to


describe:
• Innovations in operating systems development
• The basic role of an operating system
• The major operating system software subsystem
managers and their functions

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 2


What is An Operating System

 A modern computer consists of:


– One or more processors
– Main memory
– Disks
– Printers
 It is impossible for every application programmer to
understand every detail
 A layer of computer software is introduced to provide
a better, simpler, cleaner model of the resources and
manage them.
July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 3
Where the Operating System fits in

Figure 1-1. Where the operating system fits in.


July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 4
Where the Operating
System fits in
 On top of hardware is OS
 Most computers have two modes of operation:
• Kernel mode and User mode
• OS runs in kernel mode, which has complete
access to all hardware and can execute any
instruction
• Rest of software runs in user mode, which has
limited capability
• Shell or GUI is the lowest level of user mode
software

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 5


Computer System Structure
• Computer system can be divided into four components:
– Hardware – provides basic computing resources
• CPU, memory, I/O devices
– Operating system
• Controls and coordinates use of hardware among various
applications and users
– 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
– Users
• People, machines, other computers
July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 6
Four Components of a
Computer System

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 7


Role of Operating Systems
• A Resource manager
– Support many devices simultaneously
– Allocate resource to different users
– Share resources among users fairly, efficiently, and safely
– Resolve conflict in resource demand

• An extended (abstract) machine


– OS hides the implementation details
– Computer appears to be more than it really is (many
processors, large memory)
– Provides stable, portable, reliable, safe, well-behaved
environment
July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 8
Subsystem Managers

• Includes four essential subsystem managers


– Memory Manager
– Processor Manager
– Device Manager
– File Manager

• Each manager:
– Works closely with other managers
– Performs a unique role

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 9


Main Memory Management

• In charge of main memory


– Random access memory (RAM)
• Requires constant flow of electricity to hold data
• Responsibilities include:
– Checking validity and legality of memory space request
– Reallocating memory to make more useable space
available
– Deallocating memory to reclaim it
– Protecting space in main memory occupied by operating
system

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 10


Main Memory Management

• Read-only memory (ROM)


– Another type of memory
– Critical when computer is powered on
– Holds firmware: programming code
• When and how to load each piece of the operating
system after the power is turned on
– Non-volatile
• Contents retained when the power is turned off

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 11


Processor Management

• In charge of allocating Central Processing Unit (CPU)


• Tracks process status
– Program’s “instance of execution”
• Comparable to a traffic controller
– When a process is finished or maximum computation time
expired
• Processor Manager reclaims the CPU and allocates to
next waiting process
– Computer with multiple CPUs
• More complex management

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 12


Device Management

• In charge of connecting with every available device


– Printers, ports, disk drives, etc.
• Responsibilities include:
– Choosing most efficient resource allocation method
• Based on scheduling policy
– Identifying each device uniquely
– Starting device operation (when appropriate)
– Monitoring device progress
– Deallocating the device
• What is the function of a device driver?

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 13


File Management

• In charge of tracking every file in the system


– Data files, program files, compilers, application programs,
etc.
• Responsibilities include:
– Enforcing user/program resource access restrictions
• Uses predetermined access policies
– Controlling user/program modification restrictions
• Read-only, read-write, create, delete
– Allocating space for a file on secondary storage
• One large storage area or smaller linked pieces
– Retrieving files efficiently
July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 14
Network Management

• Included in operating systems with networking capability


• Authorises users to share resources
– Overall responsibility for every aspect of network
connectivity
• Devices, files, memory space, CPU capacity, etc.

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 15


User Interface

• Portion of the operating system


– Direct interaction with users
• Two primary types
– Graphical user interface (GUI)
• Input from pointing device
• Menu options, desktops, and formats vary
– Command line interface
• Keyboard-typed commands that display on a monitor
• Strict requirements for every command: typed accurately; correct
syntax; combinations of commands assembled correctly

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 16


Cooperation Issues

• No single manager performs tasks in isolation


• Each element of an operating system
– Performs individual tasks and
– Harmoniously interacts with other managers
• Incredible precision required for operating system to
work smoothly
• More complicated when networking is involved

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 17


Manager Cooperation

When a user executes a command:


1. User Interface Manager: accepts requests from users to run programs: e.g.
double click on Word, tap on an app icon, User Interface Manager
a. Identifies the required program/app
b. Invokes the Process Manager to run it
2. Process Manager
a. Requests memory to the Memory Manager, and then loads the program via
the File Manager into that memory
3. As the process executes, it may use the File Manager and Device Manager to
display output and read/write data
4. When the program is complete, the Process Manager signals all the other
service managers to release their resources

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 18


Operating systems concepts

 Many of these should be familiar to Unix


users…
– Processes (and trees of processes)
– Deadlock
– File systems & directory trees
– Pipes

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 19


Processes

• Multiprogramming of four programs


• Conceptual model of 4 independent, sequential processes
• Only one program active at any instant

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 20


Processes and programs

The difference between a process and a program:


 Baking analogy:
o Recipe = Program
o Baker = Processor
o Ingredients = data
o Baking the cake = Process
 Interrupt analogy
o The baker’s son runs in with a wounded hand
o First aid guide = interrupt code

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 21


Main OS Process-related
Goals

• Interleave the execution of existing processes to


maximise processor utilisation
• Provide reasonable response times
• Allocate resources to processes
• Support inter-process communication (and
synchronisation) and user creation of processes

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 22


How are these goals
achieved?
• Schedule and dispatch processes for execution by the
processor
• Implement a safe and fair policy for resource
allocation to processes
• Respond to requests by user programs
• Construct and maintain tables for each process
managed by the operating system

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 23


Deadlock

Potential deadlock Actual deadlock


Compiled by : Dr Nandini Sidnal Moderated by Prof
July 2020 Savitri Bevinakoppa 24
Deadlock situation

Compiled by : Dr Nandini Sidnal Moderated by Prof


July 2020 Savitri Bevinakoppa 25
Deadlocks

Compiled by : Dr Nandini Sidnal Moderated by Prof


July 2020 Savitri Bevinakoppa 26
Deadlock Problem

• A set of blocked processes each holding a resource and waiting to


acquire a resource held by another process in the set.

Example
• System has 2 tape drives.
• P0 and P1 each hold one tape drive and each needs another one.

• Handing Deadlocks
– Deadlock Prevention
– Deadlock Avoidance
– Deadlock Detection
– Deadlock Mitigation

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 27


Hierarchical file systems
Root directory

bin cse

faculty grads

ls ps cp csh
elm sbrandt kag amer4

classes research
stuff stuff

Compiled by : Dr Nandini Sidnal Moderated by Prof


July 2020 Savitri Bevinakoppa 28
Interprocess communication
• Processes want to exchange information with each other
• Many ways to do this, including
– Network
– Pipe (special file): A writes into pipe, and B reads from it

A B

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 29


System calls

• Programs want the OS to perform a service


– Access a file
– Create a process
– Others…
• Accomplished by system call
– Program passes relevant information to OS
– OS performs the service if
• The OS is able to do so
• The service is permitted for this program at this time
– OS checks information passed to make sure it’s OK
• Don’t want programs reading data into other programs’ memory!
July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 30
Understanding How Operating
Systems Work
• Elements that enable an operating system to
work with a computer include:
– The kernel
– Resource managers
– Device drivers
– Application software
– BIOS

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 31


The Kernel

• The kernel consists of the essential program code


of the operating system
• Key tasks of the OS Kernel:
– Scheduling computer processes
– Managing resources, such as memory and processing time
• Jobs performed by the kernel can include:
– Managing interactions with the CPU
– Starting, managing, and scheduling programs that
handle I/O activities, including device and networking
activities

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 32


The Kernel

• Jobs performed by the kernel (cont’d):


– Handling basic computer security
– Managing use of the computer’s memory (RAM)
– Managing priority levels assigned to programs and
computer processes
• In Windows, the name of the kernel file is
ntoskrnl.exe and in MAC OS X, the kernel is
called XNU

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 33


Resource Managers

• Help ensure memory is used properly and there are


no memory conflicts
• Manages how programs access the processing
capabilities of the CPU
– Example: if there is one CPU and ten programs that want to
access the CPU, the OS will give each program a time slice
on the CPU
• Each program does a little working during its time slice and then
hands the CPU access over to the next program the kernel gives the
next program or process CPU access for its time slice

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 34


Device Drivers and the
Operating System
• A device driver translates computer code to
display text on a screen
– Or translates movements of a mouse into action
• A separate device driver is usually present for
each I/O device
• The device driver contains the actual code
(instructions) to communicate with the chips
on the device

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 35


Device Drivers and the
Operating System

Figure 1-2 Device drivers provide communication between the OS and hardware devices
July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 36
The Role of Application
Software
• Application software
– Any program a user might choose to run on a computer
• Examples: word processor, spreadsheet,
database, and a computer game
• An operating system manages the
communication among the applications, the user,
and the computer
– Allows application programmers to concentrate on
applications that will run on any hardware, as long as the OS
can control them
July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 37
The Role of Application
Software

Figure 1-3 Application programs communicate with hardware through the operating system
July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 38
The Role of the BIOS

• BIOS – basic input/output system


• A low-level program code that:
– Resides on a chip on the computer’s motherboard
– Initiates/enables communications with hardware devices
– Performs tests at startup called power-on self test (POST)
– Conducts basic hardware and software communications
inside the computer
– Starts a full-fledged operating system that interfaces with
the user

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 39


The Role of the BIOS
• Every PC has a BIOS, which is stored in a flash memory
chip
– Flash memory does not lose its contents when the
computer is turned off
• BIOS is stored in a complementary metal oxide
semiconductor (CMOS) memory chip
• When a PC is turned on:
– Runs a startup program inside the BIOS
– Program initialises the screen and keyboard, tests
hardware, initialises the hard disk and other drives
– Loads the main operating system onto the hard disk
July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 40
A Summary of Operating
System Elements

Figure 1-5 General operating system design

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 41


Summary

• Over all what is an Operating System and its role.


• Concepts of operating System: Processes,
Deadlock, File systems & directory trees and
Pipes
• Elements that enable Operating System to work

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 42


Resources

1. http://www.scs.stanford.edu/17wi-cs140/notes/intro.pdf
2. Operating System Concepts, Ninth Edition, A Silberschatz.
Peter Galvin, Greg Gagne
3. u.cs.biu.ac.il/~ariel/download/os381/ppts/os1-1_int.pp
4. Understanding Operating Systems, 7th edition and Guide to
Operating Systems, 5th Edition
5. https://courses.cs.washington.edu/courses/cse451/07sp/lect
ures/1-Introduction.ppt
6. Operating Systems, 7th edition and Guide to Operating
Systems, 5th Edition

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 43


Lecture 1 Questions

1. Explain the role of an operating system


2. Name and explain the role of the essential managers of an
operating system and explain how they cooperate with each
other to get a job done.
3. Provide at least three resources the operating system allocates.
4. What is the common name used to refer to the operating system
program?
5. Do all computing devices have same OS? Why not or yes?

July 2020 Compiled by : Dr Nandini Sidnal Moderated by Prof Savitri Bevinakoppa 44

You might also like