Top Banner
K. Salah Advanced Operating Systems 1 Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems Distributed Systems Real -Time Systems System Calls and APIs
31

Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

Dec 21, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems1

Module 1: Introduction

• What is an operating system?

• Multiprogramming Systems

• Time-Sharing Systems

• Parallel Systems

• Distributed Systems

• Real -Time Systems

• System Calls and APIs

Page 2: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems2

What is an Operating System?

• A program that acts as an intermediary between a user of a computer and the computer hardware.

• Operating system goals:

– Execute user programs and make solving user problems easier.

– Make the computer system convenient to use.

• Use the computer hardware in an efficient manner.

Page 3: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems3

Computer System Components

1. Hardware – provides basic computing resources (CPU, memory, I/O devices).

2. Operating system – controls and coordinates the use of the hardware among the various application programs for the various users.

3. Applications programs – define the ways in which the system resources are used to solve the computing problems of the users (compilers, database systems, video games, business programs).

4. Users (people, machines, other computers).

Page 4: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems4

Abstract View of System Components

Page 5: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems5

Multiprogramming and Timesharing

• Multiprogramming: CPU is multiplexed (shared) among a number of jobs -- while one job waiting for I/O, another can use CPU.

• Advantages:

– CPU is kept busy.

• Disadvantages:

– Hardware and O.S. became significantly more complex for handling and scheduling multiple jobs.

• Timesharing: switch CPU among jobs for pre-defined time interval.

• Most O.S. issues arise from trying to support multiprogramming -- CPU scheduling, deadlock, protection, memory management, virtual memory, etc.

Page 6: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems6

Why need multiprogramming? I/O Times vs. CPU times

• 400 MHz Pentium II = 400 million cycles/second

• 10 cycles/instruction = 40 million instructions/second

• Read 1 disk block = 20 msec

• CPU can do (40 x 106) / 103= 40,000 instructions/msec

• Thus:

• In time to read one disk block, CPU can do 20 * 40,000 = 800,000 instructions !!

Page 7: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems7

Parallel Systems

• Multiprocessor systems with more than one CPU in close communication.

• Tightly coupled system – processors share memory and a clock; communication usually takes place through the shared memory.

• Advantages of parallel system:

– Increased throughput

– Economical

– Increased reliability graceful degradation or fault-tolerant

– The ability to continue providing service proportional to the level of surviving hardware.

Page 8: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems8

Parallel Systems (Cont.)

• Symmetric multiprocessing (SMP)

– Each processor runs an identical copy of the operating system.

– Many processes can run at once without performance deterioration.

– Most modern operating systems support SMP

• Asymmetric multiprocessing

– Each processor is assigned a specific task; master processor schedules and allocates work to slave processors.

– More common in extremely large systems

– Also used in PS/3 and Sbox PS/3 has 8 CPUs with one CPU acting as a master

Page 9: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems9

Symmetric Multiprocessing Architecture

Page 10: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems10

Distributed Systems

• Distribute the computation among several physical processors.

• Loosely coupled system – each processor has its own local memory; processors communicate with one another through various communications lines, such as high-speed buses or telephone lines.

• Advantages of distributed systems.

– Resource sharing sharing and printing files at remote sites processing information in a distributed database using remote specialized hardware devices

– Computation speedup – load sharing

– Reliability – detect and recover from site failure, function transfer, reintegrate failed site

– Communication – message passing

Page 11: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems11

Network vs. Distributed OS

• Network OS– A configuration in which there is a network of application machines, typically a workstations

with multiple server machines.– Server machines can be file servers, printer servers, mail, etc.– Each computer has its own OS. The user must be aware that there are multiple

independent machine and must deal with them explicitly.– NW OS allows machines to interact with each other by having a common communication

architecture.

• Distributed OS– A common OS shared by a network of computers– Offers the illusion of a unified system image, i.e. single system image

i.e, a pool of interconnected computers appears as a single unified computing resource– can say that these machines have a Single System Image (SSI) [Buyya vol.1, 1999].

– It provides the user with transparent access to the resources of multiple machines

– Therefore: less autonomy between computers gives the impression there is a single operating system controlling the network.

– Research vehicle– Examples: Bell Labs Inferno & Plan 9, Mach, Amobea by Tanenbaum, Chorus by CMU

Page 12: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems12

Computing Architectures

• Vector Computers (VC) - proprietary system:– provided the breakthrough needed for the emergence of

computational science, buy they were only a partial answer.

• Massively Parallel Processors (MPP) -proprietary systems:– high cost and a low performance/price ratio.

• Symmetric Multiprocessors (SMP):– suffers from scalability

• Distributed Systems:– difficult to use and hard to extract parallel performance.

• Clusters - gaining popularity:– High Performance Computing - Commodity Supercomputing– High Availability Computing - Mission Critical Applications

• Grid Computing

• Cloud Computing

Page 13: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems13

Cloud Computing

•http://www.youtube.com/watch?v=8RMWO9JxZjA & http://www.youtube.com/watch?v=hplXnFUlPmg&feature=fvw •beta.cloudos.com •eyeos.info & eyeos.mobi (has and an internet browser)•oos.cc

Page 14: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems14

Scalability vs. SSI

Page 15: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems15

Real-Time Systems

• Often used as a control device in a dedicated application such as controlling scientific experiments, medical imaging systems, industrial control systems, and some display systems.

• Well-defined fixed-time constraints.

• Hard real-time system. Deadline support

– Secondary storage limited or absent, data stored in short-term memory, or read-only memory (ROM)

– Conflicts with time-sharing systems, not supported by general-purpose operating systems.

• Soft real-time system. No deadline support

– Limited utility in industrial control or robotics– Useful in applications (multimedia, virtual reality) requiring

advanced operating-system features.

Page 16: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems16

Operating System Services

• Program execution – system capability to load a program into memory and to run it.

• I/O operations – since user programs cannot execute I/O operations directly, the operating system must provide some means to perform I/O.

• File-system manipulation – program capability to read, write, create, and delete files.

• Communications – exchange of information between processes executing either on the same computer or on different systems tied together by a network. Implemented via shared memory or message passing.

• Error detection – ensure correct computing by detecting errors in the CPU and memory hardware, in I/O devices, or in user programs.

Page 17: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems17

System Programs

• System programs provide a convenient environment for program development and execution. The can be divided into:

– File manipulation

– Status information

– File modification

– Programming language support

– Program loading and execution

– Communications

– Application programs

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

Page 18: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems18

System Calls

• System calls provide the interface between a running program and the operating system.

– Generally available as assembly-language instructions.

– Languages defined to replace assembly language for systems programming allow system calls to be made directly

• Three general methods are used to pass parameters between a running program and the operating system.

– Pass parameters in registers.

– Store the parameters in a table in memory, and the table address is passed as a parameter in a register.

– Push (store) the parameters onto the stack by the program, and pop off the stack by operating system.

Page 19: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems19

System Calls

• Provide "direct access" to operating system services (e.g., file system, I/O routines, memory allocate & free routines) by user programs.

• System calls execute instructions that control the resources of the computer system, e.g., I/O instructions for devices.

• We want such privileged instructions to be executed only by a system routine, under the control of the OS!

• As we will see, system calls are special, and in fact, are treated as a special case of interrupts.

• Programs that make system calls were traditionally called "system programs" and were traditionally implemented in assembly language.

Page 20: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems20

System Call Scenario (cont.)

Userprogram

File system

memory

Operating System

User program is confined!

I/O

devices

Page 21: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems21

Dual-Mode Operation

• Sharing system resources requires operating system to ensure that an incorrect program cannot cause other programs to execute incorrectly.

• Provide hardware support to differentiate between at least two modes of operations.

1. User mode – execution done on behalf of a user.2. Monitor mode (also supervisor mode or system mode) –

execution done on behalf of operating system.

Page 22: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems22

Dual-Mode Operation

• Sharing system resources requires operating system to ensure that an incorrect program cannot cause other programs to execute incorrectly.

• Provide hardware support to differentiate between at least two modes of operations.

1. User mode – execution done on behalf of a user.2. Monitor mode (also supervisor mode or system mode) –

execution done on behalf of operating system.

Page 23: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems23

Dual-Mode Operation (Cont.)

• Mode bit added to computer hardware to indicate the current mode: monitor (0) or user (1).

– Part of EFLAG in x86 architecture– Part of PSW in Motorola architecture

• When an interrupt or fault occurs hardware switches to monitor mode.

• Privileged instructions can be issued only in monitor mode.

• All I/O instructions are privileged instructions.

• Must ensure that a user program could never gain control of the computer in monitor mode (I.e., a user program that, as part of its execution, traps if it executes a privileged instruction).

monitor user

Interrupt/fault

set user mode

Page 24: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems24

API vs. System Calls

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

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

• Why use APIs rather than system calls?

Page 25: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems25

Example of Standard API

• Consider the ReadFile() function in the

• Win32 API—a function for reading from a file

• A description of the parameters passed to ReadFile()– HANDLE file—the file to be read– LPVOID buffer—a buffer where the data will be read into and written from– DWORD bytesToRead—the number of bytes to be read into the buffer– LPDWORD bytesRead—the number of bytes read during the last read– LPOVERLAPPED ovl—indicates if overlapped I/O is being used

Page 26: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems26

API – System Call – OS Relationship

Page 27: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems27

Standard C Library Example

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

Page 28: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems28

System Call Implementation

• Typically, a number associated with each system call– System-call interface maintains a table indexed according to

these numbers

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

• The callers need know nothing about how the system call is implemented

– Just needs to obey API and understand what OS will do as a result call

– Most details of OS interface hidden from programmer by API

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

Page 29: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems29

System Calls (cont.)

• Now, system calls can be made from high-level languages, such as C and Modula-2 (to a degree).

• Unix has about 32 system calls: read(), write(), open(), close(), fork(), …

• using trap instructions:– i = read(fd,80, buffer)

push buffer

push 80

push fd

trap read

pop i

• Each system call had a particular number. Instruction set has a special instruction for making system calls:

SVC (IBM 360/370)trap (PDP 11)

tw (PowerPC) - trap word tcc (Sparc) break (MIPS)

Page 30: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems30

User vs. System Mode

Special mode-bit set in PSW register: mode-bit = 0 => user program executing mode-bit = 1 => system routine executing

Privileged instructions possible only when mode-bit = 1!

System(or kernel)memory

User Program (text)

“trap”to

O.S.

case i-call

trap n

l :

n : code for read

Page 31: Advanced Operating Systems 1 K. Salah Module 1: Introduction What is an operating system? Multiprogramming Systems Time-Sharing Systems Parallel Systems.

K. Salah Advanced Operating Systems31

System Call Scenario

• User program executing (mode-bit = 0)• User makes a system call

hardware sets mode-bit to 1 system saves state of user process branch to case statement in system code branch to code for system routine based on system call

number copy parameters from user stack execute system call (using privileged instructions) restore state of user program hardware resets mode-bit return to user process