What is an Operating System:manages the computer hardware(Definition 0) provides a basis for application programs and acts as an intermediary between the computer user and the computer hardware Goals: Execute user programs and make solving user problems easier.Make the computer system convenient to use. Use the computer hardware in an efficient manner
Computer System Structure
Four Components of Computer System (not operating system):Hardware Contents: the central processing unit (CPU), the memory, and the input/output (I/O) devicesFunction: provides the basic computing resources Operating system Function: controls and coordinates the use of the hardware among the various application programs for the various users. Application programs Contents: word processors, spreadsheets, compilers, and web browsers Function: define the ways in which these resources are
used to solve users' computing problemsUsers People, machines, other computers
Other statements of OS:performs no useful function by itselfprovides an environment within which other programs can do useful work.
Goal of OS
maximize the work (or play) that the user is performing
maximize resource utilization— to assure that all available CPU time, memory, and I/O are used efficiently and that no individual user takes more than her fair share.
compromise between individual usability and resource utilization.
Definition 1: the program most intimately involved with the hardware.
Function (Definition 2 - Resource Allocator):manages resources in a computer system
Resources in a computer system: CPU time, memory space, file-storage space, I/O devices, and so on.decides between conflicting requests for efficient and fair resource use (P26)
Definition 3 - Control Program: A control program manages the execution of user programs
to prevent errors and improper use of the computer
The common functions of controlling and allocating resources are then brought together into one piece of software: the operating system.
Common Definition (Definition 4 - kernel): the operating system is the one program running at all times on the computer
DEVICES <--------I/O-------> local buffers (device controller) <------CPU-------> main memory
InterruptsInterrupt Definition: A Signal from either the hardware or the software to signal the occurrence of an event.
Sending signals to CPU usually by system bus
Triggering system call(namely, monitor call, a special operation)Interrupt Timeline I/O发出请求-空闲到发送-告知CPU数据满-CPU开始处理数据-数据处理完毕-CPU回去处理原来的 I/O request和数据开始传输的时间间隔 I/O设备初始化的过程-从idle转移到transferring初始化的一段时间 CPU接收到done之后转到I/O interrupt processing状态的时间间隔 为刚才执行的程序保存地址（PC-位置, 各个寄存器的值） The interrupt must transfer control to the appropriate interrupt service routine. (应该是I/O-transfer done那里吧) to invoke a generic routine to examine the interrupt information;the routine, in turn, would call the interrupt-specific handler. Interrupt vector Essence: a table of pointers of interrupt routines, and is indexed by a unique device number, given with the interrupt request, to provide the address of the interrupt service routine for the interrupting device. Goal: provide the necessary speed to handle interrupts quicklyReason of speeding up: no intermediate routine neededGenerally, the table of pointers is stored in low memory (the first 100 or so locations).可以理解为一个从发出中断的设备指向对应中断服务程序的向量，通过这个向量，中断可以直接将控制传输给中断服务程序 Common Functions of Interrupts Media: Interrupt transfers control to the interrupt service routine generally, through the interrupt vector, which contains the addresses of all the service routines.Protection: Interrupt architecture must save the address of the interrupted instruction.Non-Synchronous: Incoming interrupts are disabled while another interrupt is being processed to prevent a lost interrupt.Trap: A trap is a software-generated interrupt caused either by an error or a user request.Driving: An operating system is interrupt driven. Interrupt Handling The operating system preserves the state of the CPU by storing registers and the program counter.Determines which type of interrupt has occurred:
Actively sampling the status of an external device by a client program as a synchronous activity. Polling is most often used in terms of input/output (I/O), and is also referred to as polled I/O or software-driven I/O.<wiki>
Vectored interrupt system
In computer science, a vectored interrupt is a processing technique in which the interrupting device directs the processor to the appropriate interrupt service routine. This is in contrast to a polled interrupt system, in which a single interrupt service routine must determine the source of the interrupt by checking all potential interrupt sources, a slow and relatively laborious process.<wiki>Separate segments of code determine what action should be taken for each type of interrupt