Download presentation
Presentation is loading. Please wait.
Published byIivari Jokinen Modified over 5 years ago
1
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone: Textbook: Operating System Concepts, 7th edition, Silberschatz, Galvin, and Gagne. URL:
2
Components of a Computer System
A computer system consists of hardware system programs application programs
3
System Components Hardware: Physical Devices:
Memory, CPU, I/O devices…. Micro-architecture: Executes machine-level instructions. Hardware or firmware (microcode). Machine language: Hardware and instructions visible to an assembly language program.
4
Components of a Computer System
Operating System: Hides complexity of hardware and provides simplified set of instructions (API, Application Program Interface).
5
Components of a Computer System
System programs: Generally execute in user mode. (Why?) Command interpreter (shell), compilers, editors, …..
6
So What is an Operating System?
It is an extended machine Hides the messy details. Presents user with a virtual machine, easier to use Don’t want to program I/O devices, handle interrupts, etc. It is a resource manager (and scheduler) Each program (process or thread) gets time with the resource E.g., CPU, I/O devices, memory Each program gets space on the resource E.g., Disk space.
7
So What is an Operating System?
Control Program Manages the execution of user applications to prevent errors and improper use of system. Program A should not be able to access memory of an unaffiliated program B. No one user should be able to starve OS and/or other users of system resources (e.g., CPU). No user should be able to trash I/O devices (deliberately or by error).
8
Computer Hardware Review
Monitor Bus Components of a simple personal computer
9
Special registers: Program counter. Stack pointer.
Process Status Word (PSW).
10
CPU and other devices can run concurrently.
When device needs attention, it issues an interrupt. Character transferred from keyboard to system buffer. Disk read/write completed. Page fault. User programs generate interrupts when making system calls. Trap instruction. Generally termed software interrupt.
11
Interrupts Operating systems are interrupt-driven.
Perform action, such as executing a process, then wait until receives an interrupt. Makes developing an operating system a very complex task. When an interrupt is generated the CPU stops what it is doing and execution is transferred to the appropriate interrupt handler. Addresses of interrupt handlers are found in the interrupt vector. Table of addresses Each device has a particular offset within the table.
12
Interrupts The state of the interrupted computation must be saved before interrupt can be processed. This state is restored when the OS returns from the interrupt handler. Termed a context switch.
13
I/O Devices Each type of device has its own controller that accepts and carries out commands from the operating system. Because each controller is different, manufacturer provides device driver for each operating system it supports. OS talks to device driver.
14
I/O Operation Program makes I/O request (e.g., read/write to/from a file). OS loads appropriate control registers. Controller reads registers and determines the operation requested. Starts data transfer from the device to its local buffer. When completed, generates an interrupt. State of currently executing program is saved. Interrupt handled by the device driver. Device driver returns control to the OS. OS restarts suspended program.
15
(a) Steps in starting an I/O device and getting interrupt
(b) (a) Steps in starting an I/O device and getting interrupt (b) How the CPU is interrupted
16
Three I/O Methods Synchronous Asynchronous DMA (Direct Memory Access).
17
Three I/O Methods Synchronous
After I/O starts, control returns to user program only upon I/O completion. Wait instruction idles the CPU until the next interrupt Wait loop (contention for memory access). Generally a bad idea.
18
I/O Methods Asynchronous I/O completion signaled by an interrupt.
After I/O starts, control returns to user program without waiting for I/O completion. I/O completion signaled by an interrupt. More complicated than synchronous I/O.
19
Two of the I/O Methods Synchronous Asynchronous
20
I/O Methods DMA Used for high-speed I/O devices able to transmit information at close to memory speeds. Device controller transfers blocks of data from buffer storage directly to main memory without CPU intervention. Only one interrupt is generated per block, rather than the one interrupt per byte.
21
I/O Methods Asynchronous I/O requires the ability to handle multiple I/O commands concurrently. Uses device status table. Queue waiting requests.
22
Device-Status Table
23
Storage Hierarchy Storage systems organized in hierarchy. Speed Cost
Capacity
24
Storage-Device Hierarchy
25
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.
26
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.
27
Performance of Various Levels of Storage
28
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.
29
Multiprogramming Batch Systems
Problem: CPU and I/O very expensive. Solution: Multiplex CPU between multiple jobs.
30
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.
31
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.
32
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.
33
Protection of I/O Devices
All I/O instructions are privileged instructions. Only accessed through system calls.
34
Memory Protection Memory outside the defined range is protected.
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.
35
Use of A Base and Limit Register
36
Hardware Address Protection
37
CPU (and OS) Protection
Keep user from monopolizing CPU. Ensure OS regains control of CPU.
38
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.
39
Privileged Instructions
Load base and limit registers?
40
Privileged Instructions
Load base and limit registers? Set the system timer?
41
Privileged Instructions
Load base and limit registers? Set the system timer? Read the system clock?
42
Privileged Instructions
Set the system timer? Read the system clock? Load base and limit registers? Open a file?
43
Privileged Instructions
Load base and limit registers? Set the system timer? Read the system clock? Open a file? Compile a program and create executable?
44
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?
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.