0% found this document useful (0 votes)
9 views

Lecture 1 & 2

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Lecture 1 & 2

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

CSE 2024

Operating System
Lecture 1 & 2
Saurabh Mishra, PhD
Assistant Professor
Dept of CSE
Content
• Introduction to OS
• Basics of Hardware
• Basics of Storage
• Basics of IO
• Operating System Structure
• User Interface
• System Calls
Introduction to Operating System(OS)
• What all are the
operating system you
have used so far??
Name them
• The first operating
system used for real
work was GM-NAA I/O,
produced in 1956 by
General Motors'
Research division for its
IBM 704.
Introduction to OS
• An Operating System(OS) is a program that manages the
computer hardware
• OS also provides a basis for application programs and act as an
intermediatory between the computer user and the hardware
Introduction to OS
Types of OS Functions of OS
• Batch Operating System • Provide Interface
• Multi-Programming System • Process management
• Multi-Processing System • Resource management
• Multi-Tasking Operating System • Security
• Time-Sharing Operating System
• Distributed Operating System Goals of OS
• Network Operating System • Convenience
• Efficiency
• Real-Time Operating System
Computer System(Hardware) Basics
• A modern general purpose computer system consist of one or
more CPUs and a number of device controllers connected
through a common bus that provide access to shared memory.
Computer System(Hardware) Basics
• Each device controller is in-charge of a particular device type.
• The CPU and the device controller can execute concurrently,
competing for memory devices
• To ensure the orderly access to the shared memory, a memory
controller is provided whose function is to synchronize access to
the memory
Other Basics
Bootstrap Process
• Initial program that runs when the computer is switched on or rebooted
• It is stored within the computer hardware in read-only memory (ROM) or
electrically erasable programmable read-only memory (EEPROM), known by
the general term firmware.
• It must locate and load
into memory the OS kernel.
Other Basics
Interrupt
• The occurrence of an event is usually signaled by an interrupt from either the
hardware or the software.
• Hardware may trigger an interrupt at any time by sending a signal to the CPU,
through the system bus.

System Call(Monitor call)


• Software may trigger an interrupt by executing a special operation called a
system call (also called a monitor call).
Other Basics
Other Basics
• When the CPU is interrupted, it stops
what it is doing and immediately transfers
execution to a fixed location.
• The fixed location usually contains
the starting address where the
service routine for the interrupt is
located.

• The interrupt service routine executes.


• On completion, the CPU resumes the
interrupt computation.
Storage Structure Basics
• The CPU can load instructions only
from memory, so any programs to
run must be stored there.
• General-purpose computers run
most of their programs from re
writable memory, called main
memory (also called random-
access memory, or RAM).
• ROM can not be changed, only static
programs, such as the bootstrap
program are stored there.
Storage Structure Basics

• All forms of memory provide an array of


bytes. Each byte has its own address.
Interaction is achieved through a
sequence of load or store instructions to
specific memory addresses.
✓load ~> The load instruction moves a byte
(smallest addressable unit of a CPU) or
word (register size or amount of data that
can be transferred between CPU and RAM)
from main memory to an internal register
within the CPU.
✓store ~> The store instruction moves the
content of a register to main memory.
Storage Structure Basics
I/O operation
• The main theme of operating system is dedicated to manage I/ O.
• A general purpose computer system consists of CPUs and
multiple device controllers that are connected through a common
bus.
• Each device controller is in charge of a specific type of device.
• Device Controller maintains local buffer storage and set of special
purpose register
• Depending on the controller, more than one device may be
attached. For instance, 7 or more devices can be attached to the
small computer-systems interface (SCSI) controller.
I/O operation

SCSI devices includes hard disk drives, tape drives, CD/DVD drives, and scanners
I/O operation
• A device controller maintains some local buffer storage and a set
of special-purpose registers.
• The device controller is responsible for moving the data between
the peripheral devices that it controls and it local buffer storage.
• Typically, operating system have a device driver for each device
controller.
• This device driver understands the device controller and provides
the rest of the operating system with a uniform interface to the
device.
I/O operation
Working of an I/O operation
• To start an IO operation, the device driver loads the
appropriate registers within the device controller.
• The device controller examines the contents of these
registers to determine what action to take (like ‘read a
character from the keyboard’, ‘display a string’, etc.).
• The controller starts the transfer of data from the device
to its local buffer.
• When the transfer of data is complete, the device
controller informs the device driver via an interrupt that
it has finished its operation.
• The device driver then returns control to the operating
system.
I/O operation
• This form of interrupt-driven I/O is fine for moving small amounts of
data but can produce high overhead when used for bulk data
movement such as disk I/O.
• To solve this problem, direct memory access (DMA) is used. After
setting up buffers, pointers and counters for the I/O device, the device
controller transfers an entire block of data directly to or from its own
buffer storage to memory, with no intervention by the CPU.
• Only one interrupt is generated per block, to tell device driver that the
operation has completed, rather than the one interrupt per byte
generated for low-speed devices.
• So, while the device controller is performing these operations, the CPU
is available to accomplish other task/operation.
CPU Architecture
• Single Processor System
• One main CPU capable of executing a general-purpose instruction set,
including instructions from user processes
• Other special-purpose processors may come in the form of device-specific
processors, such as disk, keyboard, and graphics controllers; or, on
mainframes.
• Multiprocessor System
• Also known as parallel systems or tightly coupled systems
• Two or more processors in close communication, sharing the computer bus and
sometimes the clock, memory, and peripheral devices.
• Clustered Processor System
• Composed of two or more individual systems coupled together.
• Share storage and are closely linked via a local-area network (LAN)
provide high-availability service
Operating System Structure
• Multiprogramming
• Multitasking/Time sharing
Operating System Structure
Multiprogramming
• Increases CPU utilization by organizing jobs (code and data) so that the CPU
always has one to execute. The operating system keeps several jobs in
memory simultaneously
• Operating system keeps several jobs in the memory simultaneously.
• Since, main memory is too small to accommodate all jobs, the jobs are kept
initially on the disk in the job pool. This pool consists of all processes residing
on disk awaiting allocation of main memory.
• Operating system picks and begins to execute one of the jobs in memory.
Eventually, if that job have to wait for some task, the CPU switches to another
job, and so on.
• Eventually, the first job finishes waiting and get the CPU back. As long as at
least one job needs to execute, the CPU never idle.
Operating System Structure
Multiprogramming
Operating System Structure
Multitasking/Time sharing
• Time-sharing (or multitasking) is a logical extension of
multiprogramming.
• In time-sharing systems, the CPU executes multiple jobs by switching
among them, but the switches occur so frequently that the users can
interact with each program while it is running.
• Time-sharing requires an interactive computer system, which provides
direct communication between the user and the system.
• The user gives instructions to the operating system or to a program
directly, using an input device such as a keyboard, mouse, touchpad,
or touch screen, and waits for immediate results on an output device.
Operating System Structure
Multitasking/Time sharing
Operating System Services
• Program execution
• Input Output Operations
• Communication between Process
• File Management
• Memory Management
• Process Management
• Security and Privacy
• Resource Management
• User Interface
• Networking
• Error handling
• Time Management
User Operating System Interface
There are two fundamental approaches for users to interface with
the OS.
• One technique is to provide a command-line interface or
command interpreter that allows users to directly enter
commands that are to be performed by the OS.
• The second approach allows the user to interface with the OS via
a graphical user interface or GUI.
Operating System Services
Command-line interface or command interpreter
• Some OSs include the command interpreter in the kernel.
• Others, such as Windows XP and UNIX, treat the command
interpreter as a special program that is running when a job is
initiated or when a user first logs on (on interactive systems).
• On systems with multiple command interpreters to choose from,
the interpreters are known as shells.
• Bourne Shell
• C-Shell
• Bourne Again Shell(BASH)
• Korn Shell, etc
User Operating System Interface
Graphical User Interface
• Rather than having users directly enter commands via a
command-line interface, a GUI allows provides a mouse-based
window-and-menu system as an interface.
• Graphical user interfaces first appeared due in part to research taking place in the early 1970s at Xerox PARC research facility. The first GUI appeared on the
Xerox Alto computer in 1973. However, graphical interfaces became more widespread with the advent of Apple Macintosh computers in the 1980s.
• Microsoft's first version of Windows -version 1.O- was based upon a GUI interface to the MS-DOS OS.
• Traditionally, UNIX systems have been dominated by command-line interfaces, although there are various GUI interfaces available.

• The choice of whether to use a command-line or GUI interface is


mostly one of personal preference.
• Most Windows users are pleased to use the Windows GUI
environment and almost never use the MS-DOS shell interface.
System Call
• A system call is an interface between a program running in user
space and the operating system.
• A system call is a method for a computer program to request a
service from the kernel of the operating system on which it is
running.
• A system call is a method of interacting
with the operating system via programs.
• These calls are generally available as
routines written in C and C++
User and Kernel Mode
System Call
System Call
Types of System calls
• Process Control
• File Management
• Device Management
• Information Maintenance
• Communication.
Next Lecture
System Programming

For any queries:


[email protected]

You might also like