670 likes | 699 Views
Operating System Concepts. Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University. Chapter 3 Operating System Structures. An operating system can be viewed from several vantage points. Services
E N D
Operating System Concepts Ku-Yaw Chang canseco@mail.dyu.edu.tw Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University
Chapter 3 Operating System Structures • An operating system can be viewed from several vantage points. • Services • Interfaces to users and programmers • Components and their interconnections Chapter 3 Operating-System Structures
System Components Operating-System Services System Calls System Programs System Structures Virtual Machines System Design and Implementation System Generation Summary Exercises Chapter 3 Operating-System Structures Chapter 3 Operating-System Structures
3.1 System Components • Common system components • Process Management • Main Memory Management • File Management • I/O System Management • Secondary Management • Networking • Protection System • Command-Interpreter System Chapter 3 Operating-System Structures
3.1.1 Process Management • A process • A program in execution • Resources • CPU time • Memory • Files • I/O devices Chapter 3 Operating-System Structures
Process v.s. Program • A program by itself is not a process. • A program is a passive entity • Contents of a file stored on disk • A process is an active entity • A program counter specifies the next instruction to execute • A program spawns many processes as it runs. Chapter 3 Operating-System Structures
Process Management • A computer • Consists of a collection of processes • Operating-system processes • User processes • Be executed concurrently, by multiplexing the CPU among them. • OS is responsible for • Creating and deleting both user and system processes • Suspending and resuming processes • Providing mechanisms for process synchronization • Providing mechanisms for process communication • Providing mechanisms for deadlock handling (Chapters 4 through 7) Chapter 3 Operating-System Structures
3.1.2 Main-Memory Management • Main memory • a large array of words or bytes, each with its own address. • a repository of quickly accessible data shared by the CPU and I/O devices. • a volatile storage device • OS is responsible for • Keeping track of which parts of memory are currently being used and by whom • Deciding which processes are to be loaded into memory when memory space becomes available • Allocating and deallocating memory space as needed (Chapters 9 and 10) Chapter 3 Operating-System Structures
3.1.3 File Management • Physical Media • Magnetic tape • Magnetic disk • Optical disk • OS provides a uniform logical view of information storage – the file • Map files onto physical media • Access files via storage devices • A file • a collection of related information defined by its creator • represent programs (both source and object forms) and data • Directory (or folder) Chapter 3 Operating-System Structures
3.1.3 File Management • OS is responsible for • Creating and deleting files • Creating and deleting directories • Supporting primitives for manipulating files and directories • Mapping files onto secondary storage • Backing up files on stable (nonvolatile) storage media(Chapters 11 and 12) Chapter 3 Operating-System Structures
3.1.4 I/O-System Management • The peculiarities of I/O devices are hidden from the bulk of the operating system itself by the I/O subsystem. • A memory-management component that includes buffering, caching, and spooling • A general device-driver interface • Drivers for specific hardware devices (Chapter 13) Chapter 3 Operating-System Structures
3.1.5 Secondary-Storage Management • Primary storage • Main memory • Secondary storage • Disks • Principal on-line storage medium • Source and destination of processing • OS is responsible for • Free-space management • Storage allocation • Disk scheduling(Chapter 14) Chapter 3 Operating-System Structures
3.1.6 Networking • A distributed system is a collection processors that do not share memory or a clock. • Each processor has its own local memory. • The processors in the system are connected through a communication network. • Communication takes place using a protocol. • A distributed system provides user access to various system resources. Chapter 3 Operating-System Structures
3.1.6 Networking • Access to a shared resource allows • Computation speedup • Increased functionality • Increased data availability • Enhanced reliability • OSs usually generalize network access as a form of file access • Details are contained in the network interface’s device driver(Chapters 15 through 17) Chapter 3 Operating-System Structures
3.1.7 Protection System • Protection • a mechanism for controlling access by programs, processes, or users to both system and user resources. • The protection mechanism must • distinguish between authorized and unauthorized usage • specify the controls to be imposed • provide a means of enforcement(Chapter 18) Chapter 3 Operating-System Structures
3.1.8 Command-Interpreter System • Command Interpreter • Interface between the user and the OS • Included in the kernel or as a special program • Control statements • Commands given to the OS • Shell • Also called control-card interpreter, or the command-line interpreter • To get the next command statement and execute it Chapter 3 Operating-System Structures
3.1.8 Command-Interpreter System • Command statements • process creation and management • I/O handling • secondary-storage management • main-memory management • file-system access • protection • networking Chapter 3 Operating-System Structures
System Components Operating-System Services System Calls System Programs System Structures Virtual Machines System Design and Implementation System Generation Summary Exercises Chapter 3 Operating-System Structures Chapter 3 Operating-System Structures
3.2 Operating-System Services • Common services • Program execution • to load a program into memory and to run it. • I/O operations • user programs cannot execute I/O operations directly • File-system manipulation • capability to read, write, create, and delete files. • Communications • exchange of information between processes • Implemented via shared memory or message passing. • Error detection • ensure correct computing by detecting errors in the CPU and memory hardware, in I/O devices, or in user programs. Chapter 3 Operating-System Structures
Additional Functions • Not for helping the user, but rather for ensuring efficient system operations. • Resource allocation • allocate resources to multiple users or multiple jobs running at the same time • Accounting • keep track of and record which users use how much and what kinds of computer resources for account billing or for accumulating usage statistics • Protection • ensure that all access to system resources is controlled Chapter 3 Operating-System Structures
System Components Operating-System Services System Calls System Programs System Structures Virtual Machines System Design and Implementation System Generation Summary Exercises Chapter 3 Operating-System Structures Chapter 3 Operating-System Structures
3.3 System Calls • System calls • The interface between a process and the OS • Assembly-language • Higher-level language • C, C++ and Perl • Modern Microsoft Windows platforms • Win32 API (application programmer interface) • Even simple programs may make heavy use of the operating system. • To read data from one file and to copy them to another file • Requiring a sequence of system calls • Details are hidden from the programmer Chapter 3 Operating-System Structures
Pass parameters to the OS In registers Parameters may be more than registers In a block or table in memory The address is passed as a parameter in a register Stack Push parameters onto the stack by the program Pop off the stack by operating system 3.3 System Calls Chapter 3 Operating-System Structures
Passing of parameters as a table Chapter 3 Operating-System Structures
Five major categories Process control File management Device management Information maintenance Communications 3.3 System Calls Chapter 3 Operating-System Structures
MS-DOS At System Start-up Running a Program Chapter 3 Operating-System Structures
UNIX running multiple programs Chapter 3 Operating-System Structures
3.3.5 Communication Shared Memory Message Passing Chapter 3 Operating-System Structures
System Components Operating-System Services System Calls System Programs System Structures Virtual Machines System Design and Implementation System Generation Summary Exercises Chapter 3 Operating-System Structures Chapter 3 Operating-System Structures
3.4 System Programs • System programs provide a convenient environment for program development and execution • File management • Status information • File modification • Programming language support • Program loading and execution • Communication • System utilities or application programs • To solve common problems, or perform common operations • Web browsers and word processors • Games Chapter 3 Operating-System Structures
3.4 System Programs • Command interpreter • The most important system program • Two approaches • The command interpreter contains the code to execute the command. • Implement most commands by system programs Chapter 3 Operating-System Structures
System Components Operating-System Services System Calls System Programs System Structures Virtual Machines System Design and Implementation System Generation Summary Exercises Chapter 3 Operating-System Structures Chapter 3 Operating-System Structures
3.5 System Structure • To partition the task (OS) into small components (modules) • Not one monolithic system • Available approaches • Simple structure • Layered approach • Microkernels Chapter 3 Operating-System Structures
3.5.1 Simple Structure • MS-DOS • written to provide the most functionality in the least space • not divided into modules • Although having some structure, its interfaces and levels of functionality are not well separated Chapter 3 Operating-System Structures
MS-DOS layer structure Chapter 3 Operating-System Structures
3.5.1 Simple Structure • UNIX • Initially limited by hardware functionality • consists of two separable parts • The kernel • Everything below the system-call interface and above the physical hardware • Systems programs Chapter 3 Operating-System Structures
Unix System Structure Chapter 3 Operating-System Structures
3.5.2 Layered Approach • OS is broken into a number of layers (or levels) • Each built on top of lower layers • The bottom layer (layer 0) is the hardware • The highest layer (layer N) is the user interface • With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers. • Simplify debugging and system verification • Difficult to define each layer • Less efficient – overhead Chapter 3 Operating-System Structures
An OS layer Chapter 3 Operating-System Structures
OS/2 layer structure Chapter 3 Operating-System Structures
Windows NT • First release • A highly layer-oriented organization • Low performance (compared to Windows 95) • NT 4.0 • Move layers from user space to kernel space • Closely integration Chapter 3 Operating-System Structures
3.5.3 Microkernels • Unix • Kernel became large and difficult to manage • Mach • Developed at Carnegie Mellon University in the mid-1980s • Use the microkernel approach • Removing non-essential components from the kernel • Implement them as system- and user-level programs • A smaller kernel • Main function • To provide a communication facility Chapter 3 Operating-System Structures
3.5.3 Microkernels • Benefits • easier to extend • easier to port to new architectures • more reliable (less code is running in kernel mode) • more secure • Examples • Tru64 UNIX – UNIX + Mach kernel • MacOS X – based on Mach kernel • QNX – a real-time OS • Windows NT ( a hybrid structure) Chapter 3 Operating-System Structures
Windows NT client-server structure Chapter 3 Operating-System Structures
System Components Operating-System Services System Calls System Programs System Structures Virtual Machines System Design and Implementation System Generation Summary Exercises Chapter 3 Operating-System Structures Chapter 3 Operating-System Structures
3.6 Virtual Machines • A computer system is made up of layers • Hardware is the lowest • Virtual machines • take the layered approach to its logical conclusion • treat hardware and the operating system kernel as though they were all hardware • provide an interface identical to the underlying bare hardware. • The OS creates the illusion of multiple processes, each executing on its own processor with its own (virtual) memory. Chapter 3 Operating-System Structures
System Models Non-virtual Machine Virtual Machine Chapter 3 Operating-System Structures
3.6.1 Implementation • Difficult to implement • To provide an exact duplicate of the underlying machine • User mode • Monitor mode • Time – the major difference • I/O • Less time or more time • CPU • Multiprogrammed among many virtual machines Chapter 3 Operating-System Structures
3.6.2 Benefits • Provide complete protection of system resources • Each virtual machine is isolated from all other virtual machines. • Permits no direct sharing of resources. • A perfect vehicle for operating-systems research and development • System development is done on the virtual machine, instead of on a physical machine and so does not disrupt normal system operation. • Solve system compatibility problems Chapter 3 Operating-System Structures
3.6.3 Java • A very popular object-oriented language • By Sun Microsystems in late 1995 • Consists of • A language specification • A large API library • A specification for a Java virtual machine(JVM) • A class loader • A class verifier • A Java interpreter Chapter 3 Operating-System Structures