24
Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques, iUniverse publisher, first ed. 2011. To order: www.iUniverse.com , www.barnesandnoble.com , or www.amazon.com

Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

Embed Size (px)

Citation preview

Page 1: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

Operating System Concepts and Techniques

Lecture 1

Background: hardware concepts review

M. Naghibzadeh

ReferenceM. Naghibzadeh, Operating System Concepts and Techniques, iUniverse publisher, first ed. 2011.To order: www.iUniverse.com, www.barnesandnoble.com, or www.amazon.com

Page 2: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

2

IntroductionComputer: a device which runs programs

Program: a set of instructions to do a specific task Operating system: an essential program which sits

on top of the computer hardware; acts as an interface between the running program and the computer hardware

to: Provide basic software modules to be used by

programs Facilitate efficient use of computer resources

Prevent running programs undesirable interferences

Page 3: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

3

Computer Hardware Organization

Essential Units are: Control unit, Arithmetic-logic unit, Cache memory, Main memory Other devices

Input/Output devices Network connectivity

Figure 1 shows essential logical interconnections

Page 4: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

4

Logical interconnctions of devices

Control Unit

MainMemory

Output UnitInputUnit

Arithmetic-Logic Unit

CPU

Figure 1: Computer organization model

Page 5: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

5

Bus-base connection vs point to pointBus-based reduces interconnection wiring

Similar to a highway via which different parts of a city are connected.

There are at least three busses, address bus, data bus and control busSome computer devices are not directly connected to the computer’s internal busIn a 32-bit computer, for example, the address bus and data bus are each 32 bits wide

There are mechanisms for possessing the address and data buses, otherwise data and addresses from different devices could become mixed up A model of the bus-based computer organization is shown in Figure 2.

Page 6: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

6

Essential Physical interconnctions of a computer’s devices

Figure 2: A bus-based Computer organization model

Central Processing Unit

(CPU)

Main Memory(MM)

Monitor Mouse

Hard Disk (HD)

Internet Connection

. . .

Control bus

Address bus

Data bus

Page 7: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

7

The Fetch-Execute CycleReading an instruction from main memory

(RAM) and moving it to the CPU Program counter (PC) points to the instruction to be

fetched The instruction is moved to Instruction Register (IR)

in the Central Processing Unit (CPU) Finding out what has to be done with respect to

this instruction and perform the actions, i.e., microinstructions

Repeats this cycle of moving an instruction from the main memory to the CPU and

executing it, over and over again.This is called Fetch-Execute Cycle

See Figure 3

Page 8: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

8

The Details of Fetch-Execute Cycle

Figure 3: A simplified functional model of a computer

Read the instruction pointed out by the Program Counter (PC) register from main memory and move it to the CPU

Find out what this instruction is

Adjust PC for the next instruction

Fetch cycle

Execute the instruction, i.e., perform what is requested by the instruction. Perhaps this may readjust the PC.

Execute cycle

Move the data upon which the instruction has to be executed from main memory to the CPU.

Page 9: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

9

Program Counter (PC) update

How is PC filled? When the computer is started or restarted, it is

automatically filled with an initial value by the hardware The operating system will fill the PC with the first

executable instruction of the new program Otherwise, it is updated through fetch-execute cycle

The next instruction to be fetched is most likely the one immediately following this instruction

However, this is not always the case. Look at the piece of program below that is written in a pseudo code format.

1. If A > B 2. then print A3. else print B4. endif

Most of the time, the PC update during the fetch cycle suffices

Sometimes, its content is modified by the execution of the instruction

Page 10: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

How is fetch-excute cycle Brocken?

Will find out in Lecture 2

10

Page 11: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

11

BIOS boot processThe need for BIOS

Main memory, cache, and internal registers are volatile Upon turned on, the computer starts the fetch-execute cycle

With volatile memories, at start, there is no instruction in RAM

Therefore, BIOS is stored in a Read Only Memory (ROM)

This program is called Basic Input Output System

At start or restart, the BIOS address is automatically loaded into the PC thus facilitating its being run

BIOSs are produced by many factories, but perform the same basic functions.

Page 12: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

12

BIOS Actions at start/restart

Power-On Self Test checks to make sure every immediately

required device is connected and functionalBIOS manufacturer’s logo display

Compaq, Phoenix, Intel, IBM, Award plus, or any other manufactures

CMOS and setup modifications The Complementary Metal Oxide

Semiconductor memory is a battery-supported memory which keeps modifiable information

like date, time, computer password…Loading boot strap of the operating

system

Page 13: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

13

Operating System installation OS is giant and cannot be stored in a ROM In addition, we would like computers to be

flexible to run any operating systemTherefore, the OS has to be installed after the

computer is manufacturedDuring installation, it is transferred from say

DVD to the fastest disk driveDuring the transfer other functions such as

decompression and initialization is performed. This process is called OS installation

Page 14: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

14

Booting the operating system

At any start/restart begin the process of loading the operating system

BIOS transfers one block of data from the first valid bootable device to the main memory.

The block is taken from a fixed place of the (block one of track zero) and is put in a specific and fixed place of main memory (0xFC00)

The size of the block of data is usually 512 bytes

The block contains General data about the device + the bootstrap program

After loading the bootstrap, PC is filled with start of bootstrapThis little program will complete the boot process, perhaps by

initiating other phases

The BIOS will then become a passive program which can be used by the operating system to perform many operationsBIOS contains many other useful procedures, especially for

interacting with input/output devices

Page 15: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

15

KernelEventually, essential parts of the operating

system will be loaded in main memory This includes the Operating system Kernel

Kernel is the essential part, or the inner part, of the seed of an operating system

Other parts are usually loaded on demandKernel is composed of:

many routines for doing activities that are not be performed by any single machine instruction

In addition, kernel is composed of many essential processes (threads or agents), each designed to carry

out a responsibility of the operating systemKernel routines are built using machine

instructions and/or BIOS functionsKernel is protected

Page 16: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

16

Our computer looks like

Figure 4: A four-layer machine with system BIOS, kernel, and processes

Computer Hardware(Bare Machine)

“Layer 0”

System BIOS

“Layer 1”

OS Kernel

“Layer 2”

Other layers of the OS

……

Page 17: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

17

An actual hierarchical OS

Figure 5: The structure of Windows 2000

Hardware and Hardware Interfaces: Buses, CPU, Main Memory, Cache, I/O Devices, Timers, Clock, Direct Memory Access, Interrupts, Cache Controller, etc.

Device DriversWindows 2000 Kernel

Virtual Memory Manager

System Services/User Applications: Service Controller, Remote Procedure Call, C++ Compiler, Environmental Subsystems (Posix, OS/2, Win32), etc.

Input/ OutputManager

Process/ Thread Manager

Security Reference Manager

Cache Manager

Windows Manager

Hardware Abstraction Layer (HAL)

Page 18: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

18

Modes of operationsEvery computer has at least two modes of

operation: Kernel mode, or supervisor mode. All machine instructions,

whether privileged or non-privileged, are executable in this mode of operation

User mode. Privileged instructions are not usableOne of the most remarkable features of any

operating system is the way mode transfer is made possible.

During the system startup the system is in kernel mode

Right after the startup the mode changes to user mode

When a program calls a routine of the kernel the mode automatically changes to kernel and in

return from the routine, the mode changes back to user

Page 19: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

19

Making Your Own Operating System

With our current knowledge, it is impossible to write an actual operating

system However, by thinking of making a little

operating system tremendous knowledge is learned

Follow the following steps in writing your own little, do nothing useful, operating

system

Page 20: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

20

1.Using a running computer, write a mini program to do something over and over again

1. I would prefer this program to repeatedly display the word “Hello” on computer monitor

2. Make the size less than 512 bytes. This program will be your operating system

3. Use any language but compile it and produce the executable file

2.An executable file has two sections:1. The file header, i.e., metadata, say 512 bytes

2. The actual machine language instructions, say 512 bytes, i.e., a “com” file

3.Write a program to transfer the “com” file to sector one of track zero of a diskette

Making Your Own Operating System…

Page 21: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

21

Making Your Own Operating System…

4. Prepare a simple bootable device such as diskette5. Transfer the “com” file to sector one of track zero of

the diskette1. You have successfully stored your operating system on

the diskette6. Reset the computer and enter the BIOS setup/modify

program. Make the first floppy drive be the first bootable device

7. Insert your own operating system diskette into the first floppy drive of the computer and reset the computer

again. Wait until your operating system comes up

Page 22: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

22

SummaryThe following subjects were discussed:Computer, Program, and operating systemLogical Computer organization, physical organization, functional organization model and the Fetch-Execute CycleThe need for BIOS, BIOS actions, Installing the OS, Booting the OSOperating system Kernel, hierarchical structure, modes of operationHow to make your own small OS

Page 23: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

23

Find out Your computer’s instruction categories based on their lengthThe benefits of adjusting the PC register during the fetch cycle even though we have to readjust it during the execute cycle for some instructionsFor a 32-bit computer, the maximum memory size that the CPU can directly address (without using a base register)Your computer’s speed in terms of MIPS

The company which built your computer’s BIOS The source code of a BIOS from the Internet

A source code for a small OS from the Internet How to make the above source code actually

work

Page 24: Operating System Concepts and Techniques Lecture 1 Background: hardware concepts review M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts

24

Any Question?