* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Operating Systems CIS 250
Survey
Document related concepts
Transcript
CIS250 OPERATING SYSTEMS Ch 1 – notes/review Ch 2 Ch 3 Chapter 1 -Time-Sharing/MultiTasking System • Jobs switch so quickly, user may interact • On-Line between user, system, keyboard and CRT; TSO • Short response time, more complex • Jobs are swapped in and out of memory • Virtual Memory - job executes without being completely in memory; programs can be larger than physical memory Chapter 1 – life after mainframes: Personal Computers Introduced • Single Processor - IBM DOS • Multi-processors – many CPUs sharing the same bus and clock; tightly coupled; increased throughput, overhead. – Saved money, increased reliability – Graceful degradation - one CPU failure doesn’t stop the systemic Chapter 1 - Review What is an Operating system? What is a kernel? Describe the evolution of computers. What types of systems are there? Chapter Two Computer System Structures Objectives • Describe a computer system operation • List and define the types of system structures • Discuss hardware protection • Review the general system architecture A computer system consists of... • A CPU and Device controllers – execute concurrently (not simultaneously) – compete for memory cycles – each device controller controls specific device (audio, drives, video) • CPU and Device controllers are connected by a system bus • Memory Controller synchronizes access to Memory When we turn on the computer... • Bootstrap program locates the operating system kernel and loads it into memory • CPU registers, device controllers, and memory are initialized • Operating system waits for an interrupt – hardware interrupt gives a signal to the CPU – software interrupt is triggered by a system call For example • • • • Power up bootstrap is loaded into memory O/S runs the init A request for I/O causes an interrupt in the form of a signal • CPU stops and transfers execution to a fixed location which contains the starting address of the appropriate service routine • Control passed back to CPU upon completion Interrupts • To handle quickly, may use a table of pointers – Stored in low memory; routine called via the table - Contains address of service routine – also known as array or interrupt vector • Interrupted process must have its address saved on a system stack (so that it knows where to resume processing) – address is loaded onto the program counter Array/Interrupt Vector Example • O/S - running process with address FFF0D • I/O requests to read; produces interrupt • O/S saves the address of process on the system stack; disables other interrupts; gets the address of the I/O service from the vector; service routine is run • Get FFF0D from stack; return to program counter; enable other interrupts Operating Systems Architecture Definitions • Array/Interrupt Vector - a table of pointers stored in low memory – purpose: handle interrupts quickly – bootstrap initializes at startup • I/O Structure - controller can have multiple devices attached to it – device controller moves data between peripheral devices and local buffer storage Operating Systems Architecture Definitions • I/O Interrupts - CPU loads registers within the device controller • The device controller examines the register content to determine what to do: – read, – transfer data to buffer, – when complete, interrupts CPU Operating Systems Architecture Definitions • Interrupt Methods – Asynchronous - return control to the user before I/O is complete • more efficient: while doing I/O, CPU can process or schedule I/O • uses device status table to keep track of I/O requests – Synchronous - I/O started at completion • only one request at a time • less overhead Synchronous: Waiting for I/O completion • Only one I/O request is pending – allows O/S to know exactly which I/O device • Can be accomplished: – wait instruction - CPU is idle until the next interrupt – Wait loop - waits in a loop until next interrupt • generates instruction fetches • can tie up memory Asynchronous: Device Status Table • Used when control is passed back to the user program before I/O is complete • Still requires wait logic - done through a system call to the operating system • Table contains status of all I/O devices Process – – – – – – – – – Type a character at the keyboard Causes an interrupt to the CPU Wait until the process is finished Saves address, calls service routine Service routine saves the contents of the CPU registers Stores characters in the buffer Pointer, counter adjusted Data is processed Restore registers, interrupted instruction gains control High-Speed I/O Devices • When you are entering a series of characters at the keyboard, each character is stored contiguously in a buffer • Asynchronous I/O is assigned a low priority and interrupted often • High speed I/O devices can process as quickly as memory - too many interrupts make inefficient usage of the CPU DMA- Direct Memory Access – – – – O/S finds an empty buffer DMA controller takes over the I/O operation CPU performs other tasks DMA controller interrupts the CPU on completion • Little process execution time • For high speed I/O devices Memory • Main memory - temporary, volatile – RAM/DRAM – I/O controller has registers which hold commands/data (IBM PCs and MAC) – have memory mapped I/O - addresses physically mapped to device registers DEVICE= [video controllers] • Secondary Storage - magnetic disk, tape – storage area for programs, data Cache • Even faster than main memory • More expensive • Copy can be in main memory and then cache (after it is used) • Cache management - keep copies in sync Cache Management • Should be designed so that 80-90% of all access is in cache • Single Process - not an issue • Multitasking Environment - CPU is switched between multiple processes - must ensure that each process accessing something has the correct copy Cache Management • Distributive/Multitasking - CPU is switched between processes – if multiprocessor accesses a counter, make sure increment counter is in all caches – handled by the hardware, below the O/S • Known as cache coherency Hardware Protection • Multi-users, tasking and processors has made this a challenge • Sharing resources has made this harder to do - an error by one program may affect other processes Hardware Protection • Time-sharing, Auto Job sequencing infinite loop could affect several programs/files • DOS, Multi-programming - program can change program/data of another program • Hardware error - trap - uses interrupt vector Protection Types • Dual mode operation – user mode – monitor mode - when there is a trap, O/S switches to this mode; has privileged instructions – Requires a mode bit: NT and OS/2 have – DOS does not • I/O Protection - all I/O instructions are privileged Protection • Memory Protection – user can’t touch interrupt vector or service routines - based on base/range addressing • CPU Protection - prevent a program from “hogging” the system – via a timer/time slice Trap • Since I/O is privileged, user program must ask monitor to do I/O – done via a system call – usually done as a trap to a specific location in the interrupt vector – hardware treats a trap as a software interrupt, checks if a valid request, sets mode bit to monitor mode – resets to user mode when complete HCL • Hardware Compatibility List – List of all hardware know to work properly with WIN2K • can obtain on install CD, documentation with software OR download from web: – www.microsoft.com/hwtest/hcl • newer machines - not an issue; older adapters (8bit) are an issue • MS will not support hardware that is not on the list Windows 2000 Boot • BIOS checks hardware and loads O/S – checks either floppy (boot sector) or hard drive (master boot record) for instructions on location of O/S • In WIN2K, BIOS calls boot loader (NTLDR) and it loads OS Boot Sequence • NTLDR reads the BOOT.INI file (contains WIN menu and instructions on the kernel location) • User selects a menu item; NTDETECT.COM program loads – detects hw, tells NTLDR • NTLDR loads NTOSKRNL (kernel) and passes it info from NTDETECT; kernel loads WIN2K files Network Structure • LAN – Ethernet, FDDI, token-ring – Multiple Oss, links, gateways • WAN – Arpanet was the first (1960s) – Communication processors, routers/switches and router Oss – PPP replaced by PPTP Chapter 3 - OS Structures • Examine an operating system via – System Components – Services provided – User Interfaces and System Calls System Components • • • • • • • • Process Management Main Memory Management Secondary Storage Management I/O System Management File Management Protection Networking Command-Interpreter Process Management • A process is a program in execution • System calls can split a process into subprocesses • Each program requires initialization and resources – CPU, memory – may be given at start of execution or as needed Process • Active entity – program counter keeps track of next instruction • A unit of work in the system – system processes – user processes • Processes execute concurrently by multiplexing the CPU O/S tasks for Process Management • • • • • Create/delete processes Suspend/resume processing Synchronize processes Process communication Handle deadlocks Main Memory Management • Main memory is an array of bytes, each has an addressable location • Place where data and instructions are stored; I/O and CPU access quickly • Efficient to keep many programs in memory • O/S must: – keep track of what is in memory – decide what to load – allocate and deallocate Secondary Storage Management • Back up to main memory (not enough main memory to store everything) – compilers, editors, sorters et. • O/S is responsible for: – managing free space – allocating storage – disk scheduling I/O System Management • Prevent direct access to hardware devices from user programs – specifics are built into the I/O system • Must manage: – buffer-caching – device driver interfaces – hardware device drivers File Management • Files are part of storage devices such as magnetic tape, disk and optical disk • These devices are made up of a physical media and a software driven device driver – files are mapped to the media via the devices • O/S must handle: – – – – creation, deletion of files and directories support for manipulating files, directories mapping files to storage backup and recovery of files, directories Protection • The O/S must ensure that resources are accessed by the appropriate processes – a process must have proper authorization • Examples – memory protection: process within an address space – CPU protection via a time – I/O cannot be performed directly by a user prog Networking • Distributed systems (do not share memory, clock), communicate with each other via a communications network – routing, connection, contention and security must be managed Command-Interpreter System • Command interpreter is a system program which provides the interface between the user and the O/S – DOS, UNIX shell commands • Types of commands: process creation, execution... Operating System Services • makes programming task easier – – – – – Program Execution I/O Operations File-system manipulation Communications Error detection • ensures system efficiency – accounting, resource allocation, protection Operating Systems Services • Must be easy to execute programs and programs should end • O/S must provide a way to do I/O • Must have some type of file-system manipulation - for reading, writing, deletes • Provide a means for process communication - either on the same computer or over a NW • Error detection and correction • Allocate resources • Accounting System Calls • Interface between a process and the O/S • Usually in Assembler or C • Example: copy data from one file to another – need two file names • how is this handles? Prompts, control cards – program opens I/P and creates O/P files – error message handles – loop: read data and write to O/P – error handles (hw failures) – exit loop, close files • Each step is a series of system calls Operating Systems Types of System Calls • • • • • Process and Job Control File Manipulation Device Management Information Maintenance Communication * refer to page 68, Figure 3.2 System Programs • In the hierarchy, between operating system and application programs • Designed to provide an easier environment for program development • User interface to system call programs • More complex programs • Most important system program is the command interpreter - gets and executes next command Command Interpreter • May contain the actual execution code • or it may identify a file and execute (UNIX) – less maintenance: change file containing code, don’t have to change all of your system commands – overhead: must pass parameters to system pgm System Programs: Categories • • • • File manipulation - create, delete, copy Status information - memory, date File modification - text editors Programming-language support - comilers, assemblers, interpreters • Program loading and execution - linkers, loaders • Communications - file transfers, virtual connections, email • System call is the program interface • System program is the user interface System Structure • The way components are interconnected and melded into a kernel • Types of structure – Simple – Layered System Structure • Simple - interfaces and level of functionality are not well separated; limited by hardware – MS-DOS - no dual mode operation – original UNIX - two parts: kernel and system programs System Structure • Layered - broken down into smaller parts; allows for greater control over each part – less efficient (overhead between layers) – modularity - break the O/S into layers on top of one another; each module communicates with the one below it; simplifies debugging – information hiding-system programmers can change lower levels without affecting external interface – layer does not need to know about other layers Layered Approach • Disadvantages – less efficient - traversing multiple layers to accomplish a task – must plan layers carefully - ensure that ALL of the needed resources are layered below • backing store must be below memory, because memory accesses it • should backing store be above or below CPU? Normally above, waits for I/O, but CPU could use it as auxiliary storage Ideal System Structure • Best approach: fewer layers, prohibit direct access to lower level, allow multi-tasking, dual mode Virtual Machine • Uses layered approach • Application program regards everything below it as part of the hardware • O/S creates the illusion of multiple processes, each executing its own processor, each with its own (virtual) memory – other operating systems can be loaded on top of the virtual machine (SUN and DEC have a virtual INTEL machine on top of their proc) Virtual Machine Structure Application Programs - can call system pgms System Programs - can use system calls, hw instructions; treats sys calls and hw as same level Kernel - translates hw instructions to sys calls HW Virtual Machine • Can create virtual card readers and line printers, disks • Difficult to implement – virtual machine sw requires a lot of disk space – virtual machine can only run in monitor mode so you must create a virtual user and virtual monitor mode – need exact duplication of configuration Virtual Machine - dual mode • Virt. Mach sw runs in monitor • Machine runs in user mode • Create a virtual user and monitor mode which run in user mode • When I/O request (sys. Call) transfers from virtual user to virtual monitor • Virt. Monitor changes register contents and pgm cntr to simulate a system call • Privileged I/O instructions is executed IBM VM • Has privileged instructions on virtual machine and all others directly on the hw • Program can execute even though it is not entirely in memory • The CPU is spread across multiple virtual machines • Advantage: Protection. Machines are isolated; good for testing; no security probl. System Design and Generation • Design Goals - safe, fast, reliable, flexible, error-free • Mechanisms - how to do something – timer is a mechanism • Policies - what will be done – time splice is policy • Implementation - which language to use – Assembly is fast; C is more portable – Ideal: memory management and CPU scheduling in Assembly; rest in C SYSGEN • Running the O/S at multiple sites • Can configure specifically for each site – CPU, devices, memory, CPU scheduling algorithm – What CPU will be used? How much memory? Which devices are available? Which O/S?