Sie sind auf Seite 1von 25

MODULE I

Introduction: Operating System Batch, Multiprogrammed, Time-sharing and Real timesystems Operating system structure Operating system operations System Structures: Operating system service System calls System Programs Systemstructure Simple structure, Layered approach Kernel, Shell. Introduction: Operating System What is an Operating System? A program that acts as an intermediary between a user of a computer and the computer hardware. Operating system goals: Execute user programs and make solving user problems easier. Make the computer system convenient to use. Use the computer hardware in an efficient manner. Computer System Components A computer system can be divided roughly into four components: the hardware, the operating system, the application programs, and the users. Hardware provides basic computing resources (CPU, memory, I/O devices). Operating system controls and coordinates the use of the hardware among the various application programs for the various users. Applications programs define the ways in which the system resources are used to solve the computing problems of the users (compilers, database systems, video games, business programs). Users (people, machines, other computers).

Abstract view of the components of a computer system Operating systems from two viewpoints: that of the user and that of the system. User View The user's view of the computer varies according to the interface being used. Most computer users sit in front of a PC, consisting of a monitor, keyboard, mouse, and system unit. Such a system is designed for one user to monopolize its resources. The goal is to maximize the work (or play) that the user is performing. In this case, the operating system is designed mostly for ease of use, with some attention paid to performance and none paid to resource utilizationhow various hardware and software resources are shared. System View From the computer's point of view, the operating system is the program most intimately involved with the hardware. In this context, we can view an operating system as a resource allocator. A computer system has many resources that may be required to solve a problem: CPU time, memory space, file-storage space, I/O devices, and so on. The operating system acts as the manager of these resources. Facing numerous and possibly conflicting requests for resources, the operating system must decide how to allocate them to specific programs and users so that it can operate the computer system efficiently and fairly.

Evolution of Operating Systems Early Systems (1950) Mainframe Computer Systems were the first computers used to tackle many commercial and scientific applications. Simple Batch Systems (1960) Batch jobs together with similar needs and run them through the computer as group. Batch processing generally requires the program, data and appropriate system commands to be submitted together in the form of job. Batch operating systems usually allow little or no interaction between the users and the executing programs. Scheduling in batch system is very simple. Jobs are typically processed in the order of submission that is in first-come, first - served. Memory management in batch systems is also very simple. Memory is usually divided into two areas. In this execution environment, the CPU is often idle, because the speeds of the mechanical I/O devices are intrinsically slower than are those of the electronic devices. Memory Layout for a Simple Batch System

Multiprogrammed Batch Systems (1970) Multiprogramming needed for efficiency. The O.S. picks and begins to execute one job from memory. Once this job needs an I/O operation the O.S. switches to another job (CPU or O.S. always busy). The number of jobs in memory is less than the number of jobs in disk (Job Pool). If several jobs are ready to be brought into memory and there is not enough room for all of them, then the system chooses jobs among them (Job Scheduling). If several jobs are ready to run at the same time, the system must choose among them (CPU Scheduling). Having several programs in memory at the same time requires memory management. In non-multiprogrammed system, CPU sits idle. In multiprogramming system, CPU will never be idle.

Memory Layout for a multiprogramming System Timesharing Timesharing (Interactive Computing) is logical extension in which CPU switches jobs so frequently that users can interact with each job while it is running, creating interactive computing.

Processors time is shared among multiple users Response time should be < 1 second Each user has at least one program executing in memory process If processes dont fit in memory, swapping moves them in and out to run Virtual memory allows execution of processes not completely in memory In time-sharing systems, several jobs must be kept simultaneously in memory (job scheduling technique Round Robin method), the system must have memory management and protection. To obtain reasonable response time virtual memory concept is used. To ensure orderly execution, the system must provide mechanisms for job synchronization and communication, and it may ensure that the job do not get stuck in a deadlock. Real Time Systems Note that not all Operating Systems are general-purpose systems. Real-Time (RT) systems are dedicated systems that need to adhere to deadlines , i.e., time constraints Real time computing may be defined as that type of computing in which the correctness of the system depends not only on the logical result of the computation but also on the time at which results are produced. A hard real time Hard real-time system must meet its deadline. Conflicts with time-sharing systems, not supported by generalpurpose OSs. Often used as a control device in a dedicated application: Industrial control Robotics Secondary storage limited or absent, data/program is stored in short term memory, or Read-Only Memory (ROM). Virtual memory is absent (Time Sharing). Also called as special purpose OS

A soft real time Deadlines desirable but not mandatory. Limited utility in industrial control or robotics. Useful in modern applications (multimedia, video conference, virtual reality) requiring advanced operating-system features Multiprocessor Systems (1980) System with several CPUs in close communication: processors share memory and a clock. communication usually takes place through the shared memory. Also known as parallel systems, tightly-coupled systems. Multiprocessors systems growing in use and importance advantages include: Increased throughput Economy of scale - Increased reliability graceful degradation or fault tolerance Multiprocessor Architecture

Multiprogramming vs. Multiprocessing

Types of Multiprocessor Systems Asymmetric Multiprocessing master processor schedules and allocates work to slave processors. Symmetric Multiprocessing (SMP) Each processor runs an identical copy of the operating system. Typically each processor does self-scheduling form the pool of available process. - Most modern operating systems support SMP. Symmetric Multiprocessing (SMP) Each processor can perform the same functions and share same main memory and I/O facilities (symmetric). The OS schedule processes/threads across all the processors (real parallelism). Existence of multiple processors is transparent to the user. Incremental growth: just add another CPU. Robustness: a single CPU failure does not halt the system, only the performance is reduced.

Networked/Distributed Systems (1980) Networked Systems Distribute resources and the computation among several physical processors. Loosely coupled system: each processor has its own local memory. processors communicate with one another through various communications lines. Advantages: Resources Sharing Computation speed up load sharing Reliability Node1

Node2

network

. . Node3 Distributed Systems

. node n

Distributed system is collection of loosely interconnected by a communications network.

coupled

processors

Processors variously called nodes, computers, machines, hosts. Reasons for distributed systems: Resource sharing: sharing and printing files at remote sites. processing information in a distributed database. using remote specialized hardware devices. Computation speedup load sharing. Reliability detect and recover from site failure, function transfer, reintegrate failed site. Communication message passing. Client-Server Systems Dumb terminals supplanted by smart PCs. Many systems are now servers, responding to requests generated by clients -Computer-server provides an interface to client to request services (i.e., database) File-server provides interface for clients to store and retrieve files. General Structure of a Client-Server System

Peer to Peer systems P2P does not distinguish clients and servers. Instead all nodes are considered peers. May each act as client, server or both. Node must join P2P network

Registers its service with central lookup service on network, or Broadcasts request for service and responds to requests for service via discovery protocol Web-based Systems (1990) Web has become ubiquitous. PCs most prevalent devices. More devices becoming networked to allow web access. New category of devices to manage Web traffic among similar servers: Load Balancers. Basis for Grids/Cloud Computing. Grid Computing Systems Collection of computer resources, usually owned by multiple parties and in multiple locations, connected together such that users can share access to their combined power: Can easily span a wide-area network Heterogeneous environment Crosses administrative/geographic boundaries Supports Virtual Organizations (VOs) Examples: EGEE - Enabling Grids for E-SciencE (Europe), Open Science Grid (USA). Cloud Computing Systems Collection of computer resources, usually owned by a single entity, connected together such that users can lease access to a share of their combined power: Location independence: the user can access the desired service from anywhere in the world, using any device with any (supported) system.

Cost-effectiveness: the whole infrastructure is owned by the provider and requires no capital outlay by the user. - Reliability: enhanced by way of multiple redundant sites, though outages can occur, leaving users unable to remedy the situation Hand held Systems Handheld systems are also dedicated. - Personal Digital Assistants (PDAs). - Cellular telephones Issues: - Limited memory - Slow processors - Small display screens Operating system structure One of the most important aspect of OS is the ability to Multiprogramming Single user cannot keep CPU and I/O devices busy at all times One job selected and run via job scheduling When it has to wait (for I/O for example), OS switches to another job

Memory Layout for Multiprogrammed System

Multiprogramming Jobs are stored in Job Pool Virtual memory is the useful technique for the limitation size of physical memory Operating system operations Interrupt (driven by hardware) vs. Trap (called by software or error) Trap example: divide by 0; invalid memory access We need to make sure that an error in a user program could cause problems only for the one program that was running (such as infinite loop) . Dual mode operation Dual-mode operation allows OS to protect itself and other system components It contains user mode (mode bit:1) and Kernel mode (mode bit:0) The operating system loaded user application starts in user mode. Whenever a trap or interrupt occurs, hardware switches to kernel mode. Transition from user to kernel mode

Privileged instructions: some machine instructions that may cause harm, can only be executed in kernel mode. Such as instruction switch to user mode; I/O control; timer management, and interrupt management. Timer To prevent the OS out of control by CPU 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 System Structures: Operating system service

One set of operating-system services provides functions that are helpfulto the user : User interface - Almost all operating systems have a user interface (UI) o Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch Program execution - The system must be able to load a program intomemory and to run that program, end execution, either normally orabnormally (indicating error)

I/O operations - A running program may require I/O, which may involve a file or an I/O device. File-system manipulation - The file system is of particular interest.Obviously, programs need to read and write files and directories, create and delete them, search them, list file Information, permission management Communications Processes may exchange information, on the same computer or between computers over a network o Communications may be via shared memory or through message passing (packets moved by the OS) Error detection OS needs to be constantly aware of possible errors o May occur in the CPU and memory hardware, in I/O devices, in user program o For each type of error, OS should take the appropriate action toensure correct and consistent computing o Debugging facilities can greatly enhance the users and programmers abilities to efficiently use the system Another set of OS functions exists for ensuring the efficient operation of the system itself via resource sharing Resource allocation - When multiple users or multiple jobs running concurrently, resources must be allocated to each of them. o Many types of resources - Some (such as CPU cycles, main memory,and file storage) may have special allocation code, others (such asI/O devices) may have general request and release code. Accounting - To keep track of which users use how much and whatkinds of computer resources Protection and security - The owners of information stored in a multiuser or networked computer system may want to control use of that information, concurrent processes should not interfere with each other o Protection involves ensuring that all access to system resources is controlled.

o Security of the system from outsiders requires user authentication,extends to defending external I/O devices from invalid access attempts. o If a system is to be protected and secure, precautions must be instituted throughout it. A chain is only as strong as its weakest link. 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). Example of System Calls System call sequence to copy the contents of one file to another file.

Example of Standard API Consider the ReadFile() function in the Win32 APIa function for reading from a file

A description of the parameters passed to ReadFile() HANDLE filethe file to be read LPVOID buffera buffer where the data will be read into and written from DWORD bytesToReadthe number of bytes to be read into the buffer LPDWORD bytesReadthe number of bytes read during the last read LPOVERLAPPED ovlindicates if overlapped I/O is being used

System Call Implementation Typically, a number associated with each system call. o System-call interface maintains a table indexed according to these numbers. The system call interface invokes intended system call in OS kernel and returns status of the system call and any return values. The caller need know nothing about how the system call is implemented. o Just needs to obey API and understand what OS will do as a result call o Most details of OS interface hidden from programmer by API .

Managed by run-time support library (set of functions built into libraries included with compiler. API System Call OS Relationship

System Call Parameter Passing Often, more information is required than simply identity of desired system call. o Exact type and amount of information vary according to OS and call. Three general methods used to pass parameters to the OS. o Simplest: pass the parameters in registers. In some cases, may be more parameters than registers. o Parameters stored in a block, or table, in memory, and address of block passed as a parameter in a register . This approach taken by Linux and Solaris. o Parameters placed, or pushed, onto the stack by the program and popped off the stack by the operating system.

o Block and stack methods do not limit the number or length of parameters being passed. Parameter Passing via Table

Types of System Calls Process control File management Device management Information maintenance Communications Process Control end, abort load, execute create process, terminate process get process attributes, set process attributes wait time wait event, signal event allocate and free memory

File Management Common systems calls dealing with files and directories: create file, delete file open, close read, write, reposition get file attributes, set file attributes Device Management Similarity between files and I/O devices results in similar device system calls (some OS even merges two into a combined filedevice structure): request device, release device read, write, reposition get device attributes, set device attributes logically attach or detach devices Information Maintanence System calls for transferring information between the user program and OS: get time or date, set time or date get system data, set system data get process, file, or device attributes set process, file or device attributes Communication System calls for transferring information between the user program and OS: create, delete communication connection send, receive message transfer status information attach or detach remote devices

System Programs System programs provide a convenient environment for program development and execution. The can be divided into: o File manipulation o Status information o File modification o Programming language support o Program loading and execution o Communications o Application programs Most usersview of the operation system is defined by system programs, not the actual system calls. Provide a convenient environment for program development and execution. o Some of them are simply user interfaces to system calls; others are considerably more complex. File management -Create, delete, copy, rename, print, dump, list, and generally manipulate files and directories. Status information. o Some ask the system for info -date, time, amount of available memory, disk space, number of users. o Others provide detailed performance, logging, and debugging information. o Typically, these programs format and print the output to the terminal or other output devices. o Some systems implement a registry -used to store and retrieve configuration nformation. File modification o Text editors to create and modify files o Special commands to search contents of files or perform transformations of the text. Programming-language support -Compilers, assemblers, debuggers and interpreters sometimes provided.

Program loading and execution-Absolute loaders, relocatableloaders, linkage editors, and overlay-loaders, debugging systems for higher-level and machine language. Communications -Provide the mechanism for creating virtual connections among processes, users, and computer systems. o Allow users to send messages to one anothers screens, browse web pages, send electronic-mail messages, log in remotely, transfer files from one machine to another. System structure Simple structure MS-DOS written to provide the most functionality in the least space. o Not divided into modules Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated. MS DOS Layer Structure

Layered Approach The operating system is divided into a number of layers (levels), each built on top of lower layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface. With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layers. Layered Operating System

UNIX UNIX limited by hardware functionality, the original UNIX operating system had limited structuring. The UNIX OS consists of two separable parts. o Systems programs o The kernel Consists of everything below the system-call interface and above the physical hardware.

Provides the file system, CPU scheduling, memory management, and other operating-system functions; a large number of functions for one level. UNIX System Structure

Microkernel System Structure Moves as much from the kernel into userspace. Communication takes place between user modules using message passing. Benefits: o Easier to extend a microkernel o Easier to port the operating system to new architectures o More reliable (less code is running in kernel mode) o More secure Detriments: o Performance overhead of user space to kernel space communication.

Mac OS X Structure

Modules Most modern operating systems implement kernel modules. o Uses object-oriented approach o Each core component is separate o Each talks to the others over known interfaces o Each is loadable as needed within the kernel Overall, similar to layers but with more flexible. Solaris Modular Approach

Reference: 1.Operating System Principles-Abham Silberschatz

Das könnte Ihnen auch gefallen