Download - Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah [email protected] Amirkabir University of Technology (Tehran Polytechnic) Amir

Transcript
Page 1: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Introduction to Operating Systems(Part I)

Amir H. [email protected]

Amirkabir University of Technology(Tehran Polytechnic)

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 1 / 48

Page 2: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Course Information

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 2 / 48

Page 3: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Course Objective

I The purpose of this course is to teach the design of operating sys-tems.

I Topics we will cover include:• Process management• Memory management• File systems• I/O management• Security and privacy

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 3 / 48

Page 4: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Course Objective

I The purpose of this course is to teach the design of operating sys-tems.

I Topics we will cover include:• Process management• Memory management• File systems• I/O management• Security and privacy

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 3 / 48

Page 5: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Course Textbooks

I Operating System Concepts, 9th EditionAvil Silberschatz et al., Wiley, 2013

I Linux System Programming, 2nd EditionRobert Love, O’Relly Media, 2013

I The Linux Programming InterfaceMichael Kerrisk, No Starch Press, 2010

I Linux Device Drivers, 3rd EditionJonathan Corbet et al., O’Relly Media, 2005

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 4 / 48

Page 6: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Course Textbooks

I Operating System Concepts, 9th EditionAvil Silberschatz et al., Wiley, 2013

I Linux System Programming, 2nd EditionRobert Love, O’Relly Media, 2013

I The Linux Programming InterfaceMichael Kerrisk, No Starch Press, 2010

I Linux Device Drivers, 3rd EditionJonathan Corbet et al., O’Relly Media, 2005

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 4 / 48

Page 7: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Course Examination

I Mid term exam: 30%

I Final exam: 30%

I Lab assignments: 40%• Seven programming assignments in C• Students will work in groups of three

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 5 / 48

Page 8: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Course Web Site

I You can find all the course information on the course web page:http://www.sics.se/∼amir/os14.htm

I Use the course discussion forum if you have any questions.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 6 / 48

Page 9: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

What is an Operating System?

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 7 / 48

Page 10: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

What is an Operating System?

I A program that acts as an intermediary between a user of a computerand the computer hardware.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 8 / 48

Page 11: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

What is an Operating System?

I A program that acts as an intermediary between a user of a computerand the computer hardware.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 8 / 48

Page 12: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

What is an Operating System?

I A program that acts as an intermediary between a user of a computerand the computer hardware.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 8 / 48

Page 13: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Operating System Goals

I Execute user programs and make solving user problems easier.

I Make the computer system convenient to use.

I Use the computer hardware in an efficient manner.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 9 / 48

Page 14: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Operating System Goals

I Execute user programs and make solving user problems easier.

I Make the computer system convenient to use.

I Use the computer hardware in an efficient manner.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 9 / 48

Page 15: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Operating System Goals

I Execute user programs and make solving user problems easier.

I Make the computer system convenient to use.

I Use the computer hardware in an efficient manner.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 9 / 48

Page 16: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

What Operating Systems Do

I OS is a resource allocator• Manages all resources.• Decides between conflicting requests for efficient and fair resource

use.

I OS is a program controller• Controls execution of programs to prevent errors and improper use

of the computer.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 10 / 48

Page 17: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

What Operating Systems Do

I OS is a resource allocator• Manages all resources.• Decides between conflicting requests for efficient and fair resource

use.

I OS is a program controller• Controls execution of programs to prevent errors and improper use

of the computer.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 10 / 48

Page 18: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Operating Systems Definition

I No universally accepted definition.

I The operating system is the one program running at all times onthe computer, usually called the kernel.

I Everything else is either a system program or an application program.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 11 / 48

Page 19: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Operating Systems Definition

I No universally accepted definition.

I The operating system is the one program running at all times onthe computer, usually called the kernel.

I Everything else is either a system program or an application program.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 11 / 48

Page 20: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Operating Systems Definition

I No universally accepted definition.

I The operating system is the one program running at all times onthe computer, usually called the kernel.

I Everything else is either a system program or an application program.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 11 / 48

Page 21: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Four Components of a Computer System (1/4)

I Hardware• Provides basic computing resources.• CPU, memory, I/O devices, ...

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 12 / 48

Page 22: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Four Components of a Computer System (2/4)

I Operating system• Controls and coordinates use of hardware among various

applications and users.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 13 / 48

Page 23: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Four Components of a Computer System (3/4)

I Application programs• Compilers, web browsers, database systems, video games, ...

I System programs• File manipulation, program loading and execution, ...

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 14 / 48

Page 24: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Four Components of a Computer System (4/4)

I Users• People, machines, other computers

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 15 / 48

Page 25: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Operating Systems

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 16 / 48

Page 26: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

A Brief History ofOperating Systems

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 17 / 48

Page 27: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

First Generation: 1945-1955 (1/3)

I No operating system

I Vacuum tubes and plugboards

ENIAC (Electronic Numerical Integrator And Computer): the first electronic general-purpose computer.[http://en.wikipedia.org/wiki/ENIAC]

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 18 / 48

Page 28: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

First Generation: 1945-1955 (2/3)

I Human was the operator and programmer.

I Computer were programmed by physically re-wiring it; later, throughstored programs (von Neumann architecture).

I Programs written in machine or assembly language.

John von Neumann[http://ysfine.com/wigner/neumann.html]

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 19 / 48

Page 29: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

First Generation: 1945-1955 (2/3)

I Human was the operator and programmer.

I Computer were programmed by physically re-wiring it; later, throughstored programs (von Neumann architecture).

I Programs written in machine or assembly language.

John von Neumann[http://ysfine.com/wigner/neumann.html]

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 19 / 48

Page 30: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

First Generation: 1945-1955 (2/3)

I Human was the operator and programmer.

I Computer were programmed by physically re-wiring it; later, throughstored programs (von Neumann architecture).

I Programs written in machine or assembly language.

John von Neumann[http://ysfine.com/wigner/neumann.html]

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 19 / 48

Page 31: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

First Generation: 1945-1955 (3/3)

I Problems:

• Serial processing: users had access to the computer one by one inseries.

• Users have to write again and again the same routines.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 20 / 48

Page 32: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Second Generation: 1955-1965 (1/5)

I Transistors

I Mainframes

IBM 7094 at Columbia University[http://www.columbia.edu/cu/computinghistory/1965.html]

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 21 / 48

Page 33: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Second Generation: 1955-1965 (2/5)

I Separation between operators and programmers.• The programmer: prepares her/his job off-line.• The operator: runs the job and delivers a printed output.

I Job• A program or set of programs• A programmer would first write the program on paper (in

FORTRAN or assembly), then punch it on cards.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 22 / 48

Page 34: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Second Generation: 1955-1965 (2/5)

I Separation between operators and programmers.• The programmer: prepares her/his job off-line.• The operator: runs the job and delivers a printed output.

I Job• A program or set of programs• A programmer would first write the program on paper (in

FORTRAN or assembly), then punch it on cards.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 22 / 48

Page 35: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Second Generation: 1955-1965 (3/5)

I Batch the jobs together.

I The operator pre-reads jobs onto a magnetic tape.

I The operator loads a special program (monitor) that reads the jobsfrom the tape and run them sequentially.

I The monitor program writes the output of each job on a secondmagnetic tape.

I The operator brings the full output tape for offline printing.

[A.S. Tanenbaum et al., Operating Systems Design and Implementation, 2006]

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 23 / 48

Page 36: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Second Generation: 1955-1965 (3/5)

I Batch the jobs together.

I The operator pre-reads jobs onto a magnetic tape.

I The operator loads a special program (monitor) that reads the jobsfrom the tape and run them sequentially.

I The monitor program writes the output of each job on a secondmagnetic tape.

I The operator brings the full output tape for offline printing.

[A.S. Tanenbaum et al., Operating Systems Design and Implementation, 2006]

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 23 / 48

Page 37: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Second Generation: 1955-1965 (3/5)

I Batch the jobs together.

I The operator pre-reads jobs onto a magnetic tape.

I The operator loads a special program (monitor) that reads the jobsfrom the tape and run them sequentially.

I The monitor program writes the output of each job on a secondmagnetic tape.

I The operator brings the full output tape for offline printing.

[A.S. Tanenbaum et al., Operating Systems Design and Implementation, 2006]

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 23 / 48

Page 38: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Second Generation: 1955-1965 (3/5)

I Batch the jobs together.

I The operator pre-reads jobs onto a magnetic tape.

I The operator loads a special program (monitor) that reads the jobsfrom the tape and run them sequentially.

I The monitor program writes the output of each job on a secondmagnetic tape.

I The operator brings the full output tape for offline printing.

[A.S. Tanenbaum et al., Operating Systems Design and Implementation, 2006]

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 23 / 48

Page 39: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Second Generation: 1955-1965 (3/5)

I Batch the jobs together.

I The operator pre-reads jobs onto a magnetic tape.

I The operator loads a special program (monitor) that reads the jobsfrom the tape and run them sequentially.

I The monitor program writes the output of each job on a secondmagnetic tape.

I The operator brings the full output tape for offline printing.

[A.S. Tanenbaum et al., Operating Systems Design and Implementation, 2006]

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 23 / 48

Page 40: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Second Generation: 1955-1965 (4/5)

I Monitor

• It is the ancestor of modern O/S.

• A special program that controls the sequence of events.

• Always resides in main memory.

• Reads in jobs one at a time, places a job in the user program area ofthe memory, and passes control to it.

• Upon completion, the user program branches back to the monitor,which immediately loads and executes the next job

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 24 / 48

Page 41: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Second Generation: 1955-1965 (4/5)

I Monitor

• It is the ancestor of modern O/S.

• A special program that controls the sequence of events.

• Always resides in main memory.

• Reads in jobs one at a time, places a job in the user program area ofthe memory, and passes control to it.

• Upon completion, the user program branches back to the monitor,which immediately loads and executes the next job

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 24 / 48

Page 42: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Second Generation: 1955-1965 (4/5)

I Monitor

• It is the ancestor of modern O/S.

• A special program that controls the sequence of events.

• Always resides in main memory.

• Reads in jobs one at a time, places a job in the user program area ofthe memory, and passes control to it.

• Upon completion, the user program branches back to the monitor,which immediately loads and executes the next job

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 24 / 48

Page 43: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Second Generation: 1955-1965 (4/5)

I Monitor

• It is the ancestor of modern O/S.

• A special program that controls the sequence of events.

• Always resides in main memory.

• Reads in jobs one at a time, places a job in the user program area ofthe memory, and passes control to it.

• Upon completion, the user program branches back to the monitor,which immediately loads and executes the next job

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 24 / 48

Page 44: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Second Generation: 1955-1965 (4/5)

I Monitor

• It is the ancestor of modern O/S.

• A special program that controls the sequence of events.

• Always resides in main memory.

• Reads in jobs one at a time, places a job in the user program area ofthe memory, and passes control to it.

• Upon completion, the user program branches back to the monitor,which immediately loads and executes the next job

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 24 / 48

Page 45: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Second Generation: 1955-1965 (5/5)

I Problems:

• A lot of CPU time is still wasted waiting for I/O instructions tocomplete.

• I/O devices much slower than processor.

[W. Stallings, Operating Systems: Internals and Design Principles, 2011]

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 25 / 48

Page 46: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Third Generation: 1965-1980 (1/5)

I Integrated Circuits (ICs)

IBM 360[http://www.computermuseum.li/Testpage/IBM-360-1964.htm]

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 26 / 48

Page 47: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Third Generation: 1965-1980 (2/5)

I Multiprogrammed batch systems.

I Load two jobs in memory: while one job is waiting for I/O, theprocessor could switch to the other job.

[W. Stallings, Operating Systems: Internals and Design Principles, 2011]

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 27 / 48

Page 48: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Third Generation: 1965-1980 (3/5)

I Expand to three, four or more jobs.

I Jobs are kept in main memory at the same time and the CPU ismultiplexed among them or multiprogrammed.

[W. Stallings, Operating Systems: Internals and Design Principles, 2011]

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 28 / 48

Page 49: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Third Generation: 1965-1980 (4/5)

I Multiprogramming alone does not give any guarantee that a programwill run in a timely manner.

I Tasks kept running until they performed an operation that requiredwaiting for an external event such as I/O.

I But, in a multiple-user system, users want to see their programrunning as if it was the only program in the computer.

I Solution? time-sharing or preemptive multitasking systems.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 29 / 48

Page 50: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Third Generation: 1965-1980 (4/5)

I Multiprogramming alone does not give any guarantee that a programwill run in a timely manner.

I Tasks kept running until they performed an operation that requiredwaiting for an external event such as I/O.

I But, in a multiple-user system, users want to see their programrunning as if it was the only program in the computer.

I Solution? time-sharing or preemptive multitasking systems.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 29 / 48

Page 51: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Third Generation: 1965-1980 (4/5)

I Multiprogramming alone does not give any guarantee that a programwill run in a timely manner.

I Tasks kept running until they performed an operation that requiredwaiting for an external event such as I/O.

I But, in a multiple-user system, users want to see their programrunning as if it was the only program in the computer.

I Solution? time-sharing or preemptive multitasking systems.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 29 / 48

Page 52: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Third Generation: 1965-1980 (4/5)

I Multiprogramming alone does not give any guarantee that a programwill run in a timely manner.

I Tasks kept running until they performed an operation that requiredwaiting for an external event such as I/O.

I But, in a multiple-user system, users want to see their programrunning as if it was the only program in the computer.

I Solution? time-sharing or preemptive multitasking systems.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 29 / 48

Page 53: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Third Generation: 1965-1980 (5/5)

I Time-sharing• A logical extension of multiprogramming for handling multiple

interactive jobs among multiple users.• Hardware timer interrupt: switching jobs.

I Birth of UNIX: CTSS → MULTICS → UNIX

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 30 / 48

Page 54: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Third Generation: 1965-1980 (5/5)

I Time-sharing• A logical extension of multiprogramming for handling multiple

interactive jobs among multiple users.• Hardware timer interrupt: switching jobs.

I Birth of UNIX: CTSS → MULTICS → UNIX

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 30 / 48

Page 55: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Fourth Generation: 1980-Present (1/3)

I Personal Computers (PCs)

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 31 / 48

Page 56: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Fourth Generation: 1980-Present (2/3)

I From multiple users back to a single user.

I Multitasking a central feature of modern PC operating systems.

I PC systems emphasize user convenience.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 32 / 48

Page 57: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Fourth Generation: 1980-Present (3/3)

I GNU (GNU’s Not Unix!): 1983

I Mac OS: 1984

I Microsoft Windows: 1985

I Linux: 1991

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 33 / 48

Page 58: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

GNU/Linux (1/4)

I In 1971 Richard Matthew Stallman (RMS) joined MIT.

I At that time, all the programmers used to share their code freely.

I In 1980, software companies refused to share the code (copyright).

I In 1985, in response, Stallman, founded the Free Software Founda-tion (FSF) and published the GNU manifesto.

• Outlined his motivation for creating a free OS (GNU), which wouldbe compatible with Unix.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 34 / 48

Page 59: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

GNU/Linux (1/4)

I In 1971 Richard Matthew Stallman (RMS) joined MIT.

I At that time, all the programmers used to share their code freely.

I In 1980, software companies refused to share the code (copyright).

I In 1985, in response, Stallman, founded the Free Software Founda-tion (FSF) and published the GNU manifesto.

• Outlined his motivation for creating a free OS (GNU), which wouldbe compatible with Unix.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 34 / 48

Page 60: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

GNU/Linux (1/4)

I In 1971 Richard Matthew Stallman (RMS) joined MIT.

I At that time, all the programmers used to share their code freely.

I In 1980, software companies refused to share the code (copyright).

I In 1985, in response, Stallman, founded the Free Software Founda-tion (FSF) and published the GNU manifesto.

• Outlined his motivation for creating a free OS (GNU), which wouldbe compatible with Unix.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 34 / 48

Page 61: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

GNU/Linux (1/4)

I In 1971 Richard Matthew Stallman (RMS) joined MIT.

I At that time, all the programmers used to share their code freely.

I In 1980, software companies refused to share the code (copyright).

I In 1985, in response, Stallman, founded the Free Software Founda-tion (FSF) and published the GNU manifesto.

• Outlined his motivation for creating a free OS (GNU), which wouldbe compatible with Unix.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 34 / 48

Page 62: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

GNU/Linux (2/4)

I In 1989, Stallman released the first program independent GNU Gen-eral Public License (GPL) or copyleft.

I Now the only thing that GNU lacked was a completely free OSkernel: GNU Hurd kernel

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 35 / 48

Page 63: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

GNU/Linux (3/4)

I In 1985, Andy Tanenbaum wrote a Unix like OS from scratch, calledMinix.

I He implemented it for educational purposes.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 36 / 48

Page 64: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

GNU/Linux (4/4)

I In 1990, Linus Torvalds wanted to improve Minix.

I But he was prohibited by Tanenbaum to do so.

I So, Linus implemented his own kernel and released it under GPL:Linux kernel

I Linux, is then, used as the kernel of the GNU in many distributions.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 37 / 48

Page 65: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

GNU/Linux (4/4)

I In 1990, Linus Torvalds wanted to improve Minix.

I But he was prohibited by Tanenbaum to do so.

I So, Linus implemented his own kernel and released it under GPL:Linux kernel

I Linux, is then, used as the kernel of the GNU in many distributions.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 37 / 48

Page 66: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

GNU/Linux (4/4)

I In 1990, Linus Torvalds wanted to improve Minix.

I But he was prohibited by Tanenbaum to do so.

I So, Linus implemented his own kernel and released it under GPL:Linux kernel

I Linux, is then, used as the kernel of the GNU in many distributions.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 37 / 48

Page 67: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

GNU/Linux (4/4)

I In 1990, Linus Torvalds wanted to improve Minix.

I But he was prohibited by Tanenbaum to do so.

I So, Linus implemented his own kernel and released it under GPL:Linux kernel

I Linux, is then, used as the kernel of the GNU in many distributions.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 37 / 48

Page 68: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Computer System Organization

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 38 / 48

Page 69: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Computer-System Operation

I One or more CPUs, and device controllers connect through commonbus providing access to shared memory.

I The CPU and the device controllers can execute in parallel, com-peting for memory cycles.

I Device controllers inform CPU that it is finished with the operationby causing an interrupt.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 39 / 48

Page 70: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Computer-System Operation

I One or more CPUs, and device controllers connect through commonbus providing access to shared memory.

I The CPU and the device controllers can execute in parallel, com-peting for memory cycles.

I Device controllers inform CPU that it is finished with the operationby causing an interrupt.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 39 / 48

Page 71: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Computer-System Operation

I One or more CPUs, and device controllers connect through commonbus providing access to shared memory.

I The CPU and the device controllers can execute in parallel, com-peting for memory cycles.

I Device controllers inform CPU that it is finished with the operationby causing an interrupt.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 39 / 48

Page 72: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Interrupt (1/3)

I Hardware may trigger an interrupt at any time by sending a signalto the CPU.

I Software may trigger an interrupt by executing a special operationcalled a system call.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 40 / 48

Page 73: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Interrupt (1/3)

I Hardware may trigger an interrupt at any time by sending a signalto the CPU.

I Software may trigger an interrupt by executing a special operationcalled a system call.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 40 / 48

Page 74: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Interrupt (2/3)

I When the CPU is interrupted, it stops what it is doing and imme-diately transfers execution to an address where the service routinefor the interrupt is located.

I The CPU resumes the interrupted computation, when the interruptservice routine completes.

I The OS preserves the state of the CPU by storing registers and theprogram counter.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 41 / 48

Page 75: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Interrupt (2/3)

I When the CPU is interrupted, it stops what it is doing and imme-diately transfers execution to an address where the service routinefor the interrupt is located.

I The CPU resumes the interrupted computation, when the interruptservice routine completes.

I The OS preserves the state of the CPU by storing registers and theprogram counter.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 41 / 48

Page 76: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Interrupt (2/3)

I When the CPU is interrupted, it stops what it is doing and imme-diately transfers execution to an address where the service routinefor the interrupt is located.

I The CPU resumes the interrupted computation, when the interruptservice routine completes.

I The OS preserves the state of the CPU by storing registers and theprogram counter.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 41 / 48

Page 77: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Interrupt (3/3)

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 42 / 48

Page 78: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Storage Structure (1/2)

I Main memory (RAM)• The CPU can load instructions only from memory.• Typically volatile

I Secondary storage• Extension of main memory that provides large nonvolatile storage

capacity.• E.g., magnetic disk and SSD

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 43 / 48

Page 79: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Storage Structure (1/2)

I Main memory (RAM)• The CPU can load instructions only from memory.• Typically volatile

I Secondary storage• Extension of main memory that provides large nonvolatile storage

capacity.• E.g., magnetic disk and SSD

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 43 / 48

Page 80: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Storage Structure (2/2)

I Magnetic disks• Disk surface is logically divided into tracks, which are subdivided

into sectors.

I Solid-state disks (SSD)• Faster than hard disks, nonvolatile.• Becoming more popular.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 44 / 48

Page 81: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Storage Structure (2/2)

I Magnetic disks• Disk surface is logically divided into tracks, which are subdivided

into sectors.

I Solid-state disks (SSD)• Faster than hard disks, nonvolatile.• Becoming more popular.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 44 / 48

Page 82: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Storage Hierarchy - Cost vs. Speed

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 45 / 48

Page 83: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Summary

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 46 / 48

Page 84: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Summary

I OS history• First generation: no OS• Second generation: mainframes, batch programming• Third generation: multiprogramming, multitasking• Fourth generation: PCs

I Computer-system organization• I/O devices• Interrupt• Storage

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 47 / 48

Page 85: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Summary

I OS history• First generation: no OS• Second generation: mainframes, batch programming• Third generation: multiprogramming, multitasking• Fourth generation: PCs

I Computer-system organization• I/O devices• Interrupt• Storage

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 47 / 48

Page 86: Introduction to Operating Systems (Part I) · Introduction to Operating Systems (Part I) Amir H. Payberah amir@sics.se Amirkabir University of Technology (Tehran Polytechnic) Amir

Questions?

Acknowledgements

Some slides were derived from Avi Silberschatz slides.

Amir H. Payberah (Tehran Polytechnic) Introduction 1393/6/22 48 / 48