+ All Categories
Home > Documents > Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O...

Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O...

Date post: 31-Dec-2015
Category:
Upload: barbara-brooks
View: 214 times
Download: 0 times
Share this document with a friend
Popular Tags:
28
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory Access): Minimize the involvement of CPU.
Transcript
Page 1: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Recall: Three I/O Methods

Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to

other work. DMA (Direct Memory Access): Minimize the

involvement of CPU.

Page 2: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

I/O Methods

Asynchronous I/O requires the ability to handle multiple I/O commands concurrently.

Uses device status table. Queue waiting requests. Provides opportunity for scheduling of I/O operations.

Page 3: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Device-Status Table

Page 4: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Storage Hierarchy

Storage systems organized in hierarchy. Speed Cost Capacity

Page 5: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Storage-Device Hierarchy

Page 6: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Caching

Idea is to hold heavily used data in the memory cache to avoid going to main memory on each access (up to 500 times faster).

Typical instruction cycle: Fetch instruction from memory Fetch operands from memory Execute instruction.

Many machines have instruction and data caches. On each memory access, the hardware checks

the cache to see if required data is already is there.

Page 7: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Caching

If in cache, use it. If not in cache, retrieve from main memory

and keep copy in the cache. On many machines, main memory is used to

cache frequently used disk blocks. Caching works well when the application

exhibits “locality of reference” i.e., data used in the recent past will be used again in the near future.

Page 8: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Performance of Various Levels of Storage

Page 9: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Operating System Structure

A key concept of operating systems is multiprogramming.

Keep multiple jobs in memory. When one job blocks on I/O, the CPU immediately

switches to another job. This keeps CPU and I/O devices fully utilized. Without multiprogramming, CPU would be idle

during I/O operations. Developed in the 60s when most computers

were batch systems. Several jobs were batched together and executed. No interactions between user and job.

Page 10: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Multiprogramming Batch SystemsProblem: CPU and I/O very expensive.Solution: Multiplex CPU between multiple jobs.

Page 11: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

OS Features Needed for Multiprogramming

Use of disk space to hold jobs not in system.

Job scheduling: Choose jobs to bring into memory.

Memory management – the system must allocate the memory to several jobs.

CPU scheduling – the system must choose among several jobs ready to run.

Allocation of devices.

Page 12: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Time-Sharing Systems–Interactive Computing

Logical extension of multiprogramming. 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).

A job swapped in and out of memory to the disk. 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.

i.e., the shell Goal is to give the illusion that each user has own

machine. Response time is a priority.

Page 13: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Protection of System Resources

I/O Devices Memory CPU Based on different modes of

operation: kernel mode and user mode. Privileged instructions can be issued only in kernel

mode. Mode bit in PSW, checked on every instruction.

Page 14: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Protection of I/O Devices

All I/O instructions are privileged instructions. Only accessed through system calls.

Page 15: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Memory Protection

Must provide memory protection for the interrupt vector, interrupt service routines, and other applications address space.

Two registers that determine the range of legal addresses a program may access: Base register – holds the smallest legal

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

range Memory outside the defined range is

protected.

Page 16: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Use of A Base and Limit Register

Page 17: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Hardware Address Protection

Page 18: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

CPU (and OS) Protection

Keep user from monopolizing CPU. Ensure OS regains control of CPU.

Page 19: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

CPU Protection

Timer – interrupts computer after specified period to ensure operating system maintains control.

Timer is decremented every clock tick. When timer reaches the value 0, an interrupt occurs.

Timer commonly used to implement time sharing.

Page 20: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Privileged Instructions

Load base and limit registers?

Page 21: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Privileged Instructions

Load base and limit registers? Set the system timer?

Page 22: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Privileged Instructions

Load base and limit registers? Set the system timer? Read the system clock?

Page 23: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Privileged Instructions

Set the system timer? Read the system clock? Load base and limit registers? Open a file?

Page 24: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Privileged Instructions

Load base and limit registers? Set the system timer? Read the system clock? Open a file? Compile a program and create executable?

Page 25: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Privileged Instructions

Load base and limit registers? Set the system timer? Read the system clock? Open a file? Compile a program and create executable? Enable/disable interrupts?

Page 26: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

System Calls

Interface between executing program and OS defined by set of system calls OS provides.

System call causes a TRAP to switch from user to kernel mode and starts execution at interrupt vector location for TRAP instruction.

Operating system looks at requested operation and any parameters passed by the application.

Dispatches the correct system call handler through a table of pointers to system call handlers.

Handler completes and (may) return to user code at the next instruction. OS may schedule another process to execute.

Page 27: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Transition from User to Kernel Mode

Page 28: Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.

Interrupts are driven by both hardware and software.

TRAP when requesting OS service through a system call.

Program generated error Divide by zero, illegal address, ….


Recommended