38
Operating-System Structures Chapter 2 © 2015 Prof. Amr El-Kadi

Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

  • Upload
    others

  • View
    7

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Operating-System Structures

Chapter 2

© 2015 Prof. Amr El-Kadi

Page 2: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Operating System Services

• One set provides functions that are helpful

to the user:

– User interface

– Program execution

– I/O operations

– File-system manipulation

– Communications

– Error detection

© 2015 Prof. Amr El-Kadi

Page 3: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Operating System Services (Cont.)

• Another set exists for ensuring the efficient operation of the system itself via resource sharing

– Resource allocation

– Accounting

– Protection and security

© 2015 Prof. Amr El-Kadi

Page 4: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

System Programs

• Provide a convenient environment for

program development and execution

• Most users’ view of the operation system

is defined by system programs, not the

actual system calls

• File management - Create, delete, copy,

rename, print, dump, list, and generally

manipulate files and directories

• Status information

© 2015 Prof. Amr El-Kadi

Page 5: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

System Programs (cont.)

• File modification

• Programming-language support

• Program loading and Communications

© 2015 Prof. Amr El-Kadi

Page 6: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

System Calls

• Programming interface to the services

provided by the OS

• Typically written in a high-level language

(C or C++)

• Mostly accessed by programs via a high-

level Application Program Interface

(API) rather than direct system call use

• Win32, POSIX, and Java API

• Why use APIs rather than system calls?

© 2015 Prof. Amr El-Kadi

Page 7: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Example of System Calls

• System call sequence to copy the contents

of one file to another file

© 2015 Prof. Amr El-Kadi

Page 8: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Example of Standard API

• Consider the the Java read()

© 2015 Prof. Amr El-Kadi

Page 9: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

System Call Implementation

• Typically, a number associated with each system call

• 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

© 2015 Prof. Amr El-Kadi

Page 10: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

API – System Call – OS Relationship

© 2015 Prof. Amr El-Kadi

Page 11: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Standard C Library Example

• C program

invoking printf()

library call,

which calls

write() system

call

© 2015 Prof. Amr El-Kadi

Page 12: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

System Call Parameter Passing

• Three general methods used to pass

parameters to the OS– Simplest: pass the parameters in registers

– Parameters stored in a block, or table, in memory,

and address of block passed as a parameter in a

register (Linux & 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

© 2015 Prof. Amr El-Kadi

Page 13: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Types of System Calls

• Process control

• File management

• Device management

• Information maintenance

• Communications

© 2015 Prof. Amr El-Kadi

Page 14: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Operating System Design and

Implementation

• some approaches have proven successful

• Internal structure can vary widely

• Start by defining goals and specifications

• Affected by choice of hardware, type of

system

© 2015 Prof. Amr El-Kadi

Page 15: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Operating System Design and

Implementation (Cont.)

• 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

© 2015 Prof. Amr El-Kadi

Page 16: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Operating System Design and

Implementation (Cont.)

• Important principles 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

allows maximum flexibility if policy decisions

are to be changed later© 2015 Prof. Amr El-Kadi

Page 17: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Simple Structure (no structure)

• Monolithical systems

• Unstructured

• Supervisor call changes

from user mode into

kernel mode

App App

System services

Hardware

OS

procedures

User Mode

Kernel Mode

© 2015 Prof. Amr El-Kadi

Page 18: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

MS-DOS Structure

© 2015 Prof. Amr El-Kadi

Page 19: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Layered Approach

• With modularity, layers are selected such

that each uses functions (operations)

and services of only lower-level layersApplication

Program

Application

Program

Application

Program

System Services

File System

Memory and I/O Device Management

Processor Scheduling

Hardware

User Mode

Kernel Mode

© 2015 Prof. Amr El-Kadi

Page 20: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Layered Operating System

© 2015 Prof. Amr El-Kadi

Page 21: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Structure of the THE operating

system

© 2015 Prof. Amr El-Kadi

Page 22: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

UNIX System Structure

© 2015 Prof. Amr El-Kadi

Page 23: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Microkernel System Structure

• Moves as much from the kernel into “user”

space

• Communication takes place between user

modules using message passing

© 2015 Prof. Amr El-Kadi

Page 24: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Microkernel System Structure (cont.)

• Benefits:– Easier to extend a microkernel

– Easier to port the operating system to new architectures

– More reliable (less code is running in kernel mode)

– More secure

• Determents:– Performance overhead of user space to

kernel space communication

© 2015 Prof. Amr El-Kadi

Page 25: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Microkernel System Structure (cont.)

© 2015 Prof. Amr El-Kadi

Page 26: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Mac OS X Structure

© 2015 Prof. Amr El-Kadi

Page 27: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

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

• Overall, similar to layers but with more

flexible

© 2015 Prof. Amr El-Kadi

Page 28: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Solaris Modular Approach

© 2015 Prof. Amr El-Kadi

Page 29: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Virtual Machines

• A virtual machine 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

© 2015 Prof. Amr El-Kadi

Page 30: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Virtual Machines (Cont.)

• The operating system creates the

illusion of multiple environments,

each executing on its own processor

with its own (virtual) memory

© 2015 Prof. Amr El-Kadi

Page 31: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Virtual Machines (Cont.)

Non-virtual Machine Virtual Machine

© 2015 Prof. Amr El-Kadi

Page 32: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Virtual Machines (Cont.)

• provides complete protection of system

resources. This isolation, however, permits

no direct sharing of resources

• perfect vehicle for operating-systems

research and development

• difficult to implement due to the effort

required to provide an exact duplicate to the

underlying machine

© 2015 Prof. Amr El-Kadi

Page 33: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

VMware Architecture

© 2015 Prof. Amr El-Kadi

Page 34: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Hybrid approaches

• Windows xp

• linux

© 2015 Prof. Amr El-Kadi

Page 35: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Windows xp

© 2015 Prof. Amr El-Kadi

Page 36: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Linux

© 2015 Prof. Amr El-Kadi

Page 37: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

Operating System Generation

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

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

• Booting – starting a computer by loading the kernel

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

© 2015 Prof. Amr El-Kadi

Page 38: Operating-System Structureselkadi/Slides/CSCE 345/CSCE 345 - Chapter 2… · System Boot •Operating system must be made available to hardware so hardware can start it –Small piece

System Boot

• Operating system must be made

available to hardware so hardware can

start it– Small piece of code – bootstrap loader, locates

the kernel, loads it into memory, and starts it

– Sometimes two-step process where boot block

at fixed location loads bootstrap loader

– When power initialized on system, execution

starts at a fixed memory location

• Firmware used to hold initial boot code© 2015 Prof. Amr El-Kadi