Chapter 2: Operating-System Structures. Operating System Services User Operating System Interface ...

39
Chapter 2: Operating-System Structures
  • date post

    20-Dec-2015
  • Category

    Documents

  • view

    241
  • download

    3

Transcript of Chapter 2: Operating-System Structures. Operating System Services User Operating System Interface ...

Page 1: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Chapter 2: Operating-System Structures

Page 2: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

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

Page 3: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Objectives

Describe the services an operating system provides to users, processes, and other systems

Discuss various ways of structuring an operating system

Explain how operating systems are installed and customized and how they boot

Page 4: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Operating System Services Provide functions that are helpful to users

User interface Batch, Command-Line (CLI), Graphics User Interface (GUI) Program execution

Load a program into memory, Run it, End execution normally or abnormally

I/O operations File-system manipulation

Create, delete, read, write, and list files and directories Change permissions

Page 5: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Operating System Services (Cont.) Provide functions that are helpful to users

Communications Exchange information on the same computer or between

computers over a network Shared memory or message passing

Error detection Hardware: CPU, memory, I/O devices, etc. User program For each type of error, take an appropriate action to ensure

correct and consistent computing Debugging

Page 6: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Operating System Services (Cont.) Ensure efficient system operation via resource

sharing Resource allocation

CPU cycles, main memory, file storage, I/O devices Accounting: To keep track of which users use how much

and what kinds of computer resources Protection and security

Essential in multi-user/networked environment Protection: Ensure that all access to system resources is

controlled, e.g., mode bit, memory management Security: User authentication, access control, ...

Page 7: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

User Operating System Interface: CLI (Command Line Interface) Direct command entry

Implemented in kernel or by systems program

Multiple flavors can be implemented, e.g., several command shells for UNIX

Fetch a command from user and execute it Built-in (i.e., implemented in kernel) Invoke user-level programs

Adding new features requires no shell modification

Page 8: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

User Operating System Interface: GUI User-friendly desktop metaphor interface

Icons represent files, programs, actions, etc Mouse buttons over objects cause various actions Invented at Xerox PARC

Many systems have both CLI and GUI Microsoft Windows is GUI with CLI UNIX/LINUX is CLI with optional GUI interfaces Apple Mac OS X has Aqua GUI interface with

UNIX kernel underneath

Page 9: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

System Calls

Programming interface to OS services Typically written in C or C++ Usually use high-level Application Program

Interface (API) rather than direct system calls Win32 API for Windows POSIX API for POSIX-based systems (including

virtually all versions of UNIX, Linux, and Mac OS X)

Java API for the Java virtual machine (JVM)

Page 10: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Example System Calls System call sequence to copy the contents of

one file to another file

Page 11: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Example of Standard API

Consider the ReadFile() function in Win32 API

Page 12: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

System Call Implementation

System call interface invokes intended system call in OS and returns system status and any return values

Caller needs to know nothing about how the system call is implemented Use API Hide implementation details

Page 13: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

API – System Call – OS Relationship

Page 14: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Standard C Library Example

C program invoking printf() library call, which calls write() system call

Page 15: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

System Call Parameter Passing Often, more information is required than

simple identity of desired system call How to pass parameters to OS

Pass the parameters in registers Number & length of parameters can be limited

Parameters stored in a block or table in memory, and pass the block’s address as a parameter in a register

Push parameters onto stack

Page 16: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Parameter Passing via Table

Page 17: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Types of System Calls

Process control File management Device management Information maintenance Communications

Page 18: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

MS-DOS execution

(a) At system startup (b) running a program

Page 19: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

FreeBSD Running Multiple Programs

Page 20: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

System Programs Convenient environment for program

development and execution Program loading and execution File manipulation Programming language support Communications Application programs

Most users’ view of the OS is defined by system programs, not the actual system calls

Page 21: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

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 File management

Create, delete, copy, rename, print, dump, list, Status information File modification

Text editors to create and modify files Commands to search file contents, e.g., grep in UNIX/Linux

Page 22: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

System Programs (cont’d)

Programming language support Compilers/interpreters, assemblers, debuggers

Program loading and execution Absolute loaders, relocatable loaders, linkage

editors, and overlay loaders Communications

Creating virtual connections among processes, users, and computer systems

Send messages to somebody’s screen, send email, browse web pages, remote log in, file transfer

Page 23: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Operating System Design and Implementation

No silver bullet but some approaches have been successful

Internal structure of different OSs can vary widely Affected by choice of hardware & OS type First define goals and specifications User goals and System goals

User goals: OS should be convenient, easy to learn, reliable, safe, and fast

System goals: OS should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient

Page 24: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Operating System Design and Implementation (Cont.)

Important 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

Page 25: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Simple Structure

MS-DOS Written 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

Page 26: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

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

Page 27: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Layered Operating System

Page 28: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

UNIX UNIX

Limited by hardware functionality, the original UNIX had limited structuring consisted of two separable parts

Systems programs Kernel

Consists of everything below the system-call interface and above the physical hardware

Provides a large number of functions for one level: CPU scheduling, memory management, file system and other OS functions

Page 29: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

UNIX System Structure

Page 30: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Microkernel System Structure

Moves as much from the kernel into “user” space as possible

Message passing between user modules Benefits

Easier to extend a microkernel Easier to port the OS to new architectures More reliable (less code is running in kernel mode) More secure

Problem Performance overhead due to communications between

user space to kernel space

Page 31: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Mac OS X Structure

Hybrid approach (microkernel + layered approach)• Mach microkernel: Memory management, RPC & IPC• BSD kernel: BSD command line interface, networking & file system, POSIX API’s such as Pthreads• In addition, kernel environment provides an I/O kit & dynamically loadable modues

Page 32: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Modules

Most modern operating systems implement kernel modules 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, e.g.,

device drivers & system calls Similar to layers but more flexible

Page 33: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Solaris Modular Approach

Page 34: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Virtual Machines

Take the layered approach Treat hardware and OS kernel as

though they were all hardware Provide an interface identical to the

underlying hardware An OS creates the illusion of multiple

processes executing on its own processor with its own (virtual) memory

Page 35: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Virtual Machines (Cont.)

(a) Nonvirtual machine (b) virtual machine

Non-virtual Machine Virtual Machine

Page 36: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

Virtual Machines (Cont.)

Provide complete protection of system resources Each virtual machine is isolated from all other virtual

machines No direct sharing of resources

A perfect vehicle for operating systems research and development Develop an OS on a virtual machine Do not disrupt normal system operation.

Difficult to implement due to the effort required to provide an exact duplicate to the underlying machine

Page 37: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

VMware Architecture

Page 38: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

The Java Virtual Machine

Page 39: Chapter 2: Operating-System Structures.  Operating System Services  User Operating System Interface  System Calls  Types of System Calls  System.

End of Chapter 2

Questions?