70
1 Chapter 2: Operating- Chapter 2: Operating- System Structures System Structures

Chapter 2: Operating-System Structures

  • Upload
    chick

  • View
    39

  • Download
    0

Embed Size (px)

DESCRIPTION

Chapter 2: 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 - PowerPoint PPT Presentation

Citation preview

Page 1: Chapter 2:  Operating-System Structures

11

Chapter 2: Operating-System Chapter 2: Operating-System StructuresStructures

Page 2: Chapter 2:  Operating-System Structures

22

Chapter 2: Operating-System StructuresChapter 2: Operating-System Structures

Operating System ServicesOperating System Services

User Operating System InterfaceUser Operating System Interface

System CallsSystem Calls

Types of System CallsTypes of System Calls

System ProgramsSystem Programs

Operating System Design and ImplementationOperating System Design and Implementation

Operating System StructureOperating System Structure

Virtual MachinesVirtual Machines

Operating System DebuggingOperating System Debugging

Operating System GenerationOperating System Generation

System BootSystem Boot

Page 3: Chapter 2:  Operating-System Structures

33

ObjectivesObjectives

To describe the services an operating system To describe the services an operating system provides to users, processes, and other systemsprovides to users, processes, and other systems

To discuss the various ways of structuring an To discuss the various ways of structuring an operating systemoperating system

To explain how operating systems are installed To explain how operating systems are installed and customized and how they bootand customized and how they boot

Page 4: Chapter 2:  Operating-System Structures

44

Operating System ServicesOperating System Services

Some operating-system services provide functions Some operating-system services provide functions that are helpful to the user:that are helpful to the user: User interfaceUser interface - Almost all operating systems have - Almost all operating systems have

a user interface (UI)a user interface (UI)

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

Program executionProgram execution - The system must be able to - The system must be able to load a program into memory and to run that load a program into memory and to run that program, end execution, either normally or program, end execution, either normally or abnormally (indicating error)abnormally (indicating error)

Page 5: Chapter 2:  Operating-System Structures

55

Operating System ServicesOperating System Services

I/O operationsI/O operations - A running program may - A running program may require I/O, which may involve a file or an I/O require I/O, which may involve a file or an I/O device device

File-system manipulationFile-system manipulation - The file system is - The file system is of particular interest. Obviously, programs of particular interest. Obviously, programs need to read and write files and directories, need to read and write files and directories, create and delete them, search them, list file create and delete them, search them, list file Information, permission management.Information, permission management.

Page 6: Chapter 2:  Operating-System Structures

66

A View of Operating System ServicesA View of Operating System Services

Page 7: Chapter 2:  Operating-System Structures

77

Operating System Services (Cont)Operating System Services (Cont)

Some operating-system services provide functions Some operating-system services provide functions that are helpful to the user (Cont):that are helpful to the user (Cont): CommunicationsCommunications – Processes may exchange – Processes may exchange

information, on the same computer or between information, on the same computer or between computers over a networkcomputers over a network

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

Page 8: Chapter 2:  Operating-System Structures

88

Operating System Services (Cont)Operating System Services (Cont)

Some operating-system services provide Some operating-system services provide functions that are helpful to the user (Cont):functions that are helpful to the user (Cont): Error detectionError detection – OS needs to be constantly – OS needs to be constantly

aware of possible errorsaware of possible errors

May occur in the CPU and memory May occur in the CPU and memory hardware, in I/O devices, in user programhardware, in I/O devices, in user program

For each type of error, OS should take the For each type of error, OS should take the appropriate action to ensure correct and appropriate action to ensure correct and consistent computingconsistent computing

Debugging facilities can greatly enhance Debugging facilities can greatly enhance the user’s and programmer’s abilities to the user’s and programmer’s abilities to efficiently use the systemefficiently use the system

Page 9: Chapter 2:  Operating-System Structures

99

Operating System Services (Cont)Operating System Services (Cont)

Other OS functions exist for ensuring the efficient Other OS functions exist for ensuring the efficient operation of the system itself via resource sharingoperation of the system itself via resource sharing Resource allocationResource allocation - - When multiple users or When multiple users or

multiple jobs running concurrently, resources must multiple jobs running concurrently, resources must be allocated to each of thembe allocated to each of them

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

Page 10: Chapter 2:  Operating-System Structures

1010

Operating System Services (Cont)Operating System Services (Cont)

AccountingAccounting - - To keep track of which users use To keep track of which users use how much and what kinds of computer resourceshow much and what kinds of computer resources

Protection and securityProtection and security - - The owners of The owners of information stored in a multiuser or networked information stored in a multiuser or networked computer system may want to control use of that computer system may want to control use of that information, concurrent processes should not information, concurrent processes should not interfere with each otherinterfere with each other

ProtectionProtection involves ensuring that all access to involves ensuring that all access to system resources is controlledsystem resources is controlled

Page 11: Chapter 2:  Operating-System Structures

1111

Operating System Services (Cont)Operating System Services (Cont)

SecuritySecurity of the system from outsiders of the system from outsiders requires user authentication, extends to requires user authentication, extends to defending external I/O devices from invalid defending external I/O devices from invalid access attemptsaccess attempts

If a system is to be protected and secure, If a system is to be protected and secure, precautions must be instituted throughout precautions must be instituted throughout it. A chain is only as strong as its weakest it. A chain is only as strong as its weakest link.link.

Page 12: Chapter 2:  Operating-System Structures

1212

Chapter 2: Operating-System StructuresChapter 2: Operating-System Structures

Operating System ServicesOperating System Services

User Operating System InterfaceUser Operating System Interface

System CallsSystem Calls

Types of System CallsTypes of System Calls

System ProgramsSystem Programs

Operating System Design and ImplementationOperating System Design and Implementation

Operating System StructureOperating System Structure

Virtual MachinesVirtual Machines

Operating System DebuggingOperating System Debugging

Operating System GenerationOperating System Generation

System BootSystem Boot

Page 13: Chapter 2:  Operating-System Structures

1313

User Operating System Interface - CLIUser Operating System Interface - CLI

Command Line Interface (CLI)Command Line Interface (CLI) or or command interpreter command interpreter allows direct command entryallows direct command entry

Sometimes implemented in kernel, sometimes by Sometimes implemented in kernel, sometimes by systems programsystems program

Sometimes multiple flavors implemented – Sometimes multiple flavors implemented – shellsshells

Primarily fetches a command from user and Primarily fetches a command from user and executes itexecutes it Sometimes commands built-in, sometimes just Sometimes commands built-in, sometimes just

names of programsnames of programs

If the latter, adding new features doesn’t If the latter, adding new features doesn’t require shell modificationrequire shell modification

Page 14: Chapter 2:  Operating-System Structures

1414

User Operating System Interface - GUIUser Operating System Interface - GUI

User-friendly User-friendly desktopdesktop metaphor interface metaphor interface Usually mouse, keyboard, and monitorUsually mouse, keyboard, and monitor IconsIcons represent files, programs, actions, etc represent files, programs, actions, etc Various mouse buttons over objects in the Various mouse buttons over objects in the

interface cause various actions (provide interface cause various actions (provide information, options, execute function, open information, options, execute function, open directory (known as a directory (known as a folderfolder))

Invented at Xerox PARCInvented at Xerox PARC

Page 15: Chapter 2:  Operating-System Structures

1515

User Operating System Interface - GUIUser Operating System Interface - GUI

Many systems now include both CLI and GUI Many systems now include both CLI and GUI interfacesinterfaces Microsoft Windows is GUI with CLI Microsoft Windows is GUI with CLI

“command” shell“command” shell Apple Mac OS X as “Aqua” GUI interface with Apple Mac OS X as “Aqua” GUI interface with

UNIX kernel underneath and shells availableUNIX kernel underneath and shells available Solaris is CLI with optional GUI interfaces Solaris is CLI with optional GUI interfaces

(Java Desktop, KDE)(Java Desktop, KDE)

Page 16: Chapter 2:  Operating-System Structures

1616

Bourne Shell Command InterpreterBourne Shell Command Interpreter

Page 17: Chapter 2:  Operating-System Structures

1717

The Mac OS X GUIThe Mac OS X GUI

Page 18: Chapter 2:  Operating-System Structures

1818

Chapter 2: Operating-System StructuresChapter 2: Operating-System Structures

Operating System ServicesOperating System Services

User Operating System InterfaceUser Operating System Interface

System CallsSystem Calls

Types of System CallsTypes of System Calls

System ProgramsSystem Programs

Operating System Design and ImplementationOperating System Design and Implementation

Operating System StructureOperating System Structure

Virtual MachinesVirtual Machines

Operating System DebuggingOperating System Debugging

Operating System GenerationOperating System Generation

System BootSystem Boot

Page 19: Chapter 2:  Operating-System Structures

1919

System CallsSystem Calls

Programming interface to the services provided by the OSProgramming interface to the services provided by the OS

Typically written in a high-level language (C or C++)Typically written in a high-level language (C or C++)

Mostly accessed by programs via a high-level Mostly accessed by programs via a high-level Application Application Program Interface (API) Program Interface (API) rather than direct system call userather than direct system call use

Three most common APIs are Win32 API for Windows, POSIX Three most common APIs are Win32 API for Windows, POSIX API for POSIX-based systems (including virtually all versions API for POSIX-based systems (including virtually all versions of UNIX, Linux, and Mac OS X), and Java API for the Java of UNIX, Linux, and Mac OS X), and Java API for the Java virtual machine (JVM)virtual machine (JVM)

Why use APIs rather than system calls?Why use APIs rather than system calls?

(Note that the system-call names used throughout this text are (Note that the system-call names used throughout this text are generic)generic)

Page 20: Chapter 2:  Operating-System Structures

2020

Example of System CallsExample of System Calls

System call sequence to copy the contents of System call sequence to copy the contents of one file to another fileone file to another file

Page 21: Chapter 2:  Operating-System Structures

2121

Example of Standard APIExample of Standard API

Consider the ReadFile() function in theConsider the ReadFile() function in theWin32 API—a function for reading from a fileWin32 API—a function for reading from a file

Page 22: Chapter 2:  Operating-System Structures

2222

Example of Standard APIExample of Standard API

A description of the parameters passed to ReadFile()A description of the parameters passed to ReadFile()HANDLE file—the file to be readHANDLE file—the file to be readLPVOID buffer—a buffer where the data will be read LPVOID buffer—a buffer where the data will be read

into and written frominto and written fromDWORD bytesToRead—the number of bytes to be read DWORD bytesToRead—the number of bytes to be read

into the bufferinto the bufferLPDWORD bytesRead—the number of bytes read LPDWORD bytesRead—the number of bytes read

during the last readduring the last readLPOVERLAPPED ovl—indicates if overlapped I/O is LPOVERLAPPED ovl—indicates if overlapped I/O is

being usedbeing used

Page 23: Chapter 2:  Operating-System Structures

2323

System Call ImplementationSystem Call Implementation

Typically, a number associated with each system callTypically, a number associated with each system call System-call interface maintains a table indexed System-call interface maintains a table indexed

according to these numbersaccording to these numbers

The system call interface invokes intended system call The system call interface invokes intended system call in OS kernel and returns status of the system call and in OS kernel and returns status of the system call and any return valuesany return values

Page 24: Chapter 2:  Operating-System Structures

2424

System Call ImplementationSystem Call Implementation

The caller need know nothing about how the The caller need know nothing about how the system call is implementedsystem call is implemented Just needs to obey API and understand what Just needs to obey API and understand what

OS will do as a result callOS will do as a result call Most details of OS interface hidden from Most details of OS interface hidden from

programmer by API programmer by API

Managed by run-time support library (set of Managed by run-time support library (set of functions built into libraries included with functions built into libraries included with compiler)compiler)

Page 25: Chapter 2:  Operating-System Structures

2525

API – System Call – OS RelationshipAPI – System Call – OS Relationship

Page 26: Chapter 2:  Operating-System Structures

2626

Standard C Library ExampleStandard C Library Example

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

Page 27: Chapter 2:  Operating-System Structures

2727

System Call Parameter PassingSystem Call Parameter Passing

Often, more information is required than simply Often, more information is required than simply identity of desired system callidentity of desired system call Exact type and amount of information vary Exact type and amount of information vary

according to OS and callaccording to OS and callThree general methods used to pass parameters to Three general methods used to pass parameters to the OSthe OS Simplest: pass the parameters in Simplest: pass the parameters in registersregisters

In some cases, may be more parameters than In some cases, may be more parameters than registersregisters

Page 28: Chapter 2:  Operating-System Structures

2828

System Call Parameter PassingSystem Call Parameter Passing

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

This approach taken by Linux and SolarisThis approach taken by Linux and Solaris Parameters placed, or Parameters placed, or pushed, pushed, onto the onto the stack stack

by the program and by the program and popped popped off the stack by off the stack by the operating systemthe operating system

Block and stack methods do not limit the Block and stack methods do not limit the number or length of parameters being passednumber or length of parameters being passed

Page 29: Chapter 2:  Operating-System Structures

2929

Parameter Passing via TableParameter Passing via Table

Page 30: Chapter 2:  Operating-System Structures

3030

Chapter 2: Operating-System StructuresChapter 2: Operating-System Structures

Operating System ServicesOperating System Services

User Operating System InterfaceUser Operating System Interface

System CallsSystem Calls

Types of System CallsTypes of System Calls

System ProgramsSystem Programs

Operating System Design and ImplementationOperating System Design and Implementation

Operating System StructureOperating System Structure

Virtual MachinesVirtual Machines

Operating System DebuggingOperating System Debugging

Operating System GenerationOperating System Generation

System BootSystem Boot

Page 31: Chapter 2:  Operating-System Structures

3131

Types of System CallsTypes of System Calls

Process controlProcess control

File managementFile management

Device managementDevice management

Information maintenanceInformation maintenance

CommunicationsCommunications

ProtectionProtection

Page 32: Chapter 2:  Operating-System Structures

3232

Examples of Windows and Unix System CallsExamples of Windows and Unix System Calls

Page 33: Chapter 2:  Operating-System Structures

3333

MS-DOS ExecutionMS-DOS Execution

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

Page 34: Chapter 2:  Operating-System Structures

3434

FreeBSD Running Multiple ProgramsFreeBSD Running Multiple Programs

Page 35: Chapter 2:  Operating-System Structures

3535

Chapter 2: Operating-System StructuresChapter 2: Operating-System Structures

Operating System ServicesOperating System Services

User Operating System InterfaceUser Operating System Interface

System CallsSystem Calls

Types of System CallsTypes of System Calls

System ProgramsSystem Programs

Operating System Design and ImplementationOperating System Design and Implementation

Operating System StructureOperating System Structure

Virtual MachinesVirtual Machines

Operating System DebuggingOperating System Debugging

Operating System GenerationOperating System Generation

System BootSystem Boot

Page 36: Chapter 2:  Operating-System Structures

3636

System ProgramsSystem Programs

System programs provide a convenient environment for System programs provide a convenient environment for program development and execution. The can be divided program development and execution. The can be divided into categories:into categories: File manipulation File manipulation Status informationStatus information File modificationFile modification Programming language supportProgramming language support Program loading and executionProgram loading and execution CommunicationsCommunications Application programsApplication programs

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

Page 37: Chapter 2:  Operating-System Structures

3737

System ProgramsSystem Programs

Provide a convenient environment for program development Provide a convenient environment for program development and executionand execution Some of them are simply user interfaces to system calls; Some of them are simply user interfaces to system calls;

others are considerably more complexothers are considerably more complex

File managementFile management - Create, delete, copy, rename, print, - Create, delete, copy, rename, print, dump, list, and generally manipulate files and directoriesdump, list, and generally manipulate files and directories

Status informationStatus information Some ask the system for info - date, time, amount of Some ask the system for info - date, time, amount of

available memory, disk space, number of usersavailable memory, disk space, number of users Others provide detailed performance, logging, and Others provide detailed performance, logging, and

debugging informationdebugging information

Page 38: Chapter 2:  Operating-System Structures

3838

System Programs (cont’d)System Programs (cont’d) Typically, these status information programs format Typically, these status information programs format

and print the output to the terminal or other output and print the output to the terminal or other output devicesdevices

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

File modificationFile modification Text editors to create and modify filesText editors to create and modify files Special commands to search contents of files or Special commands to search contents of files or

perform transformations of the textperform transformations of the textProgramming-language supportProgramming-language support - Compilers, - Compilers, assemblers, debuggers and interpreters sometimes assemblers, debuggers and interpreters sometimes providedprovided

Page 39: Chapter 2:  Operating-System Structures

3939

System Programs (cont’d)System Programs (cont’d)

Program loading and execution-Program loading and execution- Absolute loaders, Absolute loaders, relocatable loaders, linkage editors, and overlay-relocatable loaders, linkage editors, and overlay-loaders, debugging systems for higher-level and loaders, debugging systems for higher-level and machine languagemachine language

CommunicationsCommunications - Provide the mechanism for - Provide the mechanism for creating virtual connections among processes, creating virtual connections among processes, users, and computer systemsusers, and computer systems Allow users to send messages to one another’s Allow users to send messages to one another’s

screens, browse web pages, send electronic-mail screens, browse web pages, send electronic-mail messages, log in remotely, transfer files from one messages, log in remotely, transfer files from one machine to anothermachine to another

Page 40: Chapter 2:  Operating-System Structures

4040

Chapter 2: Operating-System StructuresChapter 2: Operating-System Structures

Operating System ServicesOperating System Services

User Operating System InterfaceUser Operating System Interface

System CallsSystem Calls

Types of System CallsTypes of System Calls

System ProgramsSystem Programs

Operating System Design and ImplementationOperating System Design and Implementation

Operating System StructureOperating System Structure

Virtual MachinesVirtual Machines

Operating System DebuggingOperating System Debugging

Operating System GenerationOperating System Generation

System BootSystem Boot

Page 41: Chapter 2:  Operating-System Structures

4141

Operating System Design and ImplementationOperating System Design and Implementation

Various approaches have proven successful for designing Various approaches have proven successful for designing and implementing an OSand implementing an OS

The internal structure of different Operating Systems can The internal structure of different Operating Systems can vary widelyvary widely

Start by defining goals and specifications Start by defining goals and specifications

Affected by choice of hardware, type of systemAffected by choice of hardware, type of system User goals – operating system should be convenient to User goals – operating system should be convenient to

use, easy to learn, reliable, safe, and fastuse, easy to learn, reliable, safe, and fast System goals – operating system should be easy to System goals – operating system should be easy to

design, implement, and maintain, as well as flexible, design, implement, and maintain, as well as flexible, reliable, error-free, and efficientreliable, error-free, and efficient

Page 42: Chapter 2:  Operating-System Structures

4242

Operating System Design and Operating System Design and Implementation (Cont)Implementation (Cont)

Important principle to separateImportant principle to separate

Policy: Policy: What will be done?What will be done? Mechanism: Mechanism: How to do it?How to do it?

Mechanisms determine how to do something, Mechanisms determine how to do something, policies decide what will be donepolicies decide what will be done The separation of policy from mechanism is a The separation of policy from mechanism is a

very important principle, it allows maximum very important principle, it allows maximum flexibility if policy decisions are to be changed flexibility if policy decisions are to be changed laterlater

Page 43: Chapter 2:  Operating-System Structures

4343

Chapter 2: Operating-System StructuresChapter 2: Operating-System Structures

Operating System ServicesOperating System Services

User Operating System InterfaceUser Operating System Interface

System CallsSystem Calls

Types of System CallsTypes of System Calls

System ProgramsSystem Programs

Operating System Design and ImplementationOperating System Design and Implementation

Operating System StructureOperating System Structure

Virtual MachinesVirtual Machines

Operating System DebuggingOperating System Debugging

Operating System GenerationOperating System Generation

System BootSystem Boot

Page 44: Chapter 2:  Operating-System Structures

4444

Simple Structure Simple Structure

MS-DOS – written to provide the most MS-DOS – written to provide the most functionality in the least spacefunctionality in the least space Not divided into modulesNot divided into modules Although MS-DOS has some structure, its Although MS-DOS has some structure, its

interfaces and levels of functionality are not interfaces and levels of functionality are not well separatedwell separated

Page 45: Chapter 2:  Operating-System Structures

4545

MS-DOS Layer StructureMS-DOS Layer Structure

Page 46: Chapter 2:  Operating-System Structures

4646

Layered ApproachLayered Approach

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

With modularity, layers are selected such that With modularity, layers are selected such that each uses functions (operations) and services of each uses functions (operations) and services of only lower-level layersonly lower-level layers

Page 47: Chapter 2:  Operating-System Structures

4747

Traditional UNIX System StructureTraditional UNIX System Structure

Page 48: Chapter 2:  Operating-System Structures

4848

UNIXUNIX

UNIX – limited by hardware functionality, the original UNIX – limited by hardware functionality, the original UNIX operating system had limited structuring. The UNIX operating system had limited structuring. The UNIX OS consists of two separable partsUNIX OS consists of two separable parts Systems programsSystems programs The The kernelkernel

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

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

Page 49: Chapter 2:  Operating-System Structures

4949

Layered Operating SystemLayered Operating System

Page 50: Chapter 2:  Operating-System Structures

5050

Microkernel System Structure Microkernel System Structure

Moves as much from the kernel into “Moves as much from the kernel into “useruser” space” space

Communication takes place between user modules using Communication takes place between user modules using message passingmessage passing

Benefits:Benefits: Easier to extend a microkernelEasier to extend a microkernel Easier to port the operating system to new architecturesEasier to port the operating system to new architectures More reliable (less code is running in kernel mode)More reliable (less code is running in kernel mode) More secureMore secure

Detriments:Detriments: Performance overhead of user space to kernel space Performance overhead of user space to kernel space

communicationcommunication

Page 51: Chapter 2:  Operating-System Structures

5151

Mac OS X StructureMac OS X Structure

Page 52: Chapter 2:  Operating-System Structures

5252

ModulesModules

Most modern operating systems implement Most modern operating systems implement kernel moduleskernel modules Uses object-oriented approachUses object-oriented approach Each core component is separateEach core component is separate Each talks to the others over known interfacesEach talks to the others over known interfaces Each is loadable as needed within the kernelEach is loadable as needed within the kernel

Overall, similar to layers but with more flexibleOverall, similar to layers but with more flexible

Page 53: Chapter 2:  Operating-System Structures

5353

Solaris Modular ApproachSolaris Modular Approach

Page 54: Chapter 2:  Operating-System Structures

5454

Chapter 2: Operating-System StructuresChapter 2: Operating-System Structures

Operating System ServicesOperating System Services

User Operating System InterfaceUser Operating System Interface

System CallsSystem Calls

Types of System CallsTypes of System Calls

System ProgramsSystem Programs

Operating System Design and ImplementationOperating System Design and Implementation

Operating System StructureOperating System Structure

Virtual MachinesVirtual Machines

Operating System DebuggingOperating System Debugging

Operating System GenerationOperating System Generation

System BootSystem Boot

Page 55: Chapter 2:  Operating-System Structures

5555

Virtual MachinesVirtual Machines

A A virtual machine virtual machine takes the layered approach to its takes the layered approach to its logical conclusion. It treats hardware and the logical conclusion. It treats hardware and the operating system kernel as though they were all operating system kernel as though they were all hardwarehardware

A virtual machine provides an interface A virtual machine provides an interface identicalidentical to the to the underlying bare hardwareunderlying bare hardware

The operating system The operating system host host creates the illusion that a creates the illusion that a process has its own processor and (virtual memory)process has its own processor and (virtual memory)

Each Each guest guest provided with a (virtual) copy of underlying provided with a (virtual) copy of underlying computercomputer

Page 56: Chapter 2:  Operating-System Structures

5656

Virtual Machines History and BenefitsVirtual Machines History and BenefitsFirst appeared commercially in IBM mainframes in '72 First appeared commercially in IBM mainframes in '72

Fundamentally, multiple execution environments (different Fundamentally, multiple execution environments (different OS) can share the same hardwareOS) can share the same hardware

Protect from each otherProtect from each other

Some sharing of file can be permitted, controlledSome sharing of file can be permitted, controlled

Commutate with each other, other physical systems via Commutate with each other, other physical systems via networkingnetworking

Useful for development, testingUseful for development, testing

Consolidation Consolidation of many low-resource use systems onto of many low-resource use systems onto fewer busier systemsfewer busier systems

““Open Virtual Machine Format”, standard format of virtual Open Virtual Machine Format”, standard format of virtual machines, allows a VM to run within many different virtual machines, allows a VM to run within many different virtual machine (host) platformsmachine (host) platforms

Page 57: Chapter 2:  Operating-System Structures

5757

Virtual Machines (Cont)Virtual Machines (Cont)

(a) Nonvirtual machine (b) virtual machine(a) Nonvirtual machine (b) virtual machine

Non-virtual Machine Virtual Machine

Page 58: Chapter 2:  Operating-System Structures

5858

Para-virtualizationPara-virtualization

Presents guest with system similar but not Presents guest with system similar but not identical to hardwareidentical to hardware

Guest must be modified to run on paravirtualized Guest must be modified to run on paravirtualized hardwareFhardwareF

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

Page 59: Chapter 2:  Operating-System Structures

5959

Solaris 10 with Two ContainersSolaris 10 with Two Containers

Page 60: Chapter 2:  Operating-System Structures

6060

VMware ArchitectureVMware Architecture

Page 61: Chapter 2:  Operating-System Structures

6161

The Java Virtual MachineThe Java Virtual Machine

Page 62: Chapter 2:  Operating-System Structures

6262

Chapter 2: Operating-System StructuresChapter 2: Operating-System Structures

Operating System ServicesOperating System Services

User Operating System InterfaceUser Operating System Interface

System CallsSystem Calls

Types of System CallsTypes of System Calls

System ProgramsSystem Programs

Operating System Design and ImplementationOperating System Design and Implementation

Operating System StructureOperating System Structure

Virtual MachinesVirtual Machines

Operating System DebuggingOperating System Debugging

Operating System GenerationOperating System Generation

System BootSystem Boot

Page 63: Chapter 2:  Operating-System Structures

6363

Operating-System DebuggingOperating-System Debugging

Debugging is finding and fixing errors, or bugs

OSes generate log files containing error information

Failure of an application can generate core dump file capturing memory of the process

Operating system failure can generate crash dump file containing kernel memory

Beyond crashes, performance tuning can optimize system performance

Page 64: Chapter 2:  Operating-System Structures

6464

Operating-System DebuggingOperating-System Debugging

Kernighan’s Law: “Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.”

DTrace tool in Solaris, FreeBSD, Mac OS X allows live instrumentation on production systems Probes fire when code is executed, capturing

state data and sending it to consumers of those probes

Page 65: Chapter 2:  Operating-System Structures

6565

Solaris 10 dtrace Following System CallSolaris 10 dtrace Following System Call

Page 66: Chapter 2:  Operating-System Structures

6666

Chapter 2: Operating-System StructuresChapter 2: Operating-System Structures

Operating System ServicesOperating System Services

User Operating System InterfaceUser Operating System Interface

System CallsSystem Calls

Types of System CallsTypes of System Calls

System ProgramsSystem Programs

Operating System Design and ImplementationOperating System Design and Implementation

Operating System StructureOperating System Structure

Virtual MachinesVirtual Machines

Operating System DebuggingOperating System Debugging

Operating System GenerationOperating System Generation

System BootSystem Boot

Page 67: Chapter 2:  Operating-System Structures

6767

Operating System GenerationOperating System Generation

Operating systems are designed to run on any of a Operating systems are designed to run on any of a class of machines; the system must be configured class of machines; the system must be configured for each specific computer sitefor each specific computer site

SYSGEN program obtains information concerning SYSGEN program obtains information concerning the specific configuration of the hardware systemthe specific configuration of the hardware system

BootingBooting – starting a computer by loading the kernel– starting a computer by loading the kernel

Bootstrap programBootstrap program – code stored in ROM that is – code stored in ROM that is able to locate the kernel, load it into memory, and able to locate the kernel, load it into memory, and start its executionstart its execution

Page 68: Chapter 2:  Operating-System Structures

6868

Chapter 2: Operating-System StructuresChapter 2: Operating-System Structures

Operating System ServicesOperating System Services

User Operating System InterfaceUser Operating System Interface

System CallsSystem Calls

Types of System CallsTypes of System Calls

System ProgramsSystem Programs

Operating System Design and ImplementationOperating System Design and Implementation

Operating System StructureOperating System Structure

Virtual MachinesVirtual Machines

Operating System DebuggingOperating System Debugging

Operating System GenerationOperating System Generation

System BootSystem Boot

Page 69: Chapter 2:  Operating-System Structures

6969

System BootSystem Boot

Operating system must be made available to Operating system must be made available to hardware so hardware can start ithardware so hardware can start it Small piece of code – Small piece of code – bootstrap loaderbootstrap loader, ,

locates the kernel, loads it into memory, and locates the kernel, loads it into memory, and starts itstarts it

Sometimes two-step process where Sometimes two-step process where boot boot blockblock at fixed location loads bootstrap loader at fixed location loads bootstrap loader

When power initialized on system, execution When power initialized on system, execution starts at a fixed memory locationstarts at a fixed memory location

Firmware used to hold initial boot codeFirmware used to hold initial boot code

Page 70: Chapter 2:  Operating-System Structures

7070

End of Chapter 2End of Chapter 2