Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

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 Access): Minimize the involvement of CPU.

2 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.

3 Device-Status Table

4 Storage Hierarchy Storage systems organized in hierarchy. Speed Cost Capacity

5 Storage-Device Hierarchy

6 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.

7 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.

8 Performance of Various Levels of Storage

9 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.

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

11 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.

12 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.

13 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.

14 Protection of I/O Devices All I/O instructions are privileged instructions. Only accessed through system calls.

15 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.

16 Use of A Base and Limit Register

17 Hardware Address Protection

18 CPU (and OS) Protection Keep user from monopolizing CPU. Ensure OS regains control of CPU.

19 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.

20 Privileged Instructions Load base and limit registers?

21 Privileged Instructions Load base and limit registers? Set the system timer?

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

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

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

25 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?

26 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.

27 Transition from User to Kernel Mode

28 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, ….


Download ppt "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."

Similar presentations


Ads by Google