Operating Systems
Total Page:16
File Type:pdf, Size:1020Kb
Operating Systems Interface between User & Computer Hardware Applications Programs Utilities Operating System Hardware Utilities Memory Resident File Access & Control Program Creation Memory Resident File Format Structures o Editors Access Management o Compilers Protection Schemes o Debuggers System Access & Control File Manipulation System-Wide Access o File Manipulation Resource Access o File Deletion Error Detection & Response Mechanism Program Execution Error Detection Link-Loaders Error Correction Run-Time Management Response to Unrecoverable Error I/O Device Access & Control Accounting Storage File Format Structures System Usage Collection Access Management System Performance Tuning Protection Schemes Forecasting Enhancement Requirements Billing Users for Usage Resource Manager O/S KernelKernel I/O Controller Printers, Keyboards, I/O Controller Monitors, Portions of Cameras, the O/S Etc. currently in use Computer Main System Memory Portions of Various I/O Application Devices Programs Currently in use Operating System Data Application Programs I/O Controller Storage Processor Processor Data Processor Processor Operation Allocation of Main Memory is made jointly by both the O/S and Memory Management Hardware O/S controls access to I/O devices by Application Programs O/S controls access to and use of files O/S controls access to and use of the processors, i.e., how much time can be allocated to the execution of a particular Application Program Classification of Operating Systems Interactive O/S Keyboard & Monitor Access to O/S Immediate, i.e., Interactive, Communication with the Program during Execution Phase Batch O/S Multiple Programs from a diverse set of Users are batched together and submitted for execution Results are printed for each User Program to be read offline Example: Batch Updating of Bank Account Master Files at the conclusion of a Transaction Period (end of day) Uniprogramming Single Program is loaded into Main Memory Processor concentrates on executing that program to completion Multiprogramming Multiple Programs are loaded into Main Memory Processor executes the programs concurrently, i.e., switches between programs to maximize processor utilization Muiltiprogramming Uniprogramming Interactive Batch O/S O/S Early Systems No Operating Systems Console o Set of Display Lights to indicate the state of the processor o Single Row of Display Lights used to indicate a single command written in binary numbers o Set of Toggle Switches to set the Display Lights for a single command written in binary code Input Device – Card Reader Program Creation o Written on Coding Pads o Transcribed to Hollerith Cards via a Card Punch Machine (cast iron) o Program in Hollerith Card Format read into the Main Memory by the use of a Card Reader o Programs were written to absolute memory locations o Entire program had to loaded into memory o Program could be written to Magnetic Tape by the use of a Tape Drive in write mode o Program could be retrieved from the magnetic tape by the use of a Tape Drive in read mode Program Execution o Initiated by a special “GO” switch on the console o Error condition – program halted; status could be investigated by inspecting registers and main memory o Normal Completion – output to printer or Card Punch Scheduling Sign Up Sheet o Blocks of Time – 15 minutes o waste of processing time – sign up for more time than required o Inefficient use of time – need more time than allotted – forced to stop -- necessitates return at a different time – results in inefficient use of programmers time Later Early Systems Setup Time o Single Program (job) o Loading Compiler o Loading High Level language Source Code o Saving the Object Code after compilation o Loading & Linking Program Object Code and Library Function Object Codes Attaching/Detaching Loading/Unloading Magnetic Tape Drives Magnetic Tape Drives Card Readers Card Readers Serial Processing – users had access to the computer System in Series Software Tools Interrupt Processing o Libraries of Common Functions o Linkers Device Drivers o Loaders o Debuggers Memory Map Job Sequencing o I/O Driver Routines of a Resident Monitor Command Language Simple Batch Operating Systems (Monitors) Interpreter User o does not have direct access to the Computer System User Program Area o submits job to an operator (cards/tape) Operator o batches jobs together sequentially o submits entire batch to monitor for processing Monitor controls the sequence of events Resident Monitor – portion of the Monitor that must always be in the main memory Non-resident Monitor – portion of the Monitor that remains in storage until required o Utilities o Common Functions Resident Monitor determines when to read in a new job Monitor o allocates memory for a new job o reads a new job in from storage o inserts control information at end of job requiring job to restore control to the Monitor o passes control to the new job o at the end of the job, control passes back to the Resident Monitor Monitor prints results of the previous execution for the User Monitor schedules a new job Processor (at a certain point in time) o is executing instructions from a portion of the Monitor residing in Main Memory that cause the next job to be read into Main Memory o encounters a branch instruction that leads the processor to start executing the new job o encounters either an end statement or an error condition causing the processor to fetch its next instruction from specified locations in the Monitor code Control is Passed to a Job Processor is fetching and executing instructions from the user code Control is Returned to the Monitor Processor is fetching and executing instructions from the user code Job Control Language (JCL) o provides control instructions to the monitor o FORTRAN . each instruction and each data item is coded on a separate Hollerith card or record on tape . $JOB -- indicates the beginning of a new job . $FTN -- specifies which FORTRAN compiler should be loaded selected compiler produces object code – object code stored in memory “compile, load & go” operation on tape $LOAD card is required to place code in memory $FTN passes control from Monitor to the FORTRAN compiler Upon termination of the compiler operation, control passes back to the Monitor . if a $LOAD card is detected, the Monitor invokes the loader which loads the object code into the space previously held by the FORTRAN compiler; the Monitor transfers control to the object program . if a $LOAD card is not detected, the Monitor transfers control to the object program Hardware Features (absent from early hardware) o Memory Protection . exclude user programs from writing in the Monitor memory space o Timer . prohibit any single job from executing beyond a specified time limit o Privileged Instructions . instructions provided for use by the Monitor code only . processor encountering a privilege instruction in a user program, passes control to the Monitor, which then executes an error interrupt o Interrupts . ability of the hardware to regain control from an executing program to process an exceptional situation Processor time & memory space are both shared by the Utilization of the system is improved user program & Monitor Multiprogrammed Batch Systems Idle Processor o CPU speed >> I/O device speed o single job available CPU must wait for I/O completion Multitasking o multiple tasks within the same program o processed concurrently Multiprogramming o multiple processes from multiple programs o processed concurrently Multiprogramming/Multitasking o multiple jobs are available for execution, CPU . encounters an I/O operation on current job . switches to alternate job while waiting for I/O completion CPU Job A Job A Job B Job B Job C Job C Job A idle time I/O Unit I/O A I/O B I/O C I/O A I/O B I/O C Hardware Requirements o I/O Interrupt Processing Efficient Batch Processing o Direct Memory Access (DMA) o Memory Management Time-Sharing Systems Direct User Interaction o Transaction Processing – reservation systems with the Executing Process o Multiple Interactive Jobs o O/S interleaves the execution of each user program in a short burst (quantum) of time o N users each user has effective control of a computer with slightly less than the speed of the actual computer (overhead costs of context switching) Scheduling Long-Term Scheduling (infrequent exedcution) o determines which programs are admitted for processing . allocated memory space . allocated process control block (becomes a process) . process control block placed in the Ready Queue batch system PCB held on disk in a disk queue some systems PCB swapped-out to raw disk (no file management system) o considers the degree of multiprogramming & the size of remaining free memory Medium-Term Scheduling o manages degree of multiprocessing o swaps jobs between raw disk memory Short-Term Scheduling (frequent execution) o decides which job to execute next o call the dispatcher, dispatcher executes the context switch between PCBs Time-Sharing System – accepts all users until system is saturated; locks further entry Algorithm for Accepting New Processes – balance CPU bound versus I/O Bound Process States New Ready Running Halt Blocked New – admitted by Long-Term Scheduler, PCB allocated, OS needs to allocate memory, etc Ready – process is waiting access to processor, i.e., PCB is complete Running – process is executing Waiting – process is suspended, waiting for some system resource, e.g., I/O completion Halted – process has terminated, awaiting deallocation Process program code