OS Concepts An Introduction

34
OS Concepts OS Concepts An Introduction An Introduction operating systems

description

operating systems. OS Concepts An Introduction. operating systems. At the end of this module, you should have a basic understanding of what an operating system is, what it does, and what the major components of an operating system are. operating systems. Why should I study - PowerPoint PPT Presentation

Transcript of OS Concepts An Introduction

Page 1: OS Concepts An Introduction

OS ConceptsOS ConceptsAn IntroductionAn Introduction

OS ConceptsOS ConceptsAn IntroductionAn Introduction

operatingsystems

Page 2: OS Concepts An Introduction

At the end of this module, you should have abasic understanding of what an operating system is, what it does, and what the major components of an operating system are.

operatingsystems

Page 3: OS Concepts An Introduction

Why should I study operating systems?

operatingsystems

Page 4: OS Concepts An Introduction

Based on a 2007 IT Salary Survey

Application Programmers System Programmers

Average SalaryAverage Salary $71,020$71,020 $79,300$79,300

Average BonusAverage Bonus $ 3,410$ 3,410 $ 3,940$ 3,940

Based on a 2007 IT Salary Survey

Application Programmers System Programmers

Average SalaryAverage Salary $71,020$71,020 $79,300$79,300

Average BonusAverage Bonus $ 3,410$ 3,410 $ 3,940$ 3,940

operatingsystems

Page 5: OS Concepts An Introduction

Based on a 2007 IT Salary Survey

Application Programmers System Programmers

System Mainframe $74,100 $80,840 Unix/Linux $76,100 $84,100 Windows $71,000 $79,300

Based on a 2007 IT Salary Survey

Application Programmers System Programmers

System Mainframe $74,100 $80,840 Unix/Linux $76,100 $84,100 Windows $71,000 $79,300

operatingsystems

Page 6: OS Concepts An Introduction

operatingsystems

Even as an application programmer, mostreal commercial applications will require that you

Understand OS design issues and tradeoffsPerformanceFunctionSpace

Be able to exploit OS capabilitiesMultiple ProcessesThreadsSynchronizationCommunication

Page 7: OS Concepts An Introduction

What Is An Operating What Is An Operating SystemSystem

What Is An Operating What Is An Operating SystemSystem

CPU

Operating System Kernel

Language Libraries and System Calls API

System and Application Programs

User User Useroperatingsystems

Page 9: OS Concepts An Introduction

Hardware

Device Device Device

Operating System

ExecutingProgram

This program has no sense of sharing the system’s resources with other programs. It sees an Abstract Machine that has all of the resources that it needs.

Page 10: OS Concepts An Introduction

The Abstract MachineThe Abstract MachineThe Abstract MachineThe Abstract MachineModern computing systems are multi-user, multi-programsystems. The fundamental task of an operating systemin this environment is to give each running program alogical, abstract machine that contains all of the resources that it needs to do its job.

Input/Output devicesMemoryCPUGeneral purpose registersStatus registersStack

ExecutionContext

Page 11: OS Concepts An Introduction

Computer System Organization

system bus

cpu

diskcontroller

memory

devicecontroller

printer

devicecontroller

keyboard

. . .

app app app

Page 12: OS Concepts An Introduction

Computer System Operation

system bus

cpu

diskcontroller

memory

devicecontroller

printer

devicecontroller

keyboard

. . .

cpu and deviceswork concurrently

Page 13: OS Concepts An Introduction

Computer System Operation

system bus

cpu

diskcontroller

memory

devicecontroller

printer

devicecontroller

keyboard

. . .

each device controller is incharge of a particular devicetype

Page 14: OS Concepts An Introduction

Computer System Operation

system bus

cpu

diskcontroller

memory

devicecontroller

printer

devicecontroller

keyboard

. . .Each device controllerhas a local buffer

Page 15: OS Concepts An Introduction

Computer System Operation

system bus

cpu

diskcontroller

memory

devicecontroller

printer

devicecontroller

keyboard

. . .

device controllers send interrupts to the cpu to tell it that they have finished an operation the cpu told them to do

Page 16: OS Concepts An Introduction

Interrupts

An interrupt causes control to branch to an interruptservice routine through an interrupt vector.

The address of the interrupted instruction is saved.

Incoming interrupts are disabled while an interruptis being processed.

A trap is a software generated interrupt.

An operating system is interrupt driven.

Page 17: OS Concepts An Introduction

I/O Processing

Synchronous I/O

1. A process starts an I/O operation2. The requesting process waits until the I/O completes

requesting process

device driver

wait

interrupt handler

hardwaredata

Page 18: OS Concepts An Introduction

I/O Processing

Asynchronous I/O

1. A process starts an I/O operation2. An acknowledgement is returned3. The process continues execution4. The device interrupts the process when the I/O is complete

requesting process

device driver

interrupt handler

hardwaredata

Page 19: OS Concepts An Introduction

ProcessesProcessesProcessesProcesses

A process is defined as a program in execution.It includes * The program itself (program segment) * The program’s data (data segment, stack, heap) * Open files * The execution context

Page 20: OS Concepts An Introduction

For efficiency, modern operating systems allowmany processes to be running concurrently.

When one process has to wait for something,typically for an I/O operation to complete, theoperating systems schedules another process to run.

Many programs can be in memory at the sametime. The operating system gives each processa slice of time in which to run.

Page 21: OS Concepts An Introduction

ThreadsThreadsThreadsThreadsA thread, or thread of execution, is the set of instructionsbeing executed in a process.

In a single thread system each process has exactly one execution engine (the logical machine).

In a multi-thread environment, a process may have manyexecution engines, one for each thread. Thus, each thread has it’sown runtime stack, registers, and state information, but they all share the same address space in memory (program and data), and the same files.

In new multi-core machines, each logical engine may run on areal engine.

Page 22: OS Concepts An Introduction

ResourcesResourcesResourcesResources

All of the components required for a program to do it’sjob are called resources.

* memory* cpu time* devices* files* network connection

When a process needs to use a resource, it must askthe operating system for the resource before using it.

Once a process asks for a resource, it suspends operationand waits until the resource is available.

Page 23: OS Concepts An Introduction

Responsibilities of the Responsibilities of the OSOS

Responsibilities of the Responsibilities of the OSOS

1. Create an abstract machine environment for eachrunning process.

2. Manage the use of the physical components in the system, according to the policies of the system’s administrator or the system designer.

* Device management* Process and thread management* Memory Management* File Management

Page 24: OS Concepts An Introduction

Device ManagementDevice ManagementDevice ManagementDevice Management

The OS manages the allocation, isolation, and sharingof devices.

* Terminals* Disk Drives* Printers* Networks* Keyboard* etc

Page 25: OS Concepts An Introduction

Device DriversDevice DriversDevice DriversDevice Drivers

Device Independent Part

Application Programming Interface

Device Driver Interface

VendorSpecific

Part

VendorSpecific

Part

VendorSpecific

Part

Page 26: OS Concepts An Introduction

Process & Resource Process & Resource ManagementManagement

Process & Resource Process & Resource ManagementManagement

Schedules the processor so that each thread/process receivesan equitable fraction of the available time, and maintainsthe execution context for each thread (stack, registers, etc)

Allocates resources to processes when they are requestedand keeps track of resources when a thread is finished withthem. Isolates access to resources or allows sharing ofresources as required.

Page 27: OS Concepts An Introduction

Memory ManagementMemory ManagementMemory ManagementMemory Management

Maintains a unique address space in memory for eachprocess.

Works with the file and/or device managers to providevirtual memory (address space is larger than physicalmemory).

Page 28: OS Concepts An Introduction

File ManagementFile ManagementFile ManagementFile Management

Works with the device managers to give applicationsA logical view of storage (byte stream, indexed data,text files, etc), and manage the flow of information between the actual storage device and the program.

Page 29: OS Concepts An Introduction

Design IssuesDesign IssuesDesign IssuesDesign IssuesPerformance: The OS must be as efficient as possible,maximizing the use of machine resources by applications.There is some overhead involved in providing OS services.If the overhead gets too large, it negates the value ofthe service.

Exclusive Use of Resources: Each process must have theability to have exclusive use of the system resources that it uses. A process must not be able to use a resourceunless the OS has given it permission. Sharing of resourcesshould also be allowed.

* Protection Mechanisms* Security Policies

Page 30: OS Concepts An Introduction

Processor ModesProcessor ModesProcessor ModesProcessor ModesModern computing hardware provides multiple modes ofoperation:

• User Mode - Cannot execute all machine instructions (e.g. I/O) - Can only access memory allocated to the process

• Privileged Mode - Executes any instruction in the repertoire - Can access protected memory - Only executes trusted software (The OS kernel)

Page 31: OS Concepts An Introduction

Trap InstructionsTrap InstructionsTrap InstructionsTrap InstructionsUser Space

UserProcess

LibraryCode

. . .fork( );. . .

fork( ){ … trap SYS_FORK( ) . . .}

Kernel

trap table

SYS_FORK

sys_fork( ){ /* system function */ . . . return;}Expensive!

Page 32: OS Concepts An Introduction

OS OrganizationOS OrganizationOS OrganizationOS Organization

Monolithic Kernels * All OS function resides in the kernel * Fast * difficult to maintain

MicroKernels * The trusted OS software is as small as possible - only the essential OS functions * All other code is implemented in user space * Performance the major issue – many kernel calls required

Page 33: OS Concepts An Introduction

The first king is very reclusive and sits in a small castle with high walls and a few top advisors. The king tells the advisors what to do and they go outside of the small (but well defended) castle and issue orders to the knights, merchants and common-folk. The king never leaves his castle and since only his most trusted advisors are allowed in the king is very safe from attack. However, because each advisor has to pass through several guard points it can sometimes take a little while before the king’s orders can go out or news can come in.

The second king is much different. He doesn’t really live in a castle so much as it is a large mansion with beautiful grounds. Strongly defended walls encompass the entire city instead of just the castle. This makes the king and the populace very secure from outside attacks. And since this king is very friendly he goes throughout his city meeting and talking with all of his subjects. Any command he, or his many trusted aides, give are instantly obeyed. This makes his city very efficient. However, should any enemy agents manage to penetrate the outer walls, then they can quite easily assassinate the beloved king. In which case order breaks down and the entire city riots.

Page 34: OS Concepts An Introduction

The Unix KernelThe Unix KernelThe Unix KernelThe Unix Kernel

Trap Table

Monolithic Kernel Module• Process Mgt• Memory Mgt• File Mgt• Device MgtD

river

Inte

rface

Device Driver

Device Driver

OS System Call Interface

Libraries Utilities Apps Shell