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
Plan 9 from Bell Labs wikipedia , lookup
Security-focused operating system wikipedia , lookup
Copland (operating system) wikipedia , lookup
Burroughs MCP wikipedia , lookup
Spring (operating system) wikipedia , lookup
Distributed operating system wikipedia , lookup
Unix security wikipedia , lookup
Operation Systems Overview Objective Provide a grand tour of the major operating system components and responsibilities Operating System Concepts 1.2 Silberschatz, Galvin and Gagne ©2005 Operating Systems OS: A program that acts as an intermediary between a user of a computer and the computer hardware. No universally accepted definition “Everything a vendor ships when you order an operating system” is good approximation But varies wildly “The one program running at all times on the computer” is the kernel. Everything else is either a system program (ships with the operating system) or an application program Computer system can be divided into four components Hardware – provides basic computing resources Operating system Application programs Users Operating System Concepts 1.3 Silberschatz, Galvin and Gagne ©2005 Four Components of a Computer System Operating System Concepts 1.4 Silberschatz, Galvin and Gagne ©2005 Operating System Definition OS is a resource allocator Manages all resources Decides between conflicting requests for efficient and fair resource use OS is a control program Controls execution of programs to prevent errors and improper use of the computer Operating System Concepts 1.5 Silberschatz, Galvin and Gagne ©2005 Computer System Organization Computer-system operation One or more CPUs, device controllers connect through common bus providing access to shared memory Concurrent execution of CPUs and devices competing for memory cycles Operating System Concepts 1.6 Silberschatz, Galvin and Gagne ©2005 Computer-System Operation Concepts and Terms Each device controller is in charge of a particular device type. Each device controller has a local buffer. CPU moves data from/to main memory to/from local buffers I/O is from the device to local buffer of controller. Device controller informs CPU that it has finished its operation by causing an interrupt. A trap is a software-generated interrupt caused either by an error or a user request. An operating system is interrupt driven. Operating System Concepts 1.7 Silberschatz, Galvin and Gagne ©2005 Storage Structure Main memory – only large storage media that the CPU can access directly. Secondary storage – extension of main memory that provides large nonvolatile storage capacity. Magnetic disks – rigid metal or glass platters covered with magnetic recording material Operating System Concepts 1.8 Silberschatz, Galvin and Gagne ©2005 Storage Hierarchy Storage systems organized in hierarchy. Speed Cost Volatility Caching – copying information into faster storage system; main memory can be viewed as a last cache for secondary storage. Multitasking environments must be careful to use most recent value, no matter where it is stored in the storage hierarchy Multiprocessor environment must provide cache coherency in hardware such that all CPUs have the most recent value in their cache Operating System Concepts 1.9 Silberschatz, Galvin and Gagne ©2005 Operating System Structure Multiprogramming needed for efficiency Timesharing (multitasking) is logical extension in which CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computing Each user has at least one program executing in memory process If several jobs ready to run at the same time CPU scheduling If processes don’t fit in memory, swapping moves them in and out to run Virtual memory allows execution of processes not completely in memory Operating System Concepts 1.10 Silberschatz, Galvin and Gagne ©2005 Operating-System Operations Interrupt driven by hardware Software error or request creates exception or trap Division by zero, request for operating system service Other process problems include infinite loop, processes modifying each other or the operating system Dual-mode operation allows OS to protect itself and other system components User mode and kernel mode Mode bit provided by hardware Provides ability to distinguish when system is running user code or kernel code Some instructions designated as privileged, only executable in kernel mode System call changes mode to kernel, return from call resets it to user Operating System Concepts 1.11 Silberschatz, Galvin and Gagne ©2005 Transition from User to Kernel Mode Timer to prevent infinite loop / process hogging resources Set interrupt after specific period Operating system decrements counter When counter zero generate an interrupt Set up before scheduling process to regain control or terminate program that exceeds allotted time Operating System Concepts 1.12 Silberschatz, Galvin and Gagne ©2005 System Calls Programming interface to the services provided by the OS Typically written in a high-level language (C or C++) Mostly accessed by programs via a high-level Application Program Interface (API) rather than direct system call use Three most common APIs are Win32 API for Windows, POSIX API for POSIX-based systems (including virtually all versions of UNIX, Linux, and Mac OS X), and Java API for the Java virtual machine (JVM) Why use APIs rather than system calls? Operating System Concepts 1.13 Silberschatz, Galvin and Gagne ©2005 Example of System Calls System call sequence to copy the contents of one file to another file Operating System Concepts 1.14 Silberschatz, Galvin and Gagne ©2005 Standard C Library Example C program invoking printf() library call, which calls write() system call Operating System Concepts 1.15 Silberschatz, Galvin and Gagne ©2005 3 Management Actions Process Mgt Memory Mgt Storage Mgt Operating System Concepts 1.16 Silberschatz, Galvin and Gagne ©2005 Process Management A process is a program in execution. It is a unit of work within the system. Program is a passive entity, process is an active entity. Process termination requires reclaim of any reusable resources Operating System Concepts 1.17 Silberschatz, Galvin and Gagne ©2005 Process State As a process executes, it changes state new: The process is being created running: Instructions are being executed waiting: The process is waiting for some event to occur ready: The process is waiting to be assigned to a process terminated: The process has finished execution Operating System Concepts 1.18 Silberschatz, Galvin and Gagne ©2005 CPU Scheduling Basic Concepts Every time a process has to wait, another process can take over use of the CPU Scheduling of the CPU is a fundamental OS function Maximum CPU utilization obtained with multiprogramming CPU–I/O Burst Cycle – Process execution consists of a cycle of CPU execution and I/O wait Operating System Concepts 1.19 Silberschatz, Galvin and Gagne ©2005 Scheduling Criteria CPU utilization – keep the CPU as busy as possible Throughput – # of processes that complete their execution per time unit Turnaround time – amount of time to execute a particular process Waiting time – amount of time a process has been waiting in the ready queue Response time – amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment) McDonalds queue example Operating System Concepts 1.20 Silberschatz, Galvin and Gagne ©2005 Scheduling Algorithms First Come First Serve Shortest Job First Priority Based (SJF is priority based where shortest job gets highest priority) Round Robin (time quantum…if ‘q’ really large->FCFS…if ‘q’ really small too much context switching…swapping with no real progress) Multiple combinations of the above and others Book Store Example Operating System Concepts 1.21 Silberschatz, Galvin and Gagne ©2005 Memory Management All data in memory before and after processing All instructions in memory in order to execute Memory management activities Keeping track of which parts of memory are currently being used and by whom Deciding which processes (or parts thereof) and data to move into and out of memory Allocating and deallocating memory space as needed Operating System Concepts 1.22 Silberschatz, Galvin and Gagne ©2005 Memory Layout for Multiprogrammed System Operating System Concepts 1.23 Silberschatz, Galvin and Gagne ©2005 Allocating Physical Memory Contiguous Allocation Multiple-partition allocation Hole – block of available memory; holes of various size are scattered throughout memory When a process arrives, it is allocated memory from a hole large enough to accommodate it Operating system maintains information about: a) allocated partitions b) free partitions (hole) OS OS OS OS process 5 process 5 process 5 process 5 process 9 process 9 process 8 process 2 Operating System Concepts process 10 process 2 process 2 1.24 process 2 Silberschatz, Galvin and Gagne ©2005 Allocating Physical Memory Paging Model of Logical and Physical Memory Operating System Concepts 1.25 Silberschatz, Galvin and Gagne ©2005 Segmentation Memory-management scheme that supports user view of memory A program is a collection of segments. A segment is a logical unit such as: main program, procedure, function, method, object, local variables, global variables, common block, stack, symbol table, arrays Operating System Concepts 1.26 Silberschatz, Galvin and Gagne ©2005 Example of Segmentation Operating System Concepts 1.27 Silberschatz, Galvin and Gagne ©2005 Virtual Memory Virtual memory – separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution Logical address space can therefore be much larger than physical address space (figure 9.1) Allows address spaces to be shared by several processes Allows for more efficient process creation Virtual memory can be implemented via demand paging Operating System Concepts 1.28 Silberschatz, Galvin and Gagne ©2005 Virtual Memory That is Larger Than Physical Memory Operating System Concepts 1.29 Silberschatz, Galvin and Gagne ©2005 Page Table When Some Pages Are Not in Main Memory Operating System Concepts 1.30 Silberschatz, Galvin and Gagne ©2005 Virtual-address Space Virtual address space of process refers ot the logical (virtual) view of how a process is stored View starts at zero Exists in contiguous memory Allows heap to grow upward as it is used for dynamic memory allocation Allows stack to grow downward through successive function calls Heap: memory dynamically allocated during process run time Stack: contains temporary data such as function parameters, return addresses, local variables Operating System Concepts 1.31 Silberschatz, Galvin and Gagne ©2005 Storage Management OS provides uniform, logical view of information storage Abstracts physical properties to logical storage unit - file File-System management Operating System Concepts 1.32 Silberschatz, Galvin and Gagne ©2005 File Attributes Name – only information kept in human-readable form Identifier – unique tag (number) identifies file within file system Type – needed for systems that support different types Location – pointer to file location on device Size – current file size Protection – controls who can do reading, writing, executing Time, date, and user identification – data for protection, security, and usage monitoring Information about files are kept in the directory structure, which is maintained on the disk Operating System Concepts 1.33 Silberschatz, Galvin and Gagne ©2005 Sequential-access File Operating System Concepts 1.34 Silberschatz, Galvin and Gagne ©2005 Two-Level Directory Separate directory for each user Path name Can have the same file name for different user Efficient searching No grouping capability Operating System Concepts 1.35 Silberschatz, Galvin and Gagne ©2005 Tree-Structured Directories Operating System Concepts 1.36 Silberschatz, Galvin and Gagne ©2005 File System Mounting A file system must be mounted before it can be accessed A unmounted file system (i.e. Fig. 11-11(b)) is mounted at a mount point A discover process is done by OS What (name of device) Where (mount point) Verify valid file system on device Then….Notes in dir structure that a file system mounted at the mount point Enables an OS to traverse its directory structure, switching among files systems as appropriate Operating System Concepts 1.37 Silberschatz, Galvin and Gagne ©2005 (a) Existing. (b) Unmounted Partition Operating System Concepts 1.38 Silberschatz, Galvin and Gagne ©2005 Access Lists and Groups Mode of access: read, write, execute Three classes of users (used to condense ACLs) a) owner access 7 b) group access 6 c) public access 1 RWX 111 RWX 110 RWX 001 Ask manager to create a group (unique name), say G, and add some users to the group. For a particular file (say game) or subdirectory, define an appropriate access. owner chmod group 761 public game Most common approach to protection is make access dependent on identify of user Attach a group to a file chgrp Operating System Concepts G game 1.39 Silberschatz, Galvin and Gagne ©2005 Allocation Methods Secondary Storage An allocation method refers to how disk blocks are allocated for files: Contiguous allocation (similar to allocating physical memory) Linked allocation (via a trail) Indexed allocation (via a block dedicated to be an index) Operating System Concepts 1.40 Silberschatz, Galvin and Gagne ©2005 Free-Space Management Need to reuse space from deleted files, if possible Maintain free-space list to keep track of free space…records all free disk blocks Frequently implemented as a bit vector (n blocks in example) 0 1 2 n-1 bit[i] = Operating System Concepts … 0 block[i] occupied/allocated 1 block[i] free 1.41 Silberschatz, Galvin and Gagne ©2005 End of Lesson