Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书)...

27
Operating Systems ( 操操操 操) Text book: Text book: Dinosaur book Dinosaur book 操操 操操 操操操 操操 操操操 操操 ( ( 操操操 操操操 ) ) Teacher: Teacher: 操操操操操操Zheng Kougen Zheng Kougen Prof. Dr. Mr. … Prof. Dr. Mr. … [email protected] [email protected] [email protected] [email protected] TA TA [email protected] [email protected] “OS Homework” “OS Homework”

Transcript of Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书)...

Page 1: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

Operating Systems ( 操作系统原理 ) Text book: Text book:

Dinosaur book Dinosaur book (恐龙书)(恐龙书) 操作系统概念 操作系统概念 (( 中译本中译本 ))

Teacher: Teacher: 郑扣根(郑扣根( Zheng KougenZheng Kougen )) Prof. Dr. Mr. …Prof. Dr. Mr. … [email protected]@263.net.cn [email protected]@cs.zju.edu.cn

TATA

[email protected]@cs.zju.edu.cn “OS Homework” “OS Homework”

Page 2: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

Operating Systems ( 操作系统原理 ) Refs: Refs:

Kernighan and Pike, The UNIX Programming Kernighan and Pike, The UNIX Programming Environment, Prentice-Hall, 1984.Environment, Prentice-Hall, 1984.

W.R. Stevens, Advanced Programming in the UNIX W.R. Stevens, Advanced Programming in the UNIX Environment, Prentice-Hall, 1992Environment, Prentice-Hall, 1992

W.R. Stevens, UNIX Network Programming I, W.R. Stevens, UNIX Network Programming I, Prentice-Hall, 1997.Prentice-Hall, 1997.

W.R. Stevens, UNIX Network Programming II, W.R. Stevens, UNIX Network Programming II, Prentice-Hall, 1998.Prentice-Hall, 1998.

www.kernel.orgwww.kernel.org

Page 3: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

CHAPTER 1: INTRODUCTION What is an Operating System?What is an Operating System? Mainframe SystemsMainframe Systems Desktop SystemsDesktop Systems Multiprocessor SystemsMultiprocessor Systems Distributed Systems Distributed Systems Clustered SystemClustered System Real -Time SystemsReal -Time Systems Handheld SystemsHandheld Systems Feature MigrationFeature Migration Computing EnvironmentsComputing Environments

Page 4: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

WHAT IS AN OPERATING SYSTEM?

An operating system (An operating system ( 操作系统操作系统 ) ) manages the computer resources, such as CPUs, manages the computer resources, such as CPUs,

Memories, Hard disks, and acts as an intermediaMemories, Hard disks, and acts as an intermediary between the computer hardware and the comry between the computer hardware and the computer user,puter user,

provides the system services to user programs,provides the system services to user programs, provides an environment for executing programprovides an environment for executing program

s.s.

Page 5: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

What Is an Operating System? The components of a computer system

Page 6: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

What Is an Operating System? The components of a computer system

Hardware – provides basic computing resources (CPU, Hardware – provides basic computing resources (CPU, memory, I/O devices).memory, I/O devices).

Operating system – controls and coordinates the use of Operating system – controls and coordinates the use of the hardware among the various application programs the hardware among the various application programs for the various users.for the various users.

Applications programs – define the ways in which the Applications programs – define the ways in which the system resources are used to solve the computing system resources are used to solve the computing problems of the users (compilers, database systems, problems of the users (compilers, database systems, video games, business programs).video games, business programs).

Users (people, machines, other computers).Users (people, machines, other computers).

Page 7: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

What Is an Operating System? User view PC usersPC users (( PCPC 用户): 用户): The OS is designed to mostlThe OS is designed to mostl

y for ease of use, with some attention paid to performay for ease of use, with some attention paid to performance, and none paid to resource utilization. nce, and none paid to resource utilization.

Mainframe or minicomputer users (Mainframe or minicomputer users ( 大型机和小型机大型机和小型机用户用户 )) :: The OS is designed to maximize resource utilThe OS is designed to maximize resource utilization.ization.

Workstation usersWorkstation users (工作站用户): (工作站用户): The OS is desigThe OS is designed to compromise between resource utilization and inned to compromise between resource utilization and individual usability. dividual usability.

Handheld users Handheld users (手持设备用户): (手持设备用户): Mostly for indiMostly for individual usability, but performance per amount of batter lvidual usability, but performance per amount of batter life is important as well. ife is important as well.

Page 8: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

What Is an Operating System? System view An operating system is a resource allocator An operating system is a resource allocator (分配(分配

器)器) An operating system is a control program that manages An operating system is a control program that manages

the execution of user programs to prevent errors and imthe execution of user programs to prevent errors and improper use of the computer. proper use of the computer.

An operating system is to execute user programs and to An operating system is to execute user programs and to make solving user problems easier. make solving user problems easier.

What is part of the OSWhat is part of the OS An OS is anything a vendor ships.An OS is anything a vendor ships. An OS is the kernel An OS is the kernel (内核)(内核) part and all else are apart and all else are a

pplications.pplications.The matter of what constitutes an OS is becoming iThe matter of what constitutes an OS is becoming i

mportant (Microsoft case in 1998)mportant (Microsoft case in 1998)

Page 9: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

What Is an Operating System? System goals

OS goalsConvenience: Make the computer convenient to use. Efficiency: Use the computer hardware in an efficient

manner.

Building an OS is a complex task Designing and implementation Revising and updating Hardware support.

To find out What the OS is and what it does, let us trace the evolution (not revolution) of OS.

Page 10: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

MAINFRAME SYSTEMS ( 大型机系统 )

No OS No OS (无操作系统)(无操作系统)

Batched OSBatched OS (批处理操作系统)(批处理操作系统)

Multiprogrammed OS Multiprogrammed OS (多道程序操作系统)(多道程序操作系统)

Time-sharing OS Time-sharing OS (多时操作系统)(多时操作系统)

Page 11: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

Mainframe Systems: No OS

Designer, Implementer, Operator, User Designer, Implementer, Operator, User Designer, Implementer / Operator, User Designer, Implementer / Operator, User Drawbacks: Drawbacks:

Scheduling time Scheduling time Setup time Setup time slowslow

Page 12: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

Mainframe Systems: Batch OS The OS The OS

was always resident in memorywas always resident in memory automatically transferred control from one job to anautomatically transferred control from one job to an

other. other. Batching: Batching:

Programmers submitted jobs in a job control languaProgrammers submitted jobs in a job control languages (shell, awk, perl)ges (shell, awk, perl)

Operators batched together jobs with similar needs aOperators batched together jobs with similar needs and ran them through the computer as a group.nd ran them through the computer as a group.

Drawbacks: Drawbacks: fast CPU and slow I/O devices.fast CPU and slow I/O devices.

Page 13: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

Mainframe Systems: Multiprogrammed OS

Multiprogrammed OS (vs. uniprogrammed OS)Multiprogrammed OS (vs. uniprogrammed OS) Keeping many jobs in memory (see the next slide)Keeping many jobs in memory (see the next slide) Switching to another job if the CPU is idleSwitching to another job if the CPU is idle As long as at least one job needs to execute, the CPU is As long as at least one job needs to execute, the CPU is

never idle. never idle. Multiprogrammed OSMultiprogrammed OS

Job scheduling for selecting a job to load into memoryJob scheduling for selecting a job to load into memory CPU scheduling for selecting which job to runCPU scheduling for selecting which job to run Memory managementMemory management Protection.Protection.

Drawback: not interactiveDrawback: not interactive

Page 14: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

Mainframe Systems: Multiprogrammed OS

Page 15: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

Mainframe Systems: Time-sharing OS

Memory sharing Memory sharing multiprogrammingmultiprogramming Memory sharing + time sharing Memory sharing + time sharing multiprogramming + i multiprogramming + i

nteraction (or multi-tasking)nteraction (or multi-tasking) The CPU is The CPU is rapidlyrapidly multiplexed among several jobs that a multiplexed among several jobs that a

re kept in memory. (I/O operation is terribly slow!)re kept in memory. (I/O operation is terribly slow!) Time-sharing OSTime-sharing OS

Memory management (virtual memory) and protectionMemory management (virtual memory) and protection File system, disk managementFile system, disk management Process synchronization (Process synchronization ( 同步同步 ) and communication) and communication Deadlock handling Deadlock handling (死锁处理)(死锁处理) ..

Page 16: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

DESKTOP SYSTEMS Personal computers Personal computers

computer system dedicated to a single user.computer system dedicated to a single user. I/O devices – keyboards, mice, display screens, small pI/O devices – keyboards, mice, display screens, small p

rinters.rinters. Individuals have sole use of computer and do not need Individuals have sole use of computer and do not need

advanced CPU utilization of protection features.advanced CPU utilization of protection features. User convenience and responsiveness not maximizing CPUser convenience and responsiveness not maximizing CP

U and peripheral utilizationU and peripheral utilization Can adopt some of the technology developed for larger opCan adopt some of the technology developed for larger op

erating system.erating system. Not much of utilizationNot much of utilization Protection, and so onProtection, and so on

Many possible OSes: (Windows, MacOS, UNIX, Linux)Many possible OSes: (Windows, MacOS, UNIX, Linux)

Page 17: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

PARALLEL AND DISTRIBUTED SYSTEMS Two typesTwo types

Tightly coupled systems Tightly coupled systems (紧耦合系统)(紧耦合系统)Parallel systems or multiprocessor systemsParallel systems or multiprocessor systemsProcessors share memory and a clock; communicProcessors share memory and a clock; communic

ation usually takes place through the shared memation usually takes place through the shared memory.ory.

Loosed coupled systemsLoosed coupled systems (松耦合系统)(松耦合系统)Distributed systems and clustered systemsDistributed systems and clustered systemsEach processor has its own local memory; procesEach processor has its own local memory; proces

sors communicate with one another through variosors communicate with one another through various communications lines, such as high-speed buseus communications lines, such as high-speed buses or telephone lines.s or telephone lines.

Page 18: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

Parallel and distributed systems: Parallel systems Advantages of parallel systems: Advantages of parallel systems:

Increased Increased throughputthroughput Economy of scaleEconomy of scale Increased reliabilityIncreased reliability

graceful degradation (The ability to continue providigraceful degradation (The ability to continue providing service proportional to the level of surviving hardng service proportional to the level of surviving hardware). fail-soft systems (systems designed for gracefware). fail-soft systems (systems designed for graceful degration)ul degration)

Asymmetric multiprocessing Asymmetric multiprocessing (非对称处理)(非对称处理) Master processor schedules and allocated work to slave Master processor schedules and allocated work to slave

processors. processors. Each processor is assigned a specific task; Each processor is assigned a specific task; More common in extremely large systemsMore common in extremely large systems

Page 19: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

Parallel and distributed systems: Parallel systems Symmetric multiprocessing (SMP) Symmetric multiprocessing (SMP) (对称处理)(对称处理)

Each processor runs an identical copy of the operating Each processor runs an identical copy of the operating system.system.

Many processes can run at once without performance Many processes can run at once without performance deterioration.deterioration.

Most modern operating systems support SMPMost modern operating systems support SMP SMP and ASMP may be the result of either hardware anSMP and ASMP may be the result of either hardware an

d softwared software

Page 20: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

Parallel and distributed systems: Distributed systems Advantages of distributed systems.Advantages of distributed systems.

Resources Sharing Resources Sharing Computation speed up – load sharing Computation speed up – load sharing ReliabilityReliability CommunicationsCommunications

Requires networking infrastructure.Requires networking infrastructure. Local area networks (LAN) or Wide area networks Local area networks (LAN) or Wide area networks

(WAN)(WAN) May be either client-server or peer-to-peer systems.May be either client-server or peer-to-peer systems.

Page 21: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

Parallel and distributed systems: Distributed systems

Page 22: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

Parallel and distributed systems: Clustered systems (集群系统) Clustering allows two or more systems to share Clustering allows two or more systems to share

storage.storage. Provides high reliability.Provides high reliability. Asymmetric clusteringAsymmetric clustering: one server runs the application : one server runs the application

while other servers standby.while other servers standby. Symmetric clusteringSymmetric clustering: all : all NN hosts are running the hosts are running the

application.application.

Page 23: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

REAL-TIME SYSTEMS Often used as a control device in a dedicated Often used as a control device in a dedicated

application such as controlling scientific experiments, application such as controlling scientific experiments, medical imaging systems, industrial control systems, medical imaging systems, industrial control systems, and some display systems.and some display systems.

Well-defined fixed-time constraints.Well-defined fixed-time constraints. Real-Time systems may be either Real-Time systems may be either hard hard or or softsoft real- real-

time.time.

Page 24: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

Real-Time SystemsHard real-time:Hard real-time:

Secondary storage limited or absent, data stored in Secondary storage limited or absent, data stored in short term memory, or read-only memory (ROM)short term memory, or read-only memory (ROM)

Conflicts with time-sharing systems, not supported Conflicts with time-sharing systems, not supported by general-purpose operating systems.by general-purpose operating systems.

Soft real-timeSoft real-time Limited utility in industrial control of roboticsLimited utility in industrial control of robotics Useful in applications (multimedia, virtual reality) Useful in applications (multimedia, virtual reality)

requiring advanced operating-system features.requiring advanced operating-system features.

Page 25: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

HANDHELD SYSTEMS Personal Digital Assistants (PDAs) (Personal Digital Assistants (PDAs) ( 个人数字助理个人数字助理 )) Cellular telephonesCellular telephones (手机(手机 ), Pocket PC, …), Pocket PC, … Issues:Issues:

Limited memoryLimited memory Slow processorsSlow processors Small display screens.Small display screens.

Page 26: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

OS FEATURE MIGRATION

Page 27: Operating Systems ( 操作系统原理 ) Text book: Text book: Dinosaur book (恐龙书) 操作系统概念 ( 中译本 ) Teacher: Teacher: 郑扣根( Zheng Kougen ) Prof.

COMPUTING ENVIRONMENTS Traditional computingTraditional computing Web-Based ComputingWeb-Based Computing Embedded ComputingEmbedded Computing