Operating Systems
L T JayPrakash
[email protected]
Oct 15, 2014
Introduction to the Course
Introduction and Background
Goals, Course Delivery and Outline
Learning Management System (LMS)
Syllabus and Pedagogy
Class and Homework Assignments
Why study Operating Systems?
Course Delivery
Course Goals
Introduce you to operating system concepts
− Hard to use a computer without interacting with OS
− Understanding the OS makes you a more effective
programmer
Cover important systems concepts in general
− process, concurrency, memory management, I/O, files.
Understanding to deal with systems programming
− Programming assignments through different offerings
Preparatory to take second level courses
− Real-time systems, Advanced Topics in OS
Course Delivery and Exam Schedule
Every Wed @ 9.30 am, Thu @ 9.30 am.
Lecture Dates – Oct (15,18,22,23,29,30), Nov
(5,6,12,13,19,20,26,27), Dec (3,4) – 16 sessions.
Final Exam Date – Week of Dec 8, 2014.
For course related queries – After the lecture, or
meet me in my office (room number 110).
Course Outline
Focus to be core topics in OS.
– Few other topics through papers / presentation.
Half the course credit will be for homework / quizzes /
assignments / programming exercises, and half on the
end-term exams.
Programming Credits
− Half of the credit will be based on individual effort, and
− Half on the success — or lack thereof – of the overall
team effort, in case it is a team exercise.
There may be a one / two surprise quizzes in the next
seven / eight weeks of the remaining semester.
Term paper : Search – Register - Study – Report – Submit.
LMS
Handouts, announcements, etc., are posted
there, and the page will be updated throughout
the semester.
It will be presumed that each one of you will
access LMS frequently.
In case of any problems with LMS, email will be
the alternative mechanism.
Syllabus
There are numerous good sources of information for study, but no single
textbook may be sufficient due to the evolving nature of the subject.
I do not mandate a particular textbook on operating systems -- there are many
possible alternatives, all of which are reasonable, none of which may cover all.
I recommend coming to class and be a part of class discussions.
– Key criteria for attending tests / end-semester examinations.
Read the book in background (e.g., after we cover a topic in class), both to fill in
your knowledge, as well as to get a different perspective on operating systems.
Any of these books are fine:
− Andrew Tanenbaum - "Modern Operating Systems"
− Silberschatz, Galvin - "Operating System Concepts"
Others may be fine too – that you may decide as well.
Topics on processes, memory management,
scheduling, deadlocks, I/O, and file systems.
Pedagogy
Discussion based on theoretical concepts.
Problem solving exercises.
Few programming assignments either in class / take
away work
Pattern of Exam QP
− Less theory, more problem solving.
− Multiple choice questions (may be).
− Scenario-based reasoning type questions.
− Comparison type, definitions, short questions etc.
− Long theory questions like short notes will NOT be
part of any exam.
Assignments
The assignments will be posted on LMS.
Doing well in assignments is indicative of your doing well in the course
overall.
The performance in assignment may be considered as a factor in
deciding the score for individual performance.
The assignments could be any of the following types – finding internal
details, programming, problem solving, paper reading etc.
They may have a submission deadline, or in case no deadline is given,
the default deadline will be Dec 4, 2014 (firm).
Submission : through email.
– Send it as attachment to
[email protected] • Email subject (very important): MT2014-OS-<AssgnID>-<Deadline>
• Filename (generally) your roll number - MT2014###
Sharing and collaboration are great, but must respect rules! Team work is
always encouraged. Programming assignments / tests will be in pairs of
two.
Use of LATEX is preferred for all documentation.
Why study Operating Systems?
Operating systems are a maturing field
− Most people use a handful of mature OSes
− Hard to get people to switch operating systems
− Hard to have impact with a new OS
High-performance servers are an OS issue
− Face many of the same issues as OSes
Resource consumption is an OS issue
− Battery life, radio spectrum, etc.
Security is an OS issue
− Hard to achieve security without a solid foundation
New “smart” devices need new OSes
Big Data, Networks, large-scale software systems, whatever --- Key to its success is
Web browsers
Operating System Designincreasingly faceand
Principles, its working OS issues
optimal use of its policies.
Course Delivery
Theory necessary for the foundation, however,
practical approach preferred.
Supported by different research papers, possibly
original articles to get the depth of topics.
− We may not be able to discuss research papers in
the class, but pointers will be provided and interested
students may like to read the original paper along
with related book chapters.
− Select your term paper at the earliest and register
with me.
• Report submission deadline – Dec 4, 2014.
What is an OS?
Tool to make programmer's job easy
Resource allocator / manager
− Must be fair; not partial to any process, specially for process in
the same class
− Must discriminate between different class of jobs with different
service requirements
− Do the above efficiently
Within the constraints of fairness and efficiency, an OS should attempt to
maximize throughput, minimize response time, and accommodate as
many users as possible
Control program
Tool to facilitate efficient operation of a computer system
Virtual machine that is easier to understand and program
– Encapsulates the complexities of hardware
OS as Resource Manager
• A computer is a set of resources for the
movement, storage, and processing of data.
– Data could be associated with programs, devices,
and even the underlying hardware.
• The OS is responsible for managing these
resources.
15
15
OS as Resource Manager
16
16
Layers and Views
17
17
Layered Architecture Design
This is our point of
focus
Typical OS structure
− Application environment - shell, mail, text processing package, sccs
− Operating system - support programs for applications
A microinstruction program that controls the functions of a central processing unit or
peripheral controller of a computer.
A set of microinstructions that defines the individual operations that a computer carries
out in response to a machine-language instruction.
..... many more definitions published and available in different literature.
Zooming into the OS Layer
Programs and Processes
Resource Usage – includes memory, disk etc.
Input / Output Operations
File Systems These are our point of
focus
Communication
Protection and Security
Accounting for all.
OS as Service Provider
• Program development
– e.g., editors and debuggers
• Program execution
• Access I/O devices
• Controlled access to files
• System access for shared systems
• Error detection and response
– e.g., memory error, device failure, division by zero
• Accounting for resources and performance monitoring
How about Operating System as a Service? - Think about it!
We are in the age of Cloud Computing – How OS changes?
20
20
Operating System
• A program that controls the execution of application
programs
• An interface between applications and hardware
• Main objectives of an OS:
– Convenience
– Efficiency and Fairness
– Ability to evolve
21
21
1945 - 1955
Bare machines - vacuum tubes and plugboards
Early Systems No operating system, No protection
Black box concept - human operator
ENIAC - Electronic Numerical Integrator And Computer
Second
Generation
Third
Fourth Generation and beyond
Generation
1945 - 1955
Bare machines - vacuum tubes and plugboards
Early Systems No operating system, No protection
Black box concept - human operator
ENIAC - Electronic Numerical Integrator And Computer
1956 - 1965
Second Transistors and batch systems
Clear distinction between designer, builders, operators,
Generation Programmers, and maintenance personnel
I/O channel
Read ahead / spooling,Interrupts / exceptions
Minimal protection, Libraries / JCL
Third
Fourth Generation and beyond
Generation
1965 - 1980
ICs and Multiprogramming
System 360 and S/370 family of computers
Spooling (simultaneous peripheral operation on-line)
Early Systems
Time sharing
On-line storage for - system programs, user programs/data, and libraries.
Virtual memory
Multiprocessor configurations
MULTICS - Multiplexed Information and Computing Service
Second
Design started in 1965 and completed in 1972
Generation
Collaborative effort between GE, Bell Labs, and Project MAC of MIT
Aimed at providing - simultaneous computer access to large community
of users, ample computation power and data storage,
easy data sharing between users, if desired
Third
Fourth Generation and beyond
Generation
Personal computers and workstations
MS-DOS and Unix
Early Systems
Massively parallel systems
Pipelining
Array processing / SIMD
Multiprocessing / MIMD
Symmetric multiprocessing
Any process and any thread can run on any available processor
Second
Computer networks (communication aspect) - network operating systems
Generation
Distributed computing - distributed operating systems
Third
Fourth Generation and beyond
Generation
Uniprogramming
• Processor must wait for I/O instruction to
complete before preceding
31
31
Multiprogramming
• When one job needs to wait for I/O, the
processor can switch to the other job
Idea of degree of multiprogramming – solution to avoiding CPU being idle
But what is the effect on Response time? 32
32
Time Sharing Systems
• Using multiprogramming to handle multiple
interactive jobs
• Processor’s time is shared among multiple
users
33
33
OS Concepts
Kernel
Permanently resides in the main memory
Controls the execution of processes by allowing their
creation, termination or suspension, and commn.
Schedules processes fairly for execution on the CPU
Allocates main memory for an executing process
File system maintenance
Allows processes controlled access to peripheral
devices such as terminals, tape drives, disk drives, and
network devices.
Design options – Monolithic kernels, Layered, Micro
kernels.
OS Concepts
• Processes share the CPU in a time-shared manner
– CPU executes a process
– Kernel suspends it when its time quantum elapses
– Kernel schedules another process to execute
Kernel – Kernel later reschedules the suspended process
Permanently resides in the main memory
Controls the execution of processes by allowing their
creation, termination or suspension, and commn.
Schedules processes fairly for execution on the CPU
Allocates main memory for an executing process
File system maintenance
Allows processes controlled access to peripheral
devices such as terminals, tape drives, disk drives, and
network devices.
Design options – Monolithic kernels, Layered, Micro
kernels.
OS Concepts
Kernel
Allows processes to share portions of their address space under certain conditions,
but protects the private address space of a process from outside tampering
If system runsPermanently resides infrees
thememory
main by memory
low on free memory, the kernel writing a process temporarily
to secondary memory, or swap device
Controls
If kernel writes the execution
entire processes of processes
to a swap device, by allowing
then the implementation their
is called a
creation,
swapping system; termination
if it writes pages of memoryortosuspension,
a swap device, it and commn.
is called a paging system.
Coordinates with the machine hardware to set up a virtual to physical address that maps
Schedules processes
the compiler generated fairly
addresses for physical
to their execution on the CPU
addresses
Allocates main memory for an executing process
File system maintenance
Allows processes controlled access to peripheral
devices such as terminals, tape drives, disk drives, and
network devices.
Design options – Monolithic kernels, Layered, Micro
kernels.
OS Concepts
Allocates secondary memory
Kernel for efficient storage and
retrieval of user data
Permanently resides in the main memory
Allocates secondary storage for
Controls the execution of processes by allowing
user files their
creation, termination or suspension,Reclaims
and commn.
unused storage
Schedules processes fairly for execution
Structureson
thethe CPU
file system
in a well understood manner
Allocates main memory for an executing process
Protects user files from
File system maintenance illegal access
Allows processes controlled access to peripheral
devices such as terminals, tape drives, disk drives, and
network devices.
Design options – Monolithic kernels, Layered, Micro
kernels.
OS Concepts - Program
Program
Collection of source code instructions and any
associated data kept in a disk file
Source program, or a human-readable text file.
Machine language translation of the source
program, or object file
• The file is marked as executable.
• File contents are arranged according to rules
established by the kernel
Executable program, complete code output by linker /
loader, with input from libraries
Example of Program Execution
40
40
Instruction Execution
• A program consists of a set of instructions
stored in memory
• Two steps
– Processor reads (fetches) instructions from
memory
– Processor executes each instruction
41
41
OS Concepts – Process / Threads
Created by kernel as an environment in which program executes.
Program in execution
May be stopped and later restarted by the OS – How?
Program's core image (sometimes core means pri. memory)
Segments – Instruction seg., User data seg., and sys. data
System data segment
Includes attributes such as current directory, open ile
descriptors, and accumulated CPU times
Information stays outside of the process address space
Process id
Process may acquire resources (more memory, open ile) not
present in the program – Who? How?
Child and parent processes – When? How?
Communication between processes through messages – How?
Thread
Stream of instruction execution
Dispatchable unit of work to provide intraprocess concurrency in OSs.
Process may have multiple threads of execution in parallel, each thread
executing sequentially.
OS Concepts
Memory (Volatility)
– Memory hierarchy based on storage capacity, speed, and cost
– Higher the storage capacity, lesser the speed, and lesser the cost
– Different memory levels, in decreasing cost per byte of storage
– Use hierarchical memory to transfer data from lower memory to
higher memory to be executed
– Locality of reference
• Most of the references in the memory are clustered and move from one
cluster to the next
– Cache memory
• Use of very fast memory (a few kilobytes) designated to contain data for
fast access by the CPU
– Virtual memory or extension of main memory
– Disk cache
• Data-intensive applications (generally rotational speed and seek time)
OS Concepts
Memory (Volatility)
– Memory hierarchy based on storage capacity, speed, and cost
– Higher the storage capacity, lesser the speed, and lesser the cost
– Different memory levels, in decreasing cost per byte of storage
– Use hierarchical memory to transfer data from lower memory to
higher memory to be executed
– Locality of reference
• Most of the references in the memory are clustered and move from one
cluster to the next
– Cache memory
• Use of very fast memory (a few kilobytes) designated to contain data for
fast access by the CPU
– Virtual memory or extension of main memory
– Disk cache
• Data-intensive applications (generally rotational speed and seek time)
OS Concepts
Memory (Volatility)
A disk cache is a mechanism for improving the time
– Memory hierarchy based on storage capacity, speed, and cost
it takes to read from or write to a hard disk.
– Higher the storage capacity, lesser the speed, and lesser the cost
Today, the disk cache is usually included as part of the hard disk.
– Different memory levels,
(A disk cachein isdecreasing cost
RAM built into perhard
your bytedisk)
of storage
(Disk specifications : on-board cache)
– Use hierarchical memory to transfer OR data from lower memory to
higher memory
A disk cache to
canbe executed
also be a specified portion of system RAM (disk buffer).
– Locality of reference
Disk cache holds data that has recently been read and, in
some cases, adjacent data areas that are likely to be accessed next.
• Most of the references in the memory are clustered and move from one
cluster to the next
Write caching (accumulated) is also provided with some disk caches.
– Cache memory
• Use of very fast memory (a few kilobytes) designated to contain data for
fast access by the CPU
– Virtual memory or extension of main memory
– Disk cache
• Data-intensive applications (generally rotational speed and seek time)
OS Concepts – System Calls
Interface between user program and operating system - Set of extended instructions
provided by the operating system
Applied to various software objects like processes and files
Invoked by user programs to communicate with the kernel and request
services
Access routines in the kernel that do the work
Library procedure corresponding to each system call
Why modes?
Privileges?
- indicates power for
System control
Working of a System Call – How?
Interrupts
• Interrupt the normal sequencing of the
processor
• Provided to improve processor utilization
– Most I/O devices are slower than the processor
– Processor must pause to wait for device
47
47
Flow of Control w/o Interrupts and I/O Wait
Figure 1
50
50
Flow of Control with Interrupts and I/O Wait
Figure 2
51
51
Transfer of Control via Interrupts
52
52
Instruction Cycle
with Interrupts
53
53
Simple Interrupt Processing
54
54
Changes in Memory and Registers
for an Interrupt
55
55
Assignment 1
Write, test, and debug a program in the language
of your choice to carry out any task you choose.
Then write a list of all the services you suspect
the operating system is providing in order to
support the execution of your sample program.
Assignment Objective:
Understanding How a Program really runs?
Assignment 1 ...cont'd
Conduct a simple experiment in which you take some action on a computer
system and observe what the response is. You can choose any action you
wish and any computer system for which you have appropriate access. You
can either observe a quantitative result, such as how long the response
takes or how much output is produced, or a qualitative result, such as in
what form the response arrives. Now, try replicating the experiment. Do
you always get the same result? Similar ones? Are there any factors
that need to be controlled in order to get results that are at least
approximately repeatable? For example, to get consistent times, do you
need to reboot the system between each trial and prevent other people /
programs from using the system? To get consistent output, do you need to
make sure input files are kept unchanged? If your action involves a
physical device, such as a printer, do you have to control variables such as
whether the printer is stocked with paper?
Finally, write up a careful report, in which you explain both what experiment
you tried and what results you observed. You should explain how
repeatable the results proved to be and what limits there were on the
repeatability. You should describe the hardware and software
configuration in enough detail that someone else could replicate your
experiment and would be likely to get similar results.
Submission Instructions
Mail subject line: MT2014-OS-HA1-221014
File name of your attachment: MT2014###