Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
phones off (please) Operating Systems (CSCI2413) Lecture 2 Overview Operating-System Roles • • • • • Resource management Operating System Services System Calls Kernel Virtual Memory © De Montfort University, 2004 CSCI2413 - L2 2 Resource Management • • • • • • • Process Management Memory Management File Management I/O Management Secondary Management Protection Command-Interpreter © De Montfort University, 2004 CSCI2413 - L2 3 User Application Program O.S. Process Management CPU User Interface Memory Management File Management Main Memory I/O Management File Store I/O Devices Hardware Resources © De Montfort University, 2004 CSCI2413 - L2 4 Process Management • A process is a program in execution. • A process requires the CPU time, memory, files, and I/O devices, to accomplish its task. • OS is responsible for: – Process creation and deletion. – process suspension and resumption. – Provision of mechanisms for: • process synchronization • process communication © De Montfort University, 2004 CSCI2413 - L2 5 Memory Management • Memory is a repository of quickly accessible data shared by the CPU and I/O devices. • OS is responsible for: – Keeping track of which parts of memory are currently being used and by whom. – Deciding which processes to load when memory space becomes available. – Allocating and de-allocating memory space as needed. © De Montfort University, 2004 CSCI2413 - L2 6 File Management • A files represent programs (both source and object codes) and data. • OS is responsible for: – – – – – File creation and deletion. Directory creation and deletion. Manipulating files and directories. Mapping files onto secondary storage. File backup on stable (nonvolatile) storage media. © De Montfort University, 2004 CSCI2413 - L2 7 I/O Management • The I/O system consists of: – A buffer-caching system – A general device-driver interface – Drivers for specific hardware devices © De Montfort University, 2004 CSCI2413 - L2 8 Secondary-Storage Management • Generally, disks are used for both programs and data. • OS is responsible for: – Free space management – Storage allocation – Disk scheduling © De Montfort University, 2004 CSCI2413 - L2 9 Protection • A mechanism for controlling access by programs, processes, or users to both system and user resources. • Protection must: – Distinguish between authorised and unauthorised usage – Specify the controls to be imposed. – Provide a means of enforcing the control. © De Montfort University, 2004 CSCI2413 - L2 10 Command Interpreter • Commands are given to the OS by control statements which mainly deal with: – Resource management, as explained above • The program that reads and interprets control statements is variously called: – Command-line-interpreter – Shell (in UNIX). • Its function is to get and execute the next command. © De Montfort University, 2004 CSCI2413 - L2 11 Services • Program Execution – load a program into memory and run it • I/O operations – OS is responsible for performing I/O operations. • File Manipulation – capability to create, read, write, and delete files. • Communications – Exchange of information between processes executing either on the same computer or on a distant computer connected via network. © De Montfort University, 2004 CSCI2413 - L2 12 Services (cont..) • Error detection – detecting errors in the CPU and memory, in I/O devices, or in user program © De Montfort University, 2004 CSCI2413 - L2 13 System Calls • An interface between a running program and the operating system. • In another word, the means by which a process requests a specific kernel service. © De Montfort University, 2004 CSCI2413 - L2 14 User Processes Kernel Response to many system calls from processes Traps and Virtual Interrupts faults memory CPU Main Memory Network Disk, terminal Network interface Hardware Resources © De Montfort University, 2004 CSCI2413 - L2 15 Virtual Memory • Virtual memory enables a computer to appear to have more memory than its real physical memory – the technique is employed by all modern OS’s • All computers have more hard disk space than real physical memory (RAM) – hard disk space is used as ‘imaginary’ RAM • When a process starts, rather than loading the whole program into memory, the supervisor loads instructions and data into RAM in small blocks – these memory blocks are called pages • modern page sizes are typically 2K or 4K bytes © De Montfort University, 2004 CSCI2413 - L2 16 Virtual Memory Illustration hard disk program 3 program 2 program 1 © De Montfort University, 2004 main memory main memory process 3 (page 1) process 3 (page 1) process 2 process 3 (page 2) process 1 process 1 supervisor task supervisor task there is not enough free space in memory for all of program 3 so, initially, only page 1 is loaded in (note process 1 is still writing to hard disk in the background) CSCI2413 - L2 process 3, page 2 is now required, so process 2 has been swapped out to hard disk and the required page has been loaded into memory 17 Swapping • When physical memory (RAM) becomes full the supervisor searches for unused pages – the unused page(s) (instructions or data pages from an inactive process) are copied out to hard disk – the required page is then loaded into RAM • this is called swapping • If a swapped-out page is required again another page is copied out and the needed one copied in – sometimes the OS can spend so much time swapping pages that little or no useful processing is done • this is called disk thrashing © De Montfort University, 2004 CSCI2413 - L2 18 Virtual Machines • The virtual machine concept takes virtual memory one stage further – a real machine simulates a number of virtual machines – each virtual machine has its own operating system (supervisor task) in its own block of virtual memory – all machine interaction (input / output) takes place via an underlying virtual machine controller task • Intel processors have provided hardware support for virtual machines since 486’s – VMWare is a virtual machine program for PC’s – allows e.g. Win 95, Win NT and Linux to run at once © De Montfort University, 2004 CSCI2413 - L2 19 Virtual Machine Illustration main memory user process 3 supervisor task 3 (e.g. Linux) user process 2 supervisor task 2 (e.g. Win NT) user process 1 supervisor task 1 (e.g. Win 95) virtual machine task © De Montfort University, 2004 CSCI2413 - L2 20