introductionet.engr.iupui.edu/~dskim/classes/ece408/ln-os-ch01 introduction.pdf · 2. operating...

22
1 Introduction Electrical and Computer Engineering D. S. Kim ([email protected]) ECE/IUPUI RTOS & Apps 2 Outlines n What is an Operating System? n Mainframe Systems n Desktop Systems n Real-Time Systems n Handheld Systems n Computing Environments

Upload: others

Post on 11-Oct-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

1

Introduction

Electrical and Computer EngineeringD. S. Kim ([email protected])

ECE/IUPUI RTOS & Apps 2

Outlines

n What is an Operating System?n Mainframe Systemsn Desktop Systemsn Real-Time Systemsn Handheld Systemsn Computing Environments

Page 2: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

2

ECE/IUPUI RTOS & Apps 3

What is an Operating System?

n A program that acts as an intermediary between a user of a computer and the computer hardware.

n Operating system goals:u Execute user programs and make solving user

problems easier.u Make the computer system convenient to use.

n Use the computer hardware in an efficient manner.

ECE/IUPUI RTOS & Apps 4

Computer System Components

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

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

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

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

Page 3: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

3

ECE/IUPUI RTOS & Apps 5

Abstract View of System Components

ECE/IUPUI RTOS & Apps 6

Operating System Definitions

n Resource allocator – manages and allocates resources.

n Control program – controls the execution of user programs and operations of I/O devices .

n Kernel – the one program running at all times (all else being application programs).

Page 4: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

4

ECE/IUPUI RTOS & Apps 7

Mainframe Systems

n Reduce setup time by batching similar jobsn Automatic job sequencing – automatically

transfers control from one job to another. First rudimentary operating system.

n Resident monitoru initial control in monitor u control transfers to job u when job completes control transfers back

to monitor

ECE/IUPUI RTOS & Apps 8

Memory Layout for a Simple Batch System

Page 5: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

5

ECE/IUPUI RTOS & Apps 9

Multiprogrammed Batch SystemsSeveral jobs are kept in main memory at the same time, and the CPU is multiplexed among them.

ECE/IUPUI RTOS & Apps 10

OS Features Needed for Multiprogramming

n I/O routine supplied by the system.n Memory management – the system must allocate

the memory to several jobs.n CPU scheduling – the system must choose among

several jobs ready to run.n Allocation of devices.

Page 6: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

6

ECE/IUPUI RTOS & Apps 11

Time-Sharing Systems–Interactive Computing

n The CPU is multiplexed among several jobs that are kept in memory and on disk (the CPU is allocated to a job only if the job is in memory).

n A job swapped in and out of memory to the disk.n On-line communication between the user and the

system is provided; when the operating system finishes the execution of one command, it seeks the next “control statement” from the user’s keyboard.

n On-line system must be available for users to access data and code.

ECE/IUPUI RTOS & Apps 12

Desktop Systemsn Personal computers – computer system dedicated

to a single user.n I/O devices – keyboards, mice, display screens,

small printers.n User convenience and responsiveness.n Can adopt technology developed for larger

operating system’ often individuals have sole use of computer and do not need advanced CPU utilization of protection features.

n May run several different types of operating systems (Windows, MacOS, UNIX, Linux)

Page 7: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

7

ECE/IUPUI RTOS & Apps 13

Real-Time Systemsn Often used as a control device in a dedicated

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

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

time.

ECE/IUPUI RTOS & Apps 14

Real-Time Systems (Cont.)n Hard real-time:

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

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

n Soft real-timeu Limited utility in industrial control of roboticsu Useful in applications (multimedia, virtual reality)

requiring advanced operating-system features.

Page 8: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

8

ECE/IUPUI RTOS & Apps 15

Handheld Systemsn Personal Digital Assistants (PDAs)n Cellular telephonesn Issues:

u Limited memoryu Slow processorsu Small display screens.

ECE/IUPUI RTOS & Apps 16

Migration of Operating-System Concepts and Features

Page 9: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

9

ECE/IUPUI RTOS & Apps 17

Embedded Systems

n Electronic device + microprocessorn Goals

u To simplify system designu To provide flexibility

n Typical embedded systems can dou Fix bugs

u Make modificationu Add new featuresu Without re-making the system.

n They are everywhere even though we do not recognize them.u The average household in US in 1999 has 50 embedded-

microprocessors.

ECE/IUPUI RTOS & Apps 18

Examples of Embedded Systems

n Aerospace - Navigation systems, automatic landing systems, space exploration

n Automotive - Fuel injection control, antilock braking system, air bag control

n Children Toys - Nintendos, Sony Playstations, n Communications - Satellites, routers, switches, hubs, firewalls, n Computer Peripherals - Printers, scanners, monitors, modems, hard

disk, CD-ROMn Home - Dishwasher, microwave ovens, VCR, TV, DVD, camera, MP3

players, clock, n Industries – elevator controls, robot control,n Medical – x-rays, MRI, pace makers n Office – Fax, copiers, telephones, PDA, cellular phones

Page 10: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

10

ECE/IUPUI RTOS & Apps 19

Computer-System Architecture

ECE/IUPUI RTOS & Apps 20

Computer-System Operation

n I/O devices and the CPU can execute concurrently.n Each device controller is in charge of a particular device

type.n Each device controller has a local buffer.n CPU moves data from/to main memory to/from local

buffersn I/O is from the device to local buffer of controller.n Device controller informs CPU that it has finished its

operation by causing an interrupt.

Page 11: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

11

ECE/IUPUI RTOS & Apps 21

Common Functions of Interrupts

n Interrupt transfers control to the interrupt service routine generally, through the interrupt vector, which contains the addresses of all the service routines.

n Interrupt architecture must save the address of the interrupted instruction.

n Incoming interrupts are disabled while another interrupt is being processed to prevent a lost interrupt.

n A trap is a software-generated interrupt caused either by an error or a user request.

n An operating system is interrupt driven.

ECE/IUPUI RTOS & Apps 22

Interrupt Handling

n The operating system preserves the state of the CPU by storing registers and the program counter.

n Determines which type of interrupt has occurred:u pollingu vectored interrupt system

n Separate segments of code determine what action should be taken for each type of interrupt

Page 12: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

12

ECE/IUPUI RTOS & Apps 23

Interrupt Time Line For a Single Process Doing Output

ECE/IUPUI RTOS & Apps 24

I/O Structuren After I/O starts, control returns to user program only upon I/O completion.

u Wait instruction idles the CPU until the next interruptu Wait loop (contention for memory access).u At most one I/O request is outstanding at a time, no simultaneous I/O

processing.n After I/O starts, control returns to user program without waiting for I/O

completion.u System call – request to the operating system to allow user to wait for

I/O completion.

u Device-status table contains entry for each I/O device indicating its type, address, and state.

u Operating system indexes into I/O device table to determine device status and to modify table entry to include interrupt.

Page 13: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

13

ECE/IUPUI RTOS & Apps 25

Two I/O Methods

Synchronous Asynchronous

ECE/IUPUI RTOS & Apps 26

Device-Status Table

Page 14: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

14

ECE/IUPUI RTOS & Apps 27

Direct Memory Access Structure

n Used for high-speed I/O devices able to transmit information at close to memory speeds.

n Device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention.

n Only on interrupt is generated per block, rather than the one interrupt per byte.

ECE/IUPUI RTOS & Apps 28

Storage Structure

n Main memory – only large storage media that the CPU can access directly.

n Secondary storage – extension of main memory that provides large nonvolatile storage capacity.

n Magnetic disks – rigid metal or glass platters covered with magnetic recording material u Disk surface is logically divided into tracks, which are

subdivided into sectors.u The disk controller determines the logical interaction

between the device and the computer.

Page 15: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

15

ECE/IUPUI RTOS & Apps 29

Moving-Head Disk Mechanism

ECE/IUPUI RTOS & Apps 30

Storage Hierarchy

n Storage systems organized in hierarchy.u Speedu Costu Volatility

n Caching – copying information into faster storage system; main memory can be viewed as a last cache for secondary storage.

Page 16: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

16

ECE/IUPUI RTOS & Apps 31

Storage-Device Hierarchy

ECE/IUPUI RTOS & Apps 32

Caching

n Use of high-speed memory to hold recently-accessed data.

n Requires a cache management policy.n Caching introduces another level in storage

hierarchy. This requires data that is simultaneously stored in more than one level to be consistent.

Page 17: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

17

ECE/IUPUI RTOS & Apps 33

Migration of A From Disk to Register

ECE/IUPUI RTOS & Apps 34

Hardware Protection

n Dual-Mode Operationn I/O Protectionn Memory Protectionn CPU Protection

Page 18: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

18

ECE/IUPUI RTOS & Apps 35

Dual-Mode Operation

n Sharing system resources requires operating system to ensure that an incorrect program cannot cause other programs to execute incorrectly.

n Provide hardware support to differentiate between at least two modes of operations.1. User mode – execution done on behalf of a user.2. Monitor mode (also kernel mode or system mode) –

execution done on behalf of operating system.

ECE/IUPUI RTOS & Apps 36

Dual-Mode Operation (Cont.)

n Mode bit added to computer hardware to indicate the current mode: monitor (0) or user (1).

n When an interrupt or fault occurs hardware switches to monitor mode.

Privileged instructions can be issued only in monitor mode.

monitor user

Interrupt/fault

set user mode

Page 19: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

19

ECE/IUPUI RTOS & Apps 37

I/O Protection

n All I/O instructions are privileged instructions.n Must ensure that a user program could never gain

control of the computer in monitor mode (I.e., a user program that, as part of its execution, stores a new address in the interrupt vector).

ECE/IUPUI RTOS & Apps 38

Use of A System Call to Perform I/O

Page 20: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

20

ECE/IUPUI RTOS & Apps 39

Memory Protection

n Must provide memory protection at least for the interrupt vector and the interrupt service routines.

n In order to have memory protection, add two registers that determine the range of legal addresses a program may access:u Base register – holds the smallest legal

physical memory address.u Limit register – contains the size of the range

n Memory outside the defined range is protected.

ECE/IUPUI RTOS & Apps 40

Use of A Base and Limit Register

Page 21: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

21

ECE/IUPUI RTOS & Apps 41

Hardware Address Protection

ECE/IUPUI RTOS & Apps 42

Hardware Protection

n When executing in monitor mode, the operating system has unrestricted access to both monitor and user’s memory.

n The load instructions for the base and limitregisters are privileged instructions.

Page 22: Introductionet.engr.iupui.edu/~dskim/Classes/ECE408/ln-os-ch01 Introduction.pdf · 2. Operating system – controls and coordinates the use of the hardware among the various application

22

ECE/IUPUI RTOS & Apps 43

CPU Protection

n Timer – interrupts computer after specified period to ensure operating system maintains control.u Timer is decremented every clock tick.u When timer reaches the value 0, an interrupt

occurs.n Timer commonly used to implement time sharing.n Time also used to compute the current time.n Load-timer is a privileged instruction.