ch2_edit

download ch2_edit

of 26

Transcript of ch2_edit

  • 8/11/2019 ch2_edit

    1/26

    Operating System ServicesOne set of operating-system services provides functions that are helpfulto the user:

    User interface - Almost all operating systems have a userinterface (UI)

    Varies between Command-Line (CLI) , Graphics User Interface(GUI), Batch

    Program execution - The system must be able to load aprogram into memory and to run that program, end execution,either normally or abnormally (indicating error)I/O operations - A running program may require I/O, which mayinvolve a file or an I/O device

    File-system manipulation - The file system is of particularinterest. Obviously, programs need to read and write files anddirectories, create and delete them, search them, list fileInformation, permission management.

  • 8/11/2019 ch2_edit

    2/26

    Operating System Services (Cont)

    One set of operating-system services provides functions that arehelpful to the user (Cont):

    Communications Processes may exchange information,on the same computer or between computers over anetwork

    Communications may be via shared memory or throughmessage passing (packets moved by the OS)

    Error detection OS needs to be constantly aware ofpossible errors

    May occur in the CPU and memory hardware, in I/O devices, inuser programFor each type of error, OS should take the appropriate action toensure correct and consistent computingDebugging facilities can greatly enhance the users and

    programmers abilities to efficiently use the system

  • 8/11/2019 ch2_edit

    3/26

    Operating System Services (Cont)

    Another set of OS functions exists for ensuring the efficient operation of thesystem itself via resource sharing

    Resource allocation - When multiple users or multiple jobs runningconcurrently, resources must be allocated to each of them

    Many types of resources - Some (such as CPU cycles, main memory,and file storage) may have special allocation code, others (such as I/Odevices) may have general request and release code

    Accounting - To keep track of which users use how much and what kinds ofcomputer resourcesProtection and security - The owners of information stored in a multiuser ornetworked computer system may want to control use of that information,concurrent processes should not interfere with each other

    Protection involves ensuring that all access to system resources iscontrolledSecurity of the system from outsiders requires user authentication,extends to defending external I/O devices from invalid access attemptsIf a system is to be protected and secure, precautions must be institutedthroughout it. A chain is only as strong as its weakest link.

  • 8/11/2019 ch2_edit

    4/26

    User Operating System Interface - CLI

    Command Line Interface (CLI) or commandinterpreter allows direct command entry

    Sometimes implemented in kernel, sometimes bysystems program

    Sometimes multiple flavors implemented shellsPrimarily fetches a command from user and executes itSometimes commands built-in, sometimes just names ofprograms

    If the latter, adding new features doesnt require shellmodification

  • 8/11/2019 ch2_edit

    5/26

    User Operating System Interface - GUI

    User-friendly desktop metaphor interfaceUsually mouse, keyboard, and monitorIcons represent files, programs, actions, etcVarious mouse buttons over objects in the interface cause

    various actions (provide information, options, executefunction, open directory (known as a folder )Invented at Xerox PARC

    Many systems now include both CLI and GUI

    interfacesMicrosoft Windows is GUI with CLI command shell Apple Mac OS X as Aqua GUI interface with UNIXkernel underneath and shells available

    Solaris is CLI with optional GUI interfaces (Java Desktop,KDE)

  • 8/11/2019 ch2_edit

    6/26

  • 8/11/2019 ch2_edit

    7/26

    Example of Standard APIConsider the ReadFile() function in the

    Win32 API a function for reading from a file

    A description of the parameters passed to ReadFile()HANDLE file the file to be read

    LPVOID buffer a buffer where the data will be read into and written fromDWORD bytesToRead the number of bytes to be read into the bufferLPDWORD bytesRead the number of bytes read during the last readLPOVERLAPPED ovl indicates if overlapped I/O is being used

  • 8/11/2019 ch2_edit

    8/26

  • 8/11/2019 ch2_edit

    9/26

    System Call Parameter PassingOften, more information is required than simplyidentity of desired system call

    Exact type and amount of information vary according toOS and call

    Three general methods used to pass parameters to

    the OSSimplest: pass the parameters in registers In some cases, may be more parameters than registers

    Parameters stored in a block, or table, in memory, andaddress of block passed as a parameter in a register

    This approach taken by Linux and SolarisParameters placed, or pushed, onto the stack by theprogram and popped off the stack by the operatingsystemBlock and stack methods do not limit the number orlength of parameters being passed

  • 8/11/2019 ch2_edit

    10/26

    Types of System Calls

    Process controlFile managementDevice managementInformation maintenanceCommunicationsProtection

  • 8/11/2019 ch2_edit

    11/26

    System Programs

    System programs provide a convenientenvironment for program development andexecution. The can be divided into:

    File manipulationStatus informationFile modificationProgramming language supportProgram loading and executionCommunications

    Application programs

    Most users view of the operation system isdefined by system programs, not the actualsystem calls

  • 8/11/2019 ch2_edit

    12/26

    System ProgramsProvide a convenient environment for program development and execution

    Some of them are simply user interfaces to system calls; others are considerablymore complex

    File management - Create, delete, copy, rename, print, dump, list, and generallymanipulate files and directories

    Status information

    Some ask the system for info - date, time, amount of available memory, disk space,number of users

    Others provide detailed performance, logging, and debugging informationTypically, these programs format and print the output to the terminal or other outputdevices

    Some systems implement a registry - used to store and retrieve configuration

    information

  • 8/11/2019 ch2_edit

    13/26

    System Programs (contd) File modification

    Text editors to create and modify filesSpecial commands to search contents of files or performtransformations of the text

    Programming-language support - Compilers, assemblers,

    debuggers and interpreters sometimes providedProgram loading and execution- Absolute loaders,relocatable loaders, linkage editors, and overlay-loaders,debugging systems for higher-level and machinelanguageCommunications - Provide the mechanism for creatingvirtual connections among processes, users, andcomputer systems

    Allow users to send messages to one anothers screens,browse web pages, send electronic-mail messages, log inremotely, transfer files from one machine to another

  • 8/11/2019 ch2_edit

    14/26

    Operating System Design and Implementation

    Design and Implementation of OS not solvable , butsome approaches have proven successfulInternal structure of different Operating Systems canvary widelyStart by defining goals and specifications

    Affected by choice of hardware, type of systemUser goals and System goals

    User goals operating system should be convenient touse, easy to learn, reliable, safe, and fastSystem goals operating system should be easy todesign, implement, and maintain, as well as flexible,reliable, error-free, and efficient

  • 8/11/2019 ch2_edit

    15/26

    Operating System Design and Implementation (Cont)

    Important principle to separatePolicy: What will be done? Mechanism: How to do it?Mechanisms determine how to do something,

    policies decide what will be doneThe separation of policy from mechanism is a veryimportant principle, it allows maximum flexibility if policydecisions are to be changed later

  • 8/11/2019 ch2_edit

    16/26

    Simple Structure

    MS-DOS written to provide the most functionality inthe least spaceNot divided into modules

    Although MS-DOS has some structure, its interfaces andlevels of functionality are not well separated

  • 8/11/2019 ch2_edit

    17/26

    Layered Approach

    The operating system is divided into a number oflayers (levels), each built on top of lower layers. Thebottom layer (layer 0), is the hardware; the highest(layer N) is the user interface.

    With modularity, layers are selected such that eachuses functions (operations) and services of onlylower-level layers

  • 8/11/2019 ch2_edit

    18/26

    UNIX

    UNIX limited by hardware functionality, theoriginal UNIX operating system had limitedstructuring. The UNIX OS consists of twoseparable parts

    Systems programsThe kernel

    Consists of everything below the system-call interface andabove the physical hardware

    Provides the file system, CPU scheduling, memorymanagement, and other operating-system functions; alarge number of functions for one level

  • 8/11/2019 ch2_edit

    19/26

    Microkernel System Structure

    Moves as much from the kernel into user space Communication takes place between user modulesusing message passingBenefits:

    Easier to extend a microkernelEasier to port the operating system to new architecturesMore reliable (less code is running in kernel mode)More secure

    Detriments:Performance overhead of user space to kernel spacecommunication

  • 8/11/2019 ch2_edit

    20/26

    Modules

    Most modern operating systems implement kernelmodulesUses object-oriented approachEach core component is separate

    Each talks to the others over known interfacesEach is loadable as needed within the kernel

    Overall, similar to layers but with more flexible

  • 8/11/2019 ch2_edit

    21/26

    Virtual Machines

    A virtual machine takes the layeredapproach to its logical conclusion. It treatshardware and the operating system kernelas though they were all hardware

    A virtual machine provides an interfaceidentical to the underlying bare hardwareThe operating system host creates theillusion that a process has its ownprocessor and (virtual memory)Each guest provided with a (virtual) copy ofunderlying computer

  • 8/11/2019 ch2_edit

    22/26

    Virtual Machines History and Benefits

    First appeared commercially in IBM mainframes in 1972Fundamentally, multiple execution environments(different operating systems) can share the samehardwareProtect from each other

    Some sharing of file can be permitted, controlledCommutate with each other, other physical systems vianetworkingUseful for development, testing

    Consolidation of many low-resource use systems ontofewer busier systemsOpen Virtual Machine Format , standard format of virtualmachines, allows a VM to run within many different virtualmachine (host) platforms

  • 8/11/2019 ch2_edit

    23/26

    Para-virtualization

    Presents guest with system similar but not identicalto hardwareGuest must be modified to run on paravirtualizedhardwareF

    Guest can be an OS, or in the case of Solaris 10applications running in containers

  • 8/11/2019 ch2_edit

    24/26

    Operating-System DebuggingDebugging is finding and fixing errors, or bugsOSes generate log files containing error informationFailure of an application can generate core dump file capturingmemory of the processOperating system failure can generate crash dump filecontaining kernel memoryBeyond crashes, performance tuning can optimize systemperformanceKernighans Law: Debugging is twice as hard as writing thecode in the rst place. Therefore, if you write the code ascleverly as possible, you are, by denition, not smart enoughto debug it. DTrace tool in Solaris, FreeBSD, Mac OS X allows liveinstrumentation on production systems

    Probes fire when code is executed, capturing state data andsending it to consumers of those probes

  • 8/11/2019 ch2_edit

    25/26

    Operating System Generation

    Operating systems are designed to run on any of aclass of machines; the system must be configuredfor each specific computer siteSYSGEN program obtains information concerning

    the specific configuration of the hardware systemBooting starting a computer by loading the kernelBootstrap program code stored in ROM that is ableto locate the kernel, load it into memory, and start its

    execution

  • 8/11/2019 ch2_edit

    26/26

    System Boot

    Operating system must be made available tohardware so hardware can start itSmall piece of code bootstrap loader , locates thekernel, loads it into memory, and starts itSometimes two-step process where boot block at fixedlocation loads bootstrap loaderWhen power initialized on system, execution starts at afixed memory location

    Firmware used to hold initial boot code