Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mi Jung Choi Dept. of Computer Science Silberschatz, Galvin and Gagne ©2006 Operating System Principles Chapter 2: Operating-System.

Similar presentations


Presentation on theme: "Mi Jung Choi Dept. of Computer Science Silberschatz, Galvin and Gagne ©2006 Operating System Principles Chapter 2: Operating-System."— Presentation transcript:

1 Mi Jung Choi mjchoi@kangwon.ac.kr Dept. of Computer Science Silberschatz, Galvin and Gagne ©2006 Operating System Principles Chapter 2: Operating-System Structures

2 - 2 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Chapter 2: Operating-System Structures  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System Programs  Operating System Design and Implementation  Operating System Structure  Virtual Machines

3 - 3 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Objectives  To describe the services an operating system provides to users, processes, and other systems  To discuss the various ways of structuring an operating system

4 - 4 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Operating System Services To whom: Users, Processes, other systems With What: Memory, Storage, Devices, CPU  One set of OS services provides functions that are helpful to the user  Another set of OS functions exists for ensuring the efficient operation of the system itself via resource sharing

5 - 5 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Operating System Services  One set of OS services provides functions that are helpful to the user:  User Interface  Almost all operating systems have a user interface (UI)  Varies between Command-Line Interface (CLI), Graphical User Interface (GUI), Batch Interface  Program Execution  The system must be able to load a program into memory and to run that program, end execution either normally or abnormally (indicating error)

6 - 6 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Operating System Services  One set of OS services provides functions that are helpful to the user:  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.  Process needs to –read and write files and directories –create and delete them –search them –list file Information  permission management is also required.

7 - 7 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Operating System Services  One set of OS services provides functions that are helpful to the user:  Communications  Processes may exchange information, on the same computer or between computers over a network  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 – may occur in the CPU and memory, in I/O devices, in user program  For each type of error, OS should take the appropriate action to ensure correct and consistent computing  Debugging facilities can greatly enhance the user’s and programmer’s abilities to efficiently use the system

8 - 8 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Operating System Services  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  Many types of resources –Some (such as CPU cycles, main memory, and file storage) may have special allocation code. –Others (such as I/O devices) may have general request and release code.  Accounting  To keep track of which users use how much and what kinds of computer resources

9 - 9 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Operating System Services  Another set of OS functions exists for ensuring the efficient operation of the system itself via resource sharing  Protection and security in a multi-user computer system  The owners of information 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 is controlled  Security of the system from outsiders requires user authentication, –extends to defending external I/O devices from invalid access attempts

10 - 10 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures User Operating System Interface - CLI  CLI allows direct command entry  Command Line Interface (CLI)  Sometimes implemented in kernel,  Sometimes by systems program  Sometimes multiple flavors are implemented – shells  BASH (Bourne-Again SHell ), CSH (C SHell), KSH (Korn SHell), TCSH on Linux  CMD on windows XP  Primarily fetches a command from user and executes it  Sometimes commands built-in,  Sometimes just names of programs –adding new features doesn’t require shell modification

11 - 11 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures User Operating System Interface - GUI  User-friendly desktop metaphor interface  Usually mouse, keyboard, and monitor  Icons represent files, programs, actions, etc  Various mouse buttons over objects in the interface cause various actions  provide information, options, execute function, open directory  Invented at Xerox PARC  Many systems now include both CLI and GUI interfaces  Microsoft Windows is GUI with CLI “command” or “cmd” shell  Apple Mac OS X as “Aqua” GUI interface with UNIX kernel underneath and shells available  Linux is CLI with optional GUI interfaces (GNOM, KDE)

12 - 12 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures System Calls The only way that a process communicate with OS It provides an interface to the service made available by an OS

13 - 13 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures System Calls  Programming interface to the services provided by the OS  Typically written in a high-level language (C or C++)  Sometimes written using assembly-language instructions.  Mostly accessed by programs via a high-level Application Program Interface (API) rather than direct system call use  Each API consists of one or more systems calls.  APIs are OS specific.  Three most common APIs are  Win32 API, Win64 API for Windows,  POSIX API for POSIX-based systems (including UNIX, Linux, Mac OS X)  Java API for the Java virtual machine (JVM)  Why use APIs rather than system calls?  To provide a simplified method of the use of system calls and hide the implementation details.

14 - 14 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Example of System Calls  System call sequence to copy the contents of one file to another file scanf(infile) scanf(outfile) fopen(“r”); fopen(“w”); fgetc(); fputc(); fclose(infile); fclose(outfile); exit();

15 - 15 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Example of Standard API  Consider the ReadFile() function in the Win32 API  reads data from a file, and starts at the position that the file pointer indicates.  You can use this function for both synchronous and asynchronous operations.  A description of the parameters passed to ReadFile()  hFile - [in] A handle to the file to be read.  lpBuffer - [out] A pointer to the buffer that receives the data read from a file.  nNumberOfBytesToRead - [in] The maximum number of bytes to read.  lpNumberOfBytesRead - [out] A pointer to the variable that receives the number of bytes read.  lpOverlapped - [in] A pointer to an OVERLAPPED structure.

16 - 16 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures System Call Implementation  Typically, a number associated with each system call  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 needs to know nothing about how the system call is implemented  Just needs to obey API and understand what OS will do as a result of the call  Most details of OS interface hidden from programmer by API

17 - 17 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures API – System Call – OS Relationship

18 - 18 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Standard C Library Example  C program invoking printf() library call, which calls write() system call

19 - 19 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures System Call Parameter Passing  Often, more information is required than simple identity of desired system call  Exact type and amount of information vary according to OS and system call  Three general methods used to pass parameters to the OS  Simplest: pass the parameters in registers  In some cases, may be more parameters than registers  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  Parameters placed, or pushed, onto the stack by the program and popped off the stack by the operating system  Block and stack methods do not limit the number or length of parameters being passed

20 - 20 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Parameter Passing via Table

21 - 21 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Types of System Calls  Five types of system calls  Process control  File management  Device management  Information maintenance  Communications

22 - 22 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Types of System Calls  Process control  end, abort  load, execute  create process, terminate process  get process attributes, set process attributes  wait for time  wait event, signal event  allocate and free memory  File management  create file, delete file  open, close  read, write, reposition (move, rename, etc.)

23 - 23 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Types of System Calls  Device management  request device, release device  read, write, reposition  get device attributes, set device attributes  logically attach or detach devices  Information maintenance  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

24 - 24 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Types of System Calls  Communications  Create, delete communication connection  send, receive messages  transfer status information  attach or detach remote devices

25 - 25 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures MS-DOS execution (a) At system startup (b) running a program

26 - 26 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures FreeBSD Running Multiple Programs

27 - 27 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures System Programs  System programs provide a convenient environment for program development and execution.  Some of them are simply user interfaces to system calls; others are considerably more complex  They can be divided into:  File manipulation  Status information  File modification  Programming language support  Program loading and execution  Communications  Most users’ view of the operation system is defined by system programs, not the actual system calls

28 - 28 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures System Programs  File management  create, delete, copy, rename, print, dump, list, and generally manipulate files and directories  Status information  Some programs ask the system for info.  date, time, amount of available memory, disk space, number of users.  detailed performance, logging, and debugging information.  Typically, these programs format and print the output to the terminal, other output devices, files.  Some systems implement a registry - used to store and retrieve configuration information.

29 - 29 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures System Programs (cont’d)  File modification  Text editors to create and modify files  Special commands to search contents of files or perform transformations of the text  Programming-language support  Compilers, assemblers, debuggers and interpreters sometimes provided

30 - 30 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures System Programs (cont’d)  Program loading and execution  Once a program is assembled or compiled, it must be loaded into memory to be executed.  Absolute loaders, re-locatable loaders, 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  allow users to send messages to one another’s screens, browse web pages, send electronic-mail messages, log in remotely, transfer files from one machine to another

31 - 31 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures OS Design and Implementation

32 - 32 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Operating System Design and Implementation  Design and Implementation of OS is not “solvable”  but some approaches have proven successful  Internal structure of different OS can vary widely  Defining goals and specifications  Affected by choice of hardware, type of system  batch, multiprogramming, multitasking  single user, multi-user  distributed, real-time, general purpose.  User goals and System goals  User goals – operating system should be convenient to use, easy to learn, reliable, safe, and fast  System goals – operating system should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient

33 - 33 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Operating System Design and Implementation  Important principle to separate Policy: What will be done? Mechanism: How to do it?  Mechanisms determine how to do something.  Policies decide what will be done.  The separation of policy from mechanism is a very important principle,  it allows maximum flexibility if policy decisions are to be changed later  Once an operating system is designed, it must be implemented  Traditionally, written in assembly language.  Now, written in high-level languages (C: Linux and Windows)

34 - 34 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Operating System Structure 1.Simple Structure 2.Layered Structure 3.Microkernel System Structure 4.Modular Kernel Structure - Modern OS

35 - 35 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures 1. Simple Structure  MS-DOS  Policy - to provide the most functionality in the least space  Not divided into modules  Although MS-DOS has some structure, its interfaces and levels of functionality are not well separated

36 - 36 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures MS-DOS Layer Structure

37 - 37 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures 2. 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  A typical OS layer (layer M) consists of data structure and a set of routines that can be invoked by higher-level layers.  Layer M, in tern, can invoke operations on lower-level layers.

38 - 38 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Layered Operating System

39 - 39 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Layered Approach  Advantage  Simplicity of construction and debugging  The design and implementation is simplified.  Each layer is implemented with only those operations provided by lower-level layers.  A layer does not need to know how these operations are implemented.  Disadvantage  Appropriately defining the various layers  Because a layer can use only lower-level layers, careful planning is necessary.

40 - 40 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures  The UNIX OS consists of two separable parts  Systems programs  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  As UNIX expanded, the kernel became large. UNIX

41 - 41 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures UNIX System Structure

42 - 42 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures 3. Microkernel System Structure  Make the kernel as light as possible.  moves as much from the kernel into “user” space  Communication takes place between user modules using message passing  Mach OS from Carnegie Mellon Univ.  Advantage  Easier to extend a microkernel  Easier to port the operating system to new architectures  More reliable (less code is running in kernel mode) and secure  Disadvantage  Performance overhead of user space to kernel space communication

43 - 43 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures 4. Modular Kernel Structure  Most modern operating systems implement kernel modules  The kernel has a set of core components and dynamically links to additional services either during boot time or during run time.  uses object-oriented approach  Each core component is separate  Each talks to the others over known interfaces  Each is loadable as needed within the kernel  Overall, similar to layers but with more flexible

44 - 44 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Solaris Modular Approach

45 - 45 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Modular Kernel Structure  The Modular kernel approach is similar to the Layered approach  The modular kernel approach requires subsystems to interact with each other through carefully constructed interfaces  However, the Modular kernel approach differs from the Layered approach  The layered kernel imposes a strict ordering of subsystems such that subsystems at the lower layers are not allowed to invoke operations corresponding to the upper-layer subsystems.  There are no such restrictions in the modular-kernel approach, wherein modules are free to invoke each other without any constraints.

46 - 46 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Virtual Machine

47 - 47 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Virtual Machines  A virtual machine takes the layered approach to its logical conclusion.  It treats hardware and the operating system kernel as though they were all hardware  A virtual machine provides an interface identical to the underlying bare hardware  The operating system creates the illusion of multiple processes, each executing on its own processor with its own (virtual) memory  The resources of the physical computer are shared among the virtual machines

48 - 48 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Virtual Machines (a) Nonvirtual machine (b) virtual machine Non-virtual Machine Virtual Machine

49 - 49 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures  The virtual-machine concept provides complete protection of system resources since each virtual machine is isolated from all other virtual machines. This isolation, however, permits no direct sharing of resources.  A virtual-machine system is 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.  The virtual machine concept is difficult to implement due to the effort required to provide an exact duplicate to the underlying machine Virtual Machines

50 - 50 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures VMware Architecture http://www.vmware.com/

51 - 51 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures The Java Virtual Machine http://java.sun.com/

52 - 52 - CSIE301 Operating System Fall 2009 Ch2. Operating-System Structures Summary  OS provides a number of services  Functions that are helpful to the user  user interface, program execution, I/O operation  file system manipulation, communications, error detection  Functions that ensure the efficient operation of the system  resource allocation, accounting, protection and security  Three types of user interface from OS  CLI, GUI, Batch Interface  System calls allow a process to make requests to the OS.  To send a request, program use system APIs or standard library functions which are translated into a sequence of system calls.  Three methods of parameter passing in system call  Register, Block, Stack  The separation of policy from mechanism is a very important principle in the design of OS  Four types of OS structures  Simple, Layered, Microkernel, Modular  Virtual machine is an illusion of a computer system with own CPU, memory and I/O, which is created on top of host OS.

53 Mi Jung Choi mjchoi@kangwon.ac.kr Dept. of Computer Science Silberschatz, Galvin and Gagne ©2006 Operating System Principles End of Chapter 2


Download ppt "Mi Jung Choi Dept. of Computer Science Silberschatz, Galvin and Gagne ©2006 Operating System Principles Chapter 2: Operating-System."

Similar presentations


Ads by Google