Presentation is loading. Please wait.

Presentation is loading. Please wait.

Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: System Structures.

Similar presentations


Presentation on theme: "Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: System Structures."— Presentation transcript:

1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: System Structures

2 2.2 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Chapter 2: 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 Operating System Debugging Operating System Generation System Boot

3 2.3 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition 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 To explain how operating systems are installed and customized and how they boot

4 2.4 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Operating System Services One set of operating-system services provides functions that are helpful to the user: User interface - Almost all operating systems have a user interface (UI)  Varies between Command-Line (CLI), Graphics User Interface (GUI), Batch 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) 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.

5 2.5 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition A View of Operating System Services

6 2.6 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Operating System Services (Cont) One set of operating-system services provides functions that are helpful to the user (Cont): 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 hardware, 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

7 2.7 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Operating System Services (Cont) 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 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  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  If a system is to be protected and secure, precautions must be instituted throughout it.

8 2.8 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition User Operating System Interface - CLI Command Line Interface (CLI) or command interpreter allows direct command entry  Sometimes implemented in kernel, sometimes by systems program  Sometimes multiple flavors implemented – shells  Primarily fetches a command from user and executes it, commands can be implemented in two ways: – Commands built-in, number of commands determines the size of command interpreter since each command has its own code. – Command interpreter does not understand command, it uses only the command to identify a file to be loaded into memory and executed. – Example rm file.txt  search for file rm, load it into memory and execute it with the parameter file.txt » If the latter, adding new features doesn’t require shell modification. Command interpreter can be small.

9 2.9 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition 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 (known as a folder) Invented at Xerox PARC Many systems now include both CLI and GUI interfaces Microsoft Windows is GUI with CLI “command” shell Apple Mac OS X as “Aqua” GUI interface with UNIX kernel underneath and shells available Solaris is CLI with optional GUI interfaces (Java Desktop, KDE)

10 2.10 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Bourne Shell Command Interpreter

11 2.11 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition The Mac OS X GUI

12 2.12 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition System Calls Programming interface to the services provided by the OS Typically written in a high-level language (C or C++) “routines” some low level tasks may need to be written in assembly language. (Note that the system-call names used throughout this text are generic)

13 2.13 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition System Calls Example of a system call: writing a program to read data from a file and copy them to another file: Need to know two files names, requires a sequence of system call  A prompt message, read characters from keyboard.  Define two files  other option can have a mouse which requires another system calls Open the input file and create the output file (system calls) Possible errors:  input file does not exist or has protection: Print a message on the console to user (system calls) then terminate abnormally (system call)  Output file: exist  may cause abort (a system call) and create new one (a system call) in interactive system: may ask to replace or abort the program (system calls)

14 2.14 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition System Calls Both files are ready:  We enter a loop read from input file (system call) and write to output file (system call)  After entire file is copied: – program may close both files (system call) – Write a message to the console or window (more system calls) – Terminate normally (final system calls) Usually system executes thousands of system calls per second see Figure (2.4)

15 2.15 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition System Calls 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) So functions (made from API) invoke the actual system calls on behalf of the application programmers Why use APIs rather than system calls? An application programmer designing a program using an API can expect her program to compile and run on any system that supports the same API. ( works on different systems) Actual system calls can often be more detailed and difficult to work with than the API available to an application programmer.

16 2.16 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Example of System Calls System call sequence to copy the contents of one file to another file

17 2.17 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Example of Standard API Consider 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 from DWORD bytesToRead—the number of bytes to be read into the buffer LPDWORD bytesRead—the number of bytes read during the last read LPOVERLAPPED ovl—indicates if overlapped I/O is being used

18 2.18 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition 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 need know nothing about how the system call is implemented Just needs to obey API and understand what OS will do as a result call 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)

19 2.19 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition API – System Call – OS Relationship

20 2.20 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Standard C Library Example C program invoking printf() library call, which calls write() system call

21 2.21 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition System Call Parameter Passing Often, with system call, more information is required than simply identity of desired system call Exact type and amount of information vary according to OS and call For example to get input we may need:  Specify the fie or the device as the source  Address and length of memory buffer into in which the input should be read.

22 2.22 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition System Call Parameter Passing Three general methods used to pass parameters to the OS 1. Simplest: pass the parameters in registers  In some cases, may be more parameters than registers 2. 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 3. 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

23 2.23 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Parameter Passing via Table

24 2.24 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Types of System Calls Process control File management Device management Information maintenance Communications Protection

25 2.25 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Examples of Windows and Unix System Calls

26 2.26 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process control end / abort A running program needs to be able to halt its execution either normally (end) or abnormally (abort) Load / execute A process or job executing one program may want to load and execute another program Create process / terminate a process Process may need to create a new process and terminate it. Get process attributes/ set process attributes If we create new job or process, we need to control the execution. This control requires the ability to determine and reset the attributes of a job or process, including the process’s priority, time execution and so on.

27 2.27 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process control wait for time/ wait event/ signal event Having created new processes, we may need to wait for them to finish their execution, we may want to wait for a certain amount of time to pass (wait time) We will want to wait for a specific event to occur (wait event) The process should then signal when the event has occurred (signal event) Lock / release lock When two or more process share data, OS provides system calls allow a process to lock shared data to prevent another process from accessing the data while its locked. Release lock, remove prevention from locked data. Such system calls lock/ release lock used in concurrent process execution

28 2.28 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process control Variations of process control: Single-tasking system  MS-Dos  Execute only one process  Process cannot create another process Multi-tasking system  FreeBSD (derived from Berkeley UNIX)  It accept commands from user and return back to command line  To run another process, shell execute fork() system call, then the selected program loaded into memory via exec() system call  When process is done, it executes an exit() system call to terminate

29 2.29 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition MS-DOS execution (a) At system startup (b) running a program

30 2.30 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition FreeBSD Running Multiple Programs

31 2.31 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition File Management Create file/ delete file Need the files name and perhaps their attributes Open/ close/ read/ write/ reposition Once created, we need to open it and use it We may also need to read, write, reposition (rewinding or skipping to the end of the file) We need to close the file Same as the directories Get file attributes/ set file attributes Attributes such as file name, file type, protection code, accounting information and so on.

32 2.32 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Device Management A process may need several resources to execute. Resources  devices  physical (disk drives) virtual devices (files) Request device/ release device When program needs to use some resources. Once it done, it release it Functions are similar to open and close system calls for files Read/ write/ reposition device Same as files

33 2.33 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Information Maintenace Many system calls exist to transfer information between user program and OS Get time/ get date Other system may return other information such as number of users, OS version, free memory and so on OS keep information about all processes and system calls are used to access this information. Get (process/ file / device) attributes Set (process/ file / device) attributes

34 2.34 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Communication Two common models of interprocesses communication Message-passing model Shared-memory model Message-passing model Use messages between processes to transfer information Messages exchanged through a common mail-box First: a connection must be opened, the name of other communicator muse be known  Can be a process in the same system or other computer in the network  Each computer has a host name, and a network identifier (IP address)  Each process has a process name.

35 2.35 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Communication Message-passing model –continued The get hostid and get processid system calls (from process name to process identifier) do this translation The identifiers then passed to: General-purpose open and close calls provided by file system or Specific open connection and close connection system calls depending on the system model of communication.

36 2.36 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Communication Message-passing model –continued The recipient process must give its permission for communication to take place with an accept connection call. Most processes receiving connection are special-purpose daemons. They execute a wait for connection call and are awakened when the connection is made. Source process known as client and receiving daemon known as server. Then exchange message by using read message and write message system calls The close connection call terminates the communication

37 2.37 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Communication Shared memory model Processes use shared memory create and shared memory attach system calls to create and gain access to regions of memory owned by other process. Once permission granted, processes can exchange information by reading and writing data in the shared memory. This form of data is controlled by the process not OS. Processes ensure that they are not using the same location of memory simultaneously Comparisons : Both models are used, the first one is useful for smaller amount of data, and easier to implement than shared memory model for inter-computer communication. Shared-memory model allow maximum speed since it is done at the memory transfer speed. Problems (protection –synchronization between processes sharing the memory)

38 2.38 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Protection Protection provide a mechanism for controlling access to the resources of the system With the advent of networking and Internet, protection becomes more important. Typical system calls for protection include Set permission Get permission Which manipulate the permission settings of resources such as files and disks. Allow user and Deny user system calls decide what user has the right to access certain resources.

39 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, End of Chapter 2


Download ppt "Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 2: System Structures."

Similar presentations


Ads by Google