Operating-System Structures

22  Download (0)

Full text

(1)

Chapter 2

System Structures

Operating-System Structures

ƒ

Goals: Provide a way to understand an operating systems

ƒ Services

ƒ Interface

ƒ System Components

ƒ

The type of system desired is the

basis for choices among various

(2)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

Operation-System Services

ƒ

Goal:

ƒ Provide an environment for the execution of programs.

ƒ Services are provided to programs and their users.

ƒ

User Interface (UI)

ƒ Command Line Interface, Batch Interface, Graphical User Interface (GUI), etc.

ƒ Interface between the user and the operating system

Operation-System Services

ƒ Friendly UI’s

ƒ Command-line-based interfaces or mused-based window-and-menu interface

ƒ e.g., UNIX shell and command.com in MS-DOS

ƒ

Program Execution

ƒ Loading, running, terminating, etc

Get the next command Execute the command User-friendly?

(3)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

Operation-System Services

ƒ

I/O Operations

ƒ General/special operations for devices:

ƒ Efficiency & protection

ƒ

File-System Manipulation

ƒ Read, write, create, delete, etc.

ƒ Files and Directories

ƒ Permission Management

ƒ

Communications

ƒ Intra-processor or inter-processor communication – shared memory or message passing

Operation-System Services

ƒ

Error Detection

ƒ Possible errors from CPU, memory, devices, user programs Æ Ensure correct & consistent computing

ƒ Resource Allocation

ƒ Utilization & efficiency

ƒ Accounting

ƒ Statistics or Accounting

ƒ Protection & Security

(4)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

User OS Interface – Command Interpreter

ƒ

Two approaches:

ƒ Contain codes to execute commands

ƒ Fast but the interpreter tends to be big!

ƒ Painful in revision!

del cd

User OS Interface – Command Interpreter

ƒ

Implement commands as system programs Æ Search exec files which corresponds to commands (UNIX)

ƒ Issues

a. Parameter Passing

ƒ Potential Hazard: virtual memory b. Being Slow

c. Inconsistent Interpretation of Parameters

(5)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

User OS Interface – GUI

ƒ

Components

ƒ Screen, Icons, Folders, Pointer, etc.

ƒ

History

ƒ Xerox PARC research facility (1970’s)

ƒ Mouse – 1968

ƒ Mac OS – 1980’s

ƒ Windows 1.0 ~ XP

User OS Interface – GUI

ƒ Unix & Linux

ƒ Common Desktop Environment (CDE), X-Windows, K Desktop Environment (KDE), GNOME

ƒ

Trend

ƒ Mixture of GUI and command-line interfaces

ƒ Multimedia, Intelligence, etc.

(6)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

System Calls

ƒ

System calls

ƒ Interface between processes & OS

ƒ

How to make system calls?

ƒ Assemble-language instructions or subroutine/functions calls in high-level language such as C or Perl?

ƒ Generation of in-line instructions or a call to a special run-time routine.

ƒ

Example: read and copy of a file!

ƒ Library Calls vs System Calls

System Calls

ƒ

Application Programming Interface (API)

ƒ Examples: Win 32 API for Windows, POSIX API for POSIX-based

Systems, Java API for Java virtual machines

ƒ Benefits (API vs System Calls)

ƒ Portability

ƒ Ease of Use & Better Functionality

(7)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

System Calls

ƒ

How a system call occurs?

ƒ Types and information

ƒ

Parameter Passing

ƒ Registers

ƒ Registers pointing to blocks

ƒ Linux

ƒ Stacks

x: parameters for call load address x system call 13

x

register

use parameters from table x

Code for System Call 13

System Calls

ƒ

Process Control

ƒ

File Management

ƒ

Device Management

ƒ

Information Maintenance

ƒ

Communications

(8)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

System Calls

ƒ

Process & Job Control

ƒ End (normal exit) or abort (abnormal)

ƒ Error level or no

ƒ Interactive, batch, GUI-supported systems

ƒ Load and execute

ƒ How to return control?

ƒ e.g., shell load & execute commands

ƒ Creation and/or termination of processes

ƒ Multiprogramming?

System Calls

ƒ

Process & Job Control (continued)

ƒ Process Control

ƒ Get or set attributes of processes

ƒ Wait for a specified amount of time or an event

ƒ Signal event

ƒ Memory dumping, profiling, tracing, memory allocation & de-allocation

(9)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

System Calls

ƒ

Examples: MS-DOS & UNIX

kernel command interpreter process free memory

kernel interpreter

process B free memory

process A

System Calls

ƒ

File Management

ƒ Create and delete

ƒ Open and close

ƒ Read, write, and reposition (e.g., rewinding)

ƒ lseek

ƒ Get or set attributes of files

ƒ Operations for directories

(10)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

System Calls

ƒ

Device management

ƒ Physical or virtual devices, e.g., files.

ƒ Request or release

ƒ Open and close of special files

ƒ Files are abstract or virtual devices.

ƒ Read, write, and reposition (e.g., rewinding)

ƒ Get or set file attributes

ƒ Logically attach or detach devices

System Calls

ƒ

Information maintenance

ƒ Get or set date or time

ƒ Get or set system data, such as the amount of free memory

ƒ

Communication

ƒ Message Passing

ƒ Open, close, accept connections

ƒ Host ID or process ID

ƒ Send and receive messages

ƒ Transfer status information

ƒ Shared Memory

ƒ Memory mapping & process synchronization

(11)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

System Calls

ƒ

Shared Memory

ƒ Max Speed & Comm Convenience

ƒ

Message Passing

ƒ No Access Conflict & Easy Implementation

kernel Process A Process B

kernel Process A Process B

Shared Memory

M M M

System Programs

ƒ

Goal:

ƒ Provide a convenient environment for program development and execution

ƒ

Types

ƒ File Management, e.g., rm.

ƒ Status information, e.g., date.

ƒ File Modifications, e.g., editors.

ƒ Program Loading and Executions, e.g., loader.

ƒ Programming Language Supports, e.g.,

(12)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

System Design &

Implementation

ƒ

Design Goals & Specifications:

ƒ User Goals, e.g., ease of use

ƒ System Goals, e.g., reliable

ƒ

Rule 1: Separation of Policy & Mechanism

ƒ Policy:What will be done?

ƒ Mechanism:How to do things?

ƒ Example: timer construct and time slice

ƒ

Two extreme cases:

Microkernel-based OS Macintosh OS

System Design &

Implementation

ƒ

OS Implementation in High-Level Languages

ƒ E.g., UNIX, OS/2, MS NT, etc.

ƒ Advantages:

ƒ Being easy to understand & debug

ƒ Being written fast, more compact, and portable

ƒ Disadvantages:

ƒ Less efficient but more storage for code

* Tracing for bottleneck identification, exploring of excellent algorithms, etc.

(13)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

OS Structure – MS-DOS

ƒ

MS-DOS Layer Structure

Application program

Resident system program

MS-DOS device drivers

ROM BIOS device drivers

OS Structure – UNIX

terminal controller, terminals,

physical memory, device controller, devices such as disks, memory, etc.

CPU scheduling, signal handling, virtual memory, paging, swapping,

file system, disk drivers, caching/buffering, etc.

Shells, compilers, X, application programs, etc.

Kernel interface to the hardware System call interface

useruser user useruser user User user

interface

(14)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

OS Structure

ƒ

A Layered Approach – A Myth

Advantage: Modularity ~ Debugging &

Verification

Difficulty: Appropriate layer definitions, less efficiency due to overheads!

Layer M Layer M-1

hidden ops new

ops

existing ops

OS Structure

ƒ

A Layer Definition Example:

L5 User programs L4 I/O buffering

L3 Operator-console device driver L2 Memory management

L1 CPU scheduling

L0 Hardware

(15)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

OS Structure – OS/2

ƒ

OS/2 Layer Structure

Application Application Application

Subsystem Subsystem Subsystem

Device driver Device driver Device driver Application-program Interface

‧memory management

System kernel ‧task scheduling

‧device management

* Some layers of NT were from user space to kernel space in NT4.0

OS Structure – Microkernels

ƒ

The concept of microkernels was

proposed in CMU in mid 1980s (Mach).

ƒ Moving all nonessential components from the kernel to the user or system programs!

ƒ No consensus on services in kernel

ƒ Mostly on process and memory management and communication

ƒ

Benefits:

ƒ Ease of OS service extensions Æ

(16)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

OS Structure – Microkernels

ƒ

Examples

ƒ Microkernels: True64UNIX (Mach kernel), MacOS X (Mach kernel), QNX (msg passing, proc scheduling, HW interrupts, low-level networking)

ƒ Hybrid structures: Windows NT

kernel

OS/2

Applications OS/2 Server

POSIX

Applications POSIX Server Win32

Applications Win32 Server

OS Structure – Modules

ƒ

A Modular Kernel

ƒ A Set of Core Components

ƒ Dynamic Loadable Modules

ƒ E.g., Solaris: Scheduling Classes, File Systems, Loadable System Calls, Executable Formats, STREAMS Modules, Miscellaneous, Device and Bus Drivers

ƒ Characteristics:

ƒ Layer-Like – Modules

ƒ Microkernel-Like – the Primary Module

(17)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

OS Structure – Modules

ƒ

Example Mac OS X

ƒ Application Environments and Common Services

ƒ BSD: Command Line Interface, Support for Networking and File Systems, an

Implementation of POSIX APIs.

ƒ Mach: Memory Management, Support for Remote Procedure Calls, Interprocess Communication Facilities

ƒ The Kernel Environment: I/O Kit for the Development of Device Drivers and Dynamically Loadable Modules.

Kernel Environment BSD

Mach App. Environ. &

Common Services

Virtual Machine

ƒ

Virtual Machines: provide an interface that is identical to the underlying bare hardware

interface

processes processes processes processes

kernel kernel kernel kernel

VM1 VM2 VM3

(18)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

Virtual Machine

ƒ Implementation Issues:

ƒ Emulation of Physical Devices

ƒ E.g., Disk Systems

ƒ An IBM minidisk approach

ƒ User/Monitor Modes

ƒ (Physical) Monitor Mode

ƒ Virtual machine software

ƒ (Physical) User Mode

ƒ Virtual monitor mode & Virtual user mode

Virtual Machine

virtual user mode virtual monitor mode monitor mode

processes processes processes

kernel 1 kernel 2 kernel 3

virtual machine software hardware

P1/VM1 system call

Trap

Service for the system call

Set program counter

& register contents,

& then restart VM1

Simulate the effect of the I/O instruction

Restart VM1 Finish

service

time

(19)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

Virtual Machine

ƒ Disadvantages:

ƒ Slow!

ƒ Execute most instructions directly on the hardware

ƒ No direct sharing of resources

ƒ Physical devices and communications

* I/O could be slow (interpreted) or fast (spooling)

Virtual Machine

ƒ Advantages:

ƒ Complete Protection – Complete Isolation!

ƒ OS Research & Development

ƒ System Development Time

ƒ Extensions to Multiple Personalities, such as Mach (software emulation)

ƒ Emulations of Machines and OS’s, e.g., Windows over Linux

(20)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

Virtual Machine – VMware

ƒ

VMware – The visualization layer abstracts the physical hardware into isolated virtual

machines running as guest operating systems.

CPU memory I/O devices

Linux/Windows

Guest OS (Windows NT) Virtual OS Virtual memory

Virtual devices applications

Guest OS (free BSD) Virtual OS Virtual memory

Virtual devices applications applications

visualization layer

Virtual Machine – Java

ƒ

Sun Microsystems in late 1995

ƒ Java Language and API Library

ƒ Java Virtual Machine (JVM)

ƒ

Class loader (for bytecode .class files)

ƒ

Class verifier

ƒ

Java interpreter

ƒ An interpreter, a just-in-time (JIT) compiler, hardware

class loader verifier java interpreter

host system

java .class files

(21)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

Virtual Machine – Java

ƒ

JVM

ƒ Garbage collection

ƒ Reclaim unused objects

ƒ Implementation being specific for different systems

ƒ Programs are architecture neutral and portable

class loader verifier java interpreter

host system

java .class files

System Generation

ƒ SYSGEN (System Generation)

ƒ Ask and probe for information concerning the specific configuration of a hardware system

ƒ CPU, memory, device, OS options, etc.

No recompilation Recompilation

& completely Linking of of a modified table-driven modules for source code

selected OS

ƒ

Issues

ƒ Size, Generality, Ease of modification

(22)

* All rights reserved, Tei-Wei Kuo, National Taiwan University, 2005.

System Boot

ƒ

Booting

ƒ The procedure of starting a computer by loading the kernel.

ƒ The bootstrap program or the bootstrap loader

ƒ Firmware being ROM or EEPROM resident

ƒ Boot/system disk with a boot block

Figure

Updating...

References

Related subjects :