Lec 1

Preview:

Citation preview

Faculty of Computers andInformation

Second Year (Second Semester)

Operating Systems I

Dr. Ashraf Elsisi

Textbooks

- Operating Systems – Internals And Design7thPrinciples– Edition

8th -Operating system concepts

-Windows® 7 Resource Kit

-Galvin

-Windows-powershell-cookbook-the-complete-guide-to-scripting-microsofts-command-shell

Additional Reading:

Tanenbaum - Modern Operating Systems

………

Course Description

The purpose of the course is to understand thegeneral concepts of operating systems.

The course introduces:

•Computer•Operating

System,System (Process, Threads,

Concurrency, scheduling, Memory Management)

If we have time, Deadlock

Prerequisites

Introductory course in Theory of systems, Programmingskills, Logic Systems, Computer Architecture, …

Homework + LabHomework will be assigned weekly.

Note late homework will not be accepted.

ExaminationAt least one-hour midterm exam is

tentativelyscheduled for

week seven of the quarter. The actual data for the exam will bedetermined by the progress in the course.

Grading

• The composition of the final grade is:

• Homework + Lab + Midterm Exam 40%

• Final Exam 60%

Computer System Overview

CHAPTER 1

1. What is operating system?

• Exploits the hardware resources of oneor more processors

• Provides a set of services to system users

• Manages secondary memory and I/Odevices

2. Computer hardware overview••

ProcessorMain Memory

– referred to as real memory or– volatile

I/O modules

primary memory

•–––

secondary memory devicescommunications equipment

terminals• System bus

– communication among processors, memory, andI/O modules

Computer System

Computer Components

Computer Components

RegistersThe component that performs computation is CPU, or more concretely it is the ALU (arithmetic logical unit) in CPU

that do the computation.

• To compute, we need first prepare input; however ALUcannot access memory directly, Instead, a set of

registersare provided as a cache that is smaller than main memory.

faster but

• )They are smaller between they are much moreexpensive than regular memory(.

Processor RegistersThe textbook reference categorizes

registers two types:User-visible registers

– Enable programmer to minimize main-memory references by optimizing register use

Control and status registers– Used by processor to control operating of the

processor– Used by operating-system routines to control the

execution of programs

• into

User-Visible RegistersMay be referenced by machine

languageAvailable to all programs - application

programs and system programsTypes of registers

– Data– Address

••

•••

IndexStack Segment

Stack pointerSSSP

• Address Registers– Index

• involves adding an index to a base value to an address

Segment pointer• when memory is divided into segments,

memory is referenced by a segment and an offset

Stack pointer• points to top of stack

get

Control and Status RegistersProgram Counter (PC)

– Contains the address of an instruction to be fetched

Instruction Register (IR)– Contains the instruction most recently fetched

Program Status Word (PSW)

•–––

condition codesInterrupt enable/disable

Supervisor/user mode

Instruction RegisterFetched instruction is placed in the instruction• register.

Types of instructions:– Processor-memory

• transfer data between processor and memory

Processor-I/O • data transferred to or from a peripheral

device

Data processing • arithmetic or logic operation on data

Control • alter sequence of execution

• Condition Codes or Flags– Bits set by the processor hardware as a

result of operations– Can be accessed

alteredExamples

by a program but not

–••••

positive resultnegative result

zeroOverflow

2.3 Instruction execution

Instruction Fetch and Execute

• The processor fetches the instruction frommemory

• Program counter )PC( holds address of theinstruction to be fetched next

• Program counter is incremented after each fetch

Example of Program Execution

How a partial program istwo numbers.

executed step by step to add

Instructionoperand.(

consists of from two parts )opcode,

Opcode: 1 Load, 2 Store, 5 Add

Operand: Data, Address,

Example of Program Execution

Example of Program Execution

Example of Program Execution

Example of Program Execution

Example of Program Execution

Example of Program Execution

Interrupts• An interruption of the normal sequence of

executionImproves processing efficiency•

• Allows the processor toI/O

executeoperation

otherinstructions

progresswhile an is in

• A suspension of a process caused by an eventexternal to that process and performed in such

a way that the process can be resumed

Classes of Interrupts

Program•––––

arithmetic overflowdivision by zero

execute illegal instruction reference outside user’s memory space

•••

TimerI/O

Hardware failure

I/O processing with interrupts)Interrupt Handler(

A program that determines nature of the interrupt and performs whatever actions are

needed.

• Control is transferred to this program

• Generally part of the operating system

Interrupt Cycle

Interrupt Cycle

Processor checks for interrupts•

• If no interrupts fetch the next instruction forthe current program

• If an interrupt is pending, suspend executionof the current program, and execute theinterrupt handler