25

So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

Embed Size (px)

Citation preview

Page 1: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –
Page 2: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

So far

• Binary numbers• Logic gates• Digital circuits process data using gates– Half and full adder

• Data storage– Electronic memory – Magnetic memory– Optical memory – Solid state memory

Page 3: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

This week

This week• Software• Operating systems• Shells

Page 4: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

4

Learning outcomes• Describe the functions of the Operating System and its components.• Explain where the operating system is usually stored and how it gets

started.• Explain how the operating system manages memory

– Partitioning, swapping, paging, demand paging• Explain how the operating system manages I/O devices

– Programmed I/O, Interrupt-driven I/O, DMA

Page 5: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

5

Additional Reading

• Essential Reading– Stalling (2003): Chapter 7 and 8

Page 6: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

6

What is an operating system?• A program that runs on the hardware and supports

– Resource Abstraction– Resource Sharing

• Abstracts and standardises the interface to the user across different type of hardware– Virtual machine hides the messy details witch must be performed.

• Manages the hardware resources– Each program gets time with the resource– Each program gets space on the resource

Page 7: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

7

Main functions of an operating system

1. User/computer interface:– Provides an interface between the user and the

computer2. Resource manager: – manages all computer’s resources.• Process manager• Memory manager• Device manager• File manager, etc.

Page 8: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

8

Operation System

User command interface

Resource management

Process Manager

Memory manager

Device Manager

File manager

Network manager

A model of an operation System

Page 9: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

9

Operating system as a resource manager

Resource management

Process Manager:• Next program to be executed? • Time to be given to each program?

Memory manager:• Best use of the memory to run as many programs as possible

I/O Device (e.g.printer) Manager:• Which program should use a particular I/O

device?Network manager:

• which computer should execute a particular program?

Page 10: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

10

How the operating system get started?

Page 11: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

11

Operating system as a process manager

• A program is divided into a sequence of instructions• Each instructions is divided into a sequence of processes• Operating System

– Manages the execution of all processes– First come first served– Shortest job first– Round robin

Page 12: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

12

Process State

• As a process executes, it changes state– new: The process is being created.– running: Instructions are being

executed.– waiting: The process is waiting for

some event to occur.– ready: The process is waiting to be

assigned to a process.– terminated: The process has finished

execution.

Page 13: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

13

Memory partition

• How processes are arranged in the main memory before been executed?

• Fixed-sized partitions• Variable-sized partitions• Swapping • Paging

Page 14: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

14

Swapping

• I/O operations are slow • If a running process requires an I/O operation. The

CPU will move to another process in the main memory.• Suppose the main memory is full of processes waiting

on I/O.• CPU becomes idle• To solve this problem Swapping technique is used.

Page 15: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

15

os os

P1

os

P1

p2

os

P1

p2

p3

os

P1

P3

os

P1

P4

P3

os

P4

p3

os

p2

P4

p3

adcb

ehgf

Page 16: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

16

I/O devices

• Called peripherals:– Keyboard– Mouse– Speakers– Monitor– scanner– Printer– Disk drive– CD-drive.

• OS – manages all I/O operations and devices

Page 17: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

17

I/O modules

System bus

CPUMain

memory

I/O module I/O module

I/Odevice

I/Odevice

Page 18: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

18

Advantages of I/O modules

• They are 3 ways in which I/O modules can work– Programmed I/O– Interrupt-driven I/O– Direct memory access.

Page 19: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

19

Programmed I/O• The CPU controls I/O device directly Via the I/O modules.

• The CPU sends an I/O command to the I/O module.

• And waits until the I/O operation is completed before sending another I/O command.

• The performance is poor as the CPU spends too much time waiting the I/O device.

Page 20: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

20

Interrupt-driven I/O

• The CPU issues a command to the I/O module and then gets on with executing other instructions.

• The I/O module interrupts the CPU when it is ready to exchange data with the CPU.

• The CPU then executes the data transfer.

• Most computer have interrupt lines to detect and record the arrival of an interrupt request.

Page 21: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

21

Disadvantages of Interrupt-driven I/O

• CPU is responsible for managing I/O data transfer.

• Every transferred word must go through the CPU.

• Devices with large transfer, e.g. disk drive, the CPU wastes time dealing with data transfer.

• Solution: Direct-memory-access(DMA).

Page 22: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

22

Direct-memory-access - DMA

• Special-purpose processor.• Handles data transfer.• CPU issues to the DMA:

• starting address in main memory to read/write to.• Starting address in the I/O device to read/write to.• The number of words to be transferred.

• DMA transfers data without intervention from the CPU.• DMA sends interrupt to the CPU when transfer is

completed.

Page 23: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

23

DMA/CPU - bus system

• DMA take care data transfer.• CPU free to do other jobs.• However, they can not use the bus at the

same time.• DMA can use the bus only when the CPU is

not using it.• Some times it has to force to CPU to free the

bus, cycles stealing.

Page 24: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

24

DMA/CPU

System bus

CPUMain

memory

I/O module

I/Odevice

DMA

Page 25: So far Binary numbers Logic gates Digital circuits process data using gates – Half and full adder Data storage – Electronic memory – Magnetic memory –

25

Summery

• OS- memory manager• Fixed-sized partition: waist of memory.• Variable-sized partition: fragmentation. • Swapping. Time wasted in swapping the whole process• Simple paging: process divided into pages and loaded into main

memory(divided into frames).

• OS- I/O manager• Programmed I/O: CPU waste waiting for I/O operation.• Interrupt-driven I/O: CPU responsible for data transfer.• DMA: takes care of data transfer instead the CPU.