You are on page 1of 34

ADVANCED

OPERATING SYSTEM

Đỗ Đức Minh Quân

Sept-2013

CE108

WHAT IS AN OPERATING

SYSTEM?

What is an Operating System?

Users People, machines, other computers

 
     Operating system goals:
 

Operating system goals:

Execute user programs

 

and make solving user

problems easier

Operating system

Make the computer

     

system convenient to use

 

Computer

 

hardware

 

Use the computer hardware in an efficient manner

 

What is an Operating System?

Users

Controls and coordinates use of hardware among various applications and users

use of hardware among various applications and users Operating system Computer hardware CPU Memory I/O devices
Operating system Computer hardware
Operating system
Computer
hardware

CPU

Memory

I/O devices

Computer System Structure

User User 1 2 Compiler Web
User
User
1
2
Compiler
Web
User 3
User
3

Text editor

Operating system

Computer

hardware

User n Database
User
n
Database

system

Computer System Structure

User 1
User
1
User 2
User
2
User 3
User
3

User n
User
n

Compiler

Web

Text editor

Database

system

System and application programs

Operating system

Computer

hardware

Operating systems provide an environment for execution of programs and services to programs and users

OPERATING SYSTEM

SERVICES

A View of Operating System Services

User and other system programs

Operating system

Hardware

A View of Operating System Services

User and other system programs

User interfaces

System calls

Services

Operating system

Hardware

A View of Operating System Services

User and other system programs

GUI

batch

Command line

User interfaces

System calls

Services

Operating system

Hardware

A View of Operating System Services

User and other system programs

GUI

batch

Command line

User interfaces

System calls

Services

Operating system

Hardware

API System Call OS Relationship

API – System Call – OS Relationship

Standard C Library Example

C program invoking printf() library call, which

calls write() system call

Standard C Library Example  C program invoking printf() library call, which calls write() system call

A View of Operating System Services

User and other system programs

GUI

batch

Command line

User interfaces

System calls

program

execution

I/O

operations

error

detection

file systems

communication

Services

resource

allocation

accounting

protection

and security

Operating system

Hardware

OPERATING SYSTEM

STRUCTURE

Simple Structure

i.e. 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

into modules  Although MS-DOS has some structure, its interfaces and levels of functionality are not

UNIX

UNIX limited by hardware functionality, the

original UNIX operating system had limited

structuring. The UNIX OS consists of two separable parts

Systems programs The kernel

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

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

Traditional UNIX System Structure

Beyond simple but not fully layered

Traditional UNIX System Structure Beyond simple but not fully layered

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

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

Microkernel System Structure

Moves as much from the kernel into user space

Mach example of microkernel

Mac OS X kernel (Darwin) partly based on Mach

Communication takes place between user modules using message passing

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

Detriments:

Performance overhead of user space to kernel space communication

Microkernel System Structure

Application File Device Program System Driver
Application
File
Device
Program
System
Driver
messages messages memory CPU Interprocess managment scheduling Communication microkernel
messages
messages
memory
CPU
Interprocess
managment
scheduling
Communication
microkernel
hardware
hardware

user

mode

kernel

mode

Modules

Most modern operating systems implement loadable

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

Linux, Solaris, etc

Solaris Modular Approach

Solaris Modular Approach

Hybrid Systems

Most modern operating systems actually not one pure

model

Hybrid combines multiple approaches to address performance, security, usability needs

Linux and Solaris kernels in kernel address space, so

monolithic, plus modular for dynamic loading of functionality

Windows mostly monolithic, plus microkernel for different subsystem personalities

Apple Mac OS X hybrid, layered, Aqua UI plus Cocoa programming environment

Below is kernel consisting of Mach microkernel and BSD Unix parts, plus I/O kit and dynamically loadable modules (called kernel extensions)

Mac OS X Structure

graphical user interface Aqua application environments and services Java Cocoa Quicktime BSD
graphical user interface
Aqua
application environments and services
Java
Cocoa
Quicktime
BSD
kernel environment BSD Mach I/O kit kernel extensions
kernel environment
BSD
Mach
I/O kit
kernel extensions

iOS

Apple mobile OS for iPhone , iPad

Structured on Mac OS X, added functionality

Does not run OS X applications natively Also runs on different CPU architecture (ARM vs. Intel)

Cocoa Touch Objective-C API for developing apps

Media services layer for graphics, audio, video

Core services provides cloud computing, databases

Core operating system, based on Mac OS X kernel

audio, video  Core services provides cloud computing, databases  Core operating system, based on Mac
audio, video  Core services provides cloud computing, databases  Core operating system, based on Mac
audio, video  Core services provides cloud computing, databases  Core operating system, based on Mac
audio, video  Core services provides cloud computing, databases  Core operating system, based on Mac

Android

Developed by Open Handset Alliance (mostly Google)

Open Source

Similar stack to IOS

Based on Linux kernel but modified

Provides process, memory, device-driver management

Adds power management

Runtime environment includes core set of libraries and Dalvik virtual machine

Apps developed in Java plus Android API

Java class files compiled to Java bytecode then

translated to executable than runs in Dalvik VM

Libraries include frameworks for web browser

(webkit), database (SQLite), multimedia, smaller

libc

Android Architecture

Application Framework

Libraries SQLite openGL surface media manager framework webkit libc
Libraries
SQLite
openGL
surface
media
manager
framework
webkit
libc
Android runtime Core Libraries Dalvik virtual machine
Android runtime
Core Libraries
Dalvik
virtual machine

OPERATING SYSTEM &

TECHNOLOGY

Technology Changes

 

Mid-1980’s

2012

Change

CPU speed

15 MHz

2.5 GHz

167x

Memory size

8 MB

4 GB

500x

Disk capacity

30 MB

500 GB

16667x

Disk transfer rate

2 MB/s

100 MB/s

50x

Network speed

10 Mb/s

1 Gb/s

100x

Courtesy of John Ousterhout - CS 140 Lecture Notes http://www.stanford.edu/class/cs140/cgi-bin/index.php

Role of Paging

 

1960’s

Today

Change

Disk latency

80 ms

10 ms

8x

Disk transfer rate

250 KB/s

100 MB/s

400x

Memory size

256 KB

4 GB

16000x

Time to replace all of

6.4 s

3 hours

1500x

memory (random)

Time to replace all of memory (sequential)

1 s

40 s

40x

Can’t afford to page out unless idle for a long time

Courtesy of John Ousterhout - CS 140 Lecture Notes http://www.stanford.edu/class/cs140/cgi-bin/index.php

Role of Disks

Disk access rate not keeping up with capacity:

 

Mid-1980’s

2009

Change

Disk capacity

30 MB

500 GB

16667x

Max. transfer rate

2 MB/s

100 MB/s

50x

Latency (seek & rotate)

20 ms

10 ms

2x

Disks must become more archival

Frequently accessed information must be stored elsewhere (flash? DRAM?)

Courtesy of John Ousterhout - CS 140 Lecture Notes http://www.stanford.edu/class/cs140/cgi-bin/index.php

Multicores

For many years, chip technology improvements

allowed processor clock rates to improve rapidly.

Unfortunately, faster clock rates mean more power dissipation; power limitations now limit improvements in clock rate.

Chip designers are now using technology to put more processors (cores) on a chip.

Consequences:

All OSes must now be multiprocessor OSes

Not clear how to utilize all of these cores: app developers must now write parallel programs?

Writing parallel programs is very hard

Current hot areas for OS development

Very small (devices)

Android, iPhone, etc.

Very large (datacenters)

Coordinating thousands of machines working together