77
F453 – Computing F453 – Computing Theory Theory Chapter 13 Chapter 13 The Function of Operating The Function of Operating Systems Systems Interrupts Scheduling Memory Management Paging Segmentation Virtual memory Disk Thrashing Spooling Boot File FAT Resource used: OCR Computing Text Book, Hodder Education

F453 – Computing Theory

  • Upload
    beyla

  • View
    45

  • Download
    0

Embed Size (px)

DESCRIPTION

F453 – Computing Theory. Chapter 13 The Function of Operating Systems. Interrupts Scheduling Memory Management Paging Segmentation Virtual memory Disk Thrashing Spooling Boot File FAT. Resource used: OCR Computing Text Book, Hodder Education. Features of operating systems. - PowerPoint PPT Presentation

Citation preview

Page 1: F453 – Computing Theory

F453 – Computing F453 – Computing TheoryTheory

Chapter 13Chapter 13

The Function of Operating The Function of Operating SystemsSystems

Interrup

ts

Scheduli

ng

Memory M

anagemen

t

Paging

Segmenta

tion

Virtual

memory

Disk Thr

ashing

Spooling

Boot Fil

e

FAT

Resource used: OCR Computing Text Book, Hodder Education

Page 2: F453 – Computing Theory

Features of operating Features of operating systemssystems

Hardware resources (Provide and Manage) Hardware resources (Provide and Manage) – such as the management of memory and – such as the management of memory and the jobs passing through itthe jobs passing through it

Interface – provide an interface between Interface – provide an interface between the user and machinethe user and machine

Interface – provide an interface between Interface – provide an interface between applications software and the machine. applications software and the machine. (software and hardware)(software and hardware)

Security – provide it for the data on the Security – provide it for the data on the system particularly when there are lots of system particularly when there are lots of users.users.

Utility Software– provide this so that Utility Software– provide this so that maintainence can be done!maintainence can be done!

H

I

I

S

U

Don’t forget: Mnemonics! – memory aids!

Page 3: F453 – Computing Theory

You’re the expert…You’re the expert…

H

I

I

S

U

What did you say

an operating system was? What are the

main features of an operating

system!?

Er..HISSU….

Page 4: F453 – Computing Theory

Moving on…Moving on…

INTERRUPT HANDLINGINTERRUPT HANDLING

Page 5: F453 – Computing Theory

Interrupt HandlingInterrupt Handling Remember our friend Remember our friend

the Processor? (brain of the Processor? (brain of the computer)the computer)

It normally functions It normally functions SERIALLY – that is an SERIALLY – that is an instruction is collected, instruction is collected, acted upon, next acted upon, next instruction…instruction…

This continues while the This continues while the processor is operating processor is operating or the set of instructions or the set of instructions is completed.is completed.

Page 6: F453 – Computing Theory

Interrupt HandlingInterrupt Handling

That’s all well and That’s all well and good – if things run good – if things run smoothly, but often smoothly, but often you are going to get you are going to get something causing something causing the processor to stop the processor to stop what it is doing and what it is doing and do something elsedo something else

It is the INTERRUPT It is the INTERRUPT that asks for this to that asks for this to happen….happen….

Page 7: F453 – Computing Theory

Types of Interrupt Types of Interrupt Hardware interrupt – (the buffer that is being Hardware interrupt – (the buffer that is being

used to transfer data from primary memory used to transfer data from primary memory to secondary storage has been emptied and to secondary storage has been emptied and needs to be refilled so that data transfer can needs to be refilled so that data transfer can continue)continue)

Software interrupts (such as the interrupt Software interrupts (such as the interrupt caused to the flow of a program by a call to caused to the flow of a program by a call to an external device)an external device)

EACH INTERRUPT IS GIVEN A PRIORITY – if EACH INTERRUPT IS GIVEN A PRIORITY – if two occur you need to know which is more two occur you need to know which is more important.important.

Page 8: F453 – Computing Theory

Example of most important Example of most important interruptinterrupt

An interruption to power supply! An interruption to power supply! (this is given the highest priority of (this is given the highest priority of all!)all!)

Page 9: F453 – Computing Theory

So what happens when an So what happens when an interrupt occurs – What’s interrupt occurs – What’s

the process?the process?

Page 10: F453 – Computing Theory

Interrupt - processInterrupt - process Interrupt is stored with all other jobs that the Interrupt is stored with all other jobs that the

processor has to do (including current processor has to do (including current running task)running task)

Interrupt given a priority, as is the current Interrupt given a priority, as is the current job, according to importancejob, according to importance

All jobs are stored – but also stored in order All jobs are stored – but also stored in order of priority!of priority!

Processor finishes an instruction – it checks Processor finishes an instruction – it checks list for stuff to be donelist for stuff to be done

As long as job it is doing is at the top of the As long as job it is doing is at the top of the list –It will continue with next instruction, but list –It will continue with next instruction, but if an interrupt has gone to top of list, the if an interrupt has gone to top of list, the processor will STOP the job its doing!processor will STOP the job its doing!

Page 11: F453 – Computing Theory

It can’t just stopIt can’t just stop

It’s like when you’ve been working all It’s like when you’ve been working all night on an essay.night on an essay.

In the morning there’s a fire….you In the morning there’s a fire….you need to rush out of the house.need to rush out of the house.

An important interrupt no doubt but…An important interrupt no doubt but… Will you press save?Will you press save?

*maybe not!*maybe not!

Page 12: F453 – Computing Theory

Processor does save when it Processor does save when it is interruptedis interrupted

It can’t waste all the processing its It can’t waste all the processing its donedone

So it stores the contents of all the So it stores the contents of all the special registers so that when it goes special registers so that when it goes back to the job it can load the special back to the job it can load the special register with these contents again and register with these contents again and carry on from where it left off.carry on from where it left off.

These values are stored in a STACK These values are stored in a STACK (we’ll do more on these soon)(we’ll do more on these soon)

Page 13: F453 – Computing Theory

So special registers So special registers emptiedemptied

The new job then (the interrupt) can The new job then (the interrupt) can be loaded into the special registers be loaded into the special registers and proccessed until it is and proccessed until it is completeed.completeed.

Page 14: F453 – Computing Theory

Scheduling, Job Queues and Scheduling, Job Queues and PrioritiesPriorities

Life requires Schedules, Priorities and Queues. Without them, things would not function.

Page 15: F453 – Computing Theory

What are your priorities?What are your priorities?

PhysicalPhysical SpiritualSpiritual MentalMental EmotionalEmotional

Page 16: F453 – Computing Theory

SchedulingScheduling Take the exampe of a multi operating Take the exampe of a multi operating

system….there are a number of jobs that system….there are a number of jobs that must be in the memory in order of the must be in the memory in order of the OS to switch from one job to the otherOS to switch from one job to the other

This in turns means the OS must have a This in turns means the OS must have a set of rules that it can use in order to set of rules that it can use in order to determine the order in which the jobs determine the order in which the jobs should be handledshould be handled

The use of this set of rules is known as The use of this set of rules is known as job schedulingjob scheduling

Page 17: F453 – Computing Theory

So what’s scheduling?So what’s scheduling?

The use of a set of rules to The use of a set of rules to determine the order that jobs should determine the order that jobs should be handled is called Schedulingbe handled is called Scheduling

Page 18: F453 – Computing Theory

What’s scheduling?????What’s scheduling?????

Set of rulesSet of rules These set of rules determine the These set of rules determine the

order in which jobs should be order in which jobs should be handled.handled.

Use of these rules is called job Use of these rules is called job scheduling!scheduling!

Page 19: F453 – Computing Theory

More about the rules…More about the rules…

The rules used will be largely The rules used will be largely decided by the importance applied decided by the importance applied to the different jobs to be carried outto the different jobs to be carried out

This concept of “importance” implies This concept of “importance” implies that the jobs can be arranged into that the jobs can be arranged into some sort of order and the OS can some sort of order and the OS can then follow this order of jobsthen follow this order of jobs

HOW IS THE ORDER OF JOBS HOW IS THE ORDER OF JOBS DECIDED!?!?!??DECIDED!?!?!??

Page 20: F453 – Computing Theory

How do you order jobs in How do you order jobs in your brain?your brain?

Jobs that require Jobs that require physical strength – physical strength – (interfacing with (interfacing with physical external physical external objects…?)objects…?)

Jobs that require Jobs that require emotional strength emotional strength (things that require (things that require processing and brain processing and brain powre)powre)

Page 21: F453 – Computing Theory

Two types of jobs! (for a Two types of jobs! (for a processor!)processor!)

Jobs that required printers and Jobs that required printers and peripherals a lot – such as a job that peripherals a lot – such as a job that needs you to print gas billsneeds you to print gas bills

Jobs that might use the processor a lot – Jobs that might use the processor a lot – such as a program to calculate a prime such as a program to calculate a prime number or square root of something.number or square root of something.

TWO JOBS HERE ARE:TWO JOBS HERE ARE:

I/O Bound Jobs

Processor Bound Jobs

Page 22: F453 – Computing Theory

Which ones are given a Which ones are given a higher prioity?higher prioity?

I/O bound jobs orI/O bound jobs or

Processor bound jobs??Processor bound jobs??

I/O Bound jobs!

Why do you think this is?

Page 23: F453 – Computing Theory

Exam paper Practice!Exam paper Practice!

Remember the mark scheme is a Remember the mark scheme is a good way to memorise answers! (in good way to memorise answers! (in a concise manner)a concise manner)

Page 24: F453 – Computing Theory

From Spec Paper f453 From Spec Paper f453 (Q1)(Q1)

Page 25: F453 – Computing Theory

Answers!Answers!

Page 26: F453 – Computing Theory

Scheduling/Round Robin Scheduling/Round Robin SchedulingScheduling

Page 27: F453 – Computing Theory

Answers!Answers!

Page 28: F453 – Computing Theory

If you had loads of things to If you had loads of things to do, you might develop an do, you might develop an unconscious algo in your unconscious algo in your

head…head…

First Watch GLEEFirst Watch GLEE Then Bully little BrotherThen Bully little Brother Then do computing coursework (if Then do computing coursework (if

time left)time left)

Page 29: F453 – Computing Theory

Take your computing Take your computing courseworkcoursework

Do first come, first served – as in what Do first come, first served – as in what you’ve been asked to do – you doyou’ve been asked to do – you do

Do a bit of everything – equal amounts of Do a bit of everything – equal amounts of time spent on write-up and programmingtime spent on write-up and programming

Do the shortest bit first (as in do login Do the shortest bit first (as in do login screen, then move on to sorting algorithm screen, then move on to sorting algorithm – leave write-up for last, as its longest!)– leave write-up for last, as its longest!)

Devise a system where you spend some Devise a system where you spend some time on the write-up but an alarm goes off time on the write-up but an alarm goes off if you spend too much time on it, and then if you spend too much time on it, and then move on to another job. Multi-level and move on to another job. Multi-level and complexcomplex

Parts to focus on: Write-up + Coding

Page 30: F453 – Computing Theory

Scheduling AlgorithimsScheduling Algorithims Some examples of Scheduling Algorithims:Some examples of Scheduling Algorithims: FCFSFCFS RRRR SJFSJF SRTSRT MFQ MFQ – Multilevel feedback queues – a very complex – Multilevel feedback queues – a very complex

algorithm involving a number of queues set up algorithm involving a number of queues set up according to rules and acting like a set of league according to rules and acting like a set of league tables. As jobs are given lots of peripheral time, they tables. As jobs are given lots of peripheral time, they drop Down the league table, some getting relegated. drop Down the league table, some getting relegated. When a job is finished it leaves the system another When a job is finished it leaves the system another job can then get promoted. In this way JOBS job can then get promoted. In this way JOBS CANNOT SPEND TOO MUCH TIME MONOPOLISING CANNOT SPEND TOO MUCH TIME MONOPOLISING THE PROCESSORTHE PROCESSOR

Page 31: F453 – Computing Theory

Scheduling AlgorithimsScheduling Algorithims Some examples of Scheduling Algorithims:Some examples of Scheduling Algorithims: FCFSFCFS RRRR SJFSJF SRTSRT –Shortest Remaining Time – similar to –Shortest Remaining Time – similar to

SJF – jobs will obviously get shorter and SJF – jobs will obviously get shorter and hence nearer the top of the queue as they are hence nearer the top of the queue as they are processed. Jobs are returned to the queue processed. Jobs are returned to the queue when they have to stop for some reason like when they have to stop for some reason like waiting for some input from a keyboard. The waiting for some input from a keyboard. The major problem with this scheduling algorithm major problem with this scheduling algorithm is…..?is…..?

MFQMFQ LONGER JOBS MAY NEVER GET STARTED!

Page 32: F453 – Computing Theory

Scheduling AlgorithimsScheduling Algorithims

Some examples of Scheduling Algorithims:Some examples of Scheduling Algorithims: FCFSFCFS RRRR SJF –SJF –Shortest Job first. When new jobs are Shortest Job first. When new jobs are

added it is important to make sure they are added it is important to make sure they are placed in the right place in the queue by the placed in the right place in the queue by the OS making an estimate of the length of time OS making an estimate of the length of time required to carry out the taskrequired to carry out the task

SRTSRT MFQMFQ

Page 33: F453 – Computing Theory

Scheduling AlgorithimsScheduling Algorithims Some examples of Scheduling Algorithims:Some examples of Scheduling Algorithims: FCFSFCFS RR – Round RobinRR – Round Robin! The concept of every ! The concept of every

user getting a small amount of time with the user getting a small amount of time with the processor betfore it goes on to the next processor betfore it goes on to the next user. (used in Multi-access OS’s) It uses user. (used in Multi-access OS’s) It uses time slices of various lengths to ensure that time slices of various lengths to ensure that all jobs get a share of processor time!all jobs get a share of processor time!

SJFSJF SRTSRT MFQMFQ

Page 34: F453 – Computing Theory

Scheduling AlgorithimsScheduling Algorithims

Some examples of Scheduling Some examples of Scheduling Algorithims:Algorithims:

FCFS: First Come, First ServedFCFS: First Come, First Served RRRR SJFSJF SRTSRT MFQMFQ

Page 35: F453 – Computing Theory

Take your computing Take your computing courseworkcoursework

You do what you’ve been asked to do – in You do what you’ve been asked to do – in the order you are given it!the order you are given it!

Do a bit of everything – equal amounts of Do a bit of everything – equal amounts of time spent on write-up and programmingtime spent on write-up and programming

Do the shortest bit first (as in do login Do the shortest bit first (as in do login screen, then move on to sorting algorithm screen, then move on to sorting algorithm – leave write-up for last, as its longest!)– leave write-up for last, as its longest!)

Devise a system where you spend some Devise a system where you spend some time on the write-up but an alarm goes off time on the write-up but an alarm goes off if you spend too much time on it, and then if you spend too much time on it, and then move on to another job. Multi-level and move on to another job. Multi-level and complexcomplex

Parts to focus on: Write-up + Coding

Poor example perhaps – but can you match the types of Scheduling Algorithmsto the examples provided above?

Page 36: F453 – Computing Theory

So what is the purpose of So what is the purpose of Scheduling?Scheduling?

It is used in order to try and maximise the use It is used in order to try and maximise the use of the computer and all its peripherals. It of the computer and all its peripherals. It should do this while being “fair” to all the should do this while being “fair” to all the user and ensuring that there is a reasonable user and ensuring that there is a reasonable response time for all!response time for all!

It should ensure, above all, that the algorithm It should ensure, above all, that the algorithm is robust so that the system will not fail either is robust so that the system will not fail either through ovberloading or by becoming through ovberloading or by becoming blocked!!blocked!!

Page 37: F453 – Computing Theory

So Scheduling preventsSo Scheduling prevents

(or should prevent)(or should prevent)

OVERLOADING of systemOVERLOADING of system BLOCKAGE of SystemBLOCKAGE of System

Page 38: F453 – Computing Theory

Looking more closely at the Looking more closely at the processor and the ability of processor and the ability of

a computer to have a a computer to have a number of jobs in different number of jobs in different stages of processing…….stages of processing…….

We need to know how a processor treats jobs…!

Page 39: F453 – Computing Theory

How does a processor How does a processor treat jobs!treat jobs!

Page 40: F453 – Computing Theory

Any job can be one of three Any job can be one of three states:states:

Think of your coursework projects!!!Think of your coursework projects!!!

Jose’s coursework project is READY!

Page 41: F453 – Computing Theory

Any job can be one of three Any job can be one of three states:states:

Think of your coursework projects!!!Think of your coursework projects!!!

Napoleons coursework is

RUNNING (getting there)

Page 42: F453 – Computing Theory

Any job can be one of three Any job can be one of three states:states:

Think of your coursework projects!!!Think of your coursework projects!!!

Darwin’s coursework project is –

incomplete. His brain is

incapable of completing it!BLOCKED!

Page 43: F453 – Computing Theory

Jobs can be in three Jobs can be in three statesstates

READYREADY RUNNINGRUNNING BLOCKEDBLOCKED

Page 44: F453 – Computing Theory

READY

RUNNING BLOCKED

JOB LEAVES THE SYSTEM

JOB ENTERS THE SYSTEM

Page 45: F453 – Computing Theory

Three cool things you need Three cool things you need to know aboutto know about

There is an important thing in the There is an important thing in the processor that controls jobs around processor that controls jobs around the processor is is called the:the processor is is called the:

THE SCHEDULER!THE SCHEDULER!

Page 46: F453 – Computing Theory

The Scheduler is made The Scheduler is made up of:up of:

THE HIGH LEVEL SCHEDULERTHE HIGH LEVEL SCHEDULER THE LOW LEVEL SCHEDULERTHE LOW LEVEL SCHEDULER

And the Medium Level Scheduler…And the Medium Level Scheduler…

Page 47: F453 – Computing Theory

The SCHEDULER!The SCHEDULER!

The part of the OS that controls jobs around The part of the OS that controls jobs around the processor is called the SCHEDULERthe processor is called the SCHEDULER

There are a number of tasks that have to be There are a number of tasks that have to be done and they are carried out by different done and they are carried out by different parts of the scheduler.parts of the scheduler.

When a job wants to be processed it must When a job wants to be processed it must enter the system and be placed in a queue of enter the system and be placed in a queue of jobs waiting for processing called the READY jobs waiting for processing called the READY QUEUEQUEUE

Page 48: F453 – Computing Theory

High Level SchedulerHigh Level Scheduler

This is the thing that loads the job This is the thing that loads the job into the Ready queueinto the Ready queue

HLS = Loads job into Ready queue

Page 49: F453 – Computing Theory

Low level schedulerLow level scheduler

When the job that is currently running When the job that is currently running has had to stop then the job at the top has had to stop then the job at the top of the ready queue is loaded into the of the ready queue is loaded into the processor and is run.processor and is run.

THIS IS DONE BY THE LOW LEVEL THIS IS DONE BY THE LOW LEVEL SCHEDULER (LLS)SCHEDULER (LLS)

Jobs may leave the “running” state for Jobs may leave the “running” state for one of three reasonsone of three reasons

Page 50: F453 – Computing Theory

Three statesThree states

ReadyReady RunningRunning BlockedBlocked

(can you think of three reasons that jobs might leave the running state?)

Page 51: F453 – Computing Theory

Reasons (for jobs leaving Reasons (for jobs leaving running state)running state)

Job may have finished running in which case it Job may have finished running in which case it will leave the systemwill leave the system

Job may require services of a peripheral (like Job may require services of a peripheral (like some printing to be carried out, in which case some printing to be carried out, in which case it will be placed in the blocked queue to await it will be placed in the blocked queue to await servicing)servicing)

Job has had long enough and it has to give up Job has had long enough and it has to give up its place so that the other jobs get a chance…its place so that the other jobs get a chance…There have to be rules for this to happen, There have to be rules for this to happen, obvious example multi-access system where obvious example multi-access system where each user gets a time slice. When time slice is each user gets a time slice. When time slice is ended, job is returned to ready queue to wait ended, job is returned to ready queue to wait its next turn!its next turn!

Another reason a job might be stopped from running – is if a higher priority interrupt comes along!

3+1 reasons

Page 52: F453 – Computing Theory

Three parts of schedulerThree parts of scheduler

HLSHLS LLSLLS

Now the third part: MEDIUM LEVEL Now the third part: MEDIUM LEVEL SCHEDULERSCHEDULER

It controls the movement of jobs between It controls the movement of jobs between the PRIMARY MEMORY AND SECONDARY the PRIMARY MEMORY AND SECONDARY STORAGESTORAGE

Page 53: F453 – Computing Theory

NoteNote What is the difference between primary memory and secondary memory?What is the difference between primary memory and secondary memory? In: In: ScienceScience, , Computer VirusesComputer Viruses, , Data Storage DevicesData Storage Devices [ [Edit categoriesEdit categories]] Crucial Memory UpgradesCrucial Memory Upgrades

100% Compatible Computer Memory Upgrades. Free Lifetime Warranty!100% Compatible Computer Memory Upgrades. Free Lifetime Warranty!www.Crucial.com/Computer_Memorywww.Crucial.com/Computer_Memory

[[ImproveImprove] ] There are two types of memories: Primary and Secondary. There are two types of memories: Primary and Secondary. 

The primary memory or the main memory is part of the main computer system. The processor or The primary memory or the main memory is part of the main computer system. The processor or the CPU directly stores and retrieves information from it. This memory is accessed by CPU, in the CPU directly stores and retrieves information from it. This memory is accessed by CPU, in random fashion. That means any location of this memory can be accessed by the CPU to either random fashion. That means any location of this memory can be accessed by the CPU to either read information from it, or to store information in it.read information from it, or to store information in it.

o The primary memory itself is implemented by two types of memory technologies. The first is called o The primary memory itself is implemented by two types of memory technologies. The first is called Random Access Memory (RAM) and the other is read only memory (ROM). A more appropriate name for Random Access Memory (RAM) and the other is read only memory (ROM). A more appropriate name for RAM is RWM (Read Write Memory), the CPU can write and read information from any primary memory RAM is RWM (Read Write Memory), the CPU can write and read information from any primary memory location implemented using RAM. The other part of primary memory is implemented using ROM which location implemented using RAM. The other part of primary memory is implemented using ROM which stands for Read Only Memory. stands for Read Only Memory. 

Primary memory is much faster and also it is more cost effective. But the secondary memory is much slower Primary memory is much faster and also it is more cost effective. But the secondary memory is much slower and also less costly. It stores the data permanently unless it is erased. The secondary memory is usually and also less costly. It stores the data permanently unless it is erased. The secondary memory is usually available in the form of floppy disk storage media, hard disk, CD, DVD, Pen drive (i.e. Mass storage available in the form of floppy disk storage media, hard disk, CD, DVD, Pen drive (i.e. Mass storage devices), memory chips. A 5 and1/4 inch floppy disk typically stores 1.44 mb of data. The data on the floppy devices), memory chips. A 5 and1/4 inch floppy disk typically stores 1.44 mb of data. The data on the floppy disk is organized in terms of tracks and sectors. Hard disk can have large capacity something like 80-300 disk is organized in terms of tracks and sectors. Hard disk can have large capacity something like 80-300 GB's or higher. Hard disk itself is made up of, large number of platters. Hard disk is usually much faster GB's or higher. Hard disk itself is made up of, large number of platters. Hard disk is usually much faster compared to floppy disk. CD can store up to 750 mb of data. Information on CD ROM is organized in terms compared to floppy disk. CD can store up to 750 mb of data. Information on CD ROM is organized in terms of a spiral track. A DVD is digital Versatile Disk and can store 4.6 Gigabyte of information. All these CD disk of a spiral track. A DVD is digital Versatile Disk and can store 4.6 Gigabyte of information. All these CD disk are usually write ones and read many times (if the disk is not multisession and re writable). So are the are usually write ones and read many times (if the disk is not multisession and re writable). So are the DVDs. DVDs. 

Difference between Primary and Secondary Memory

Page 54: F453 – Computing Theory

READY

RUNNING BLOCKED

JOB LEAVES THE SYSTEM

JOB ENTERS THE SYSTEM

LLS

HLS

LLS

Page 55: F453 – Computing Theory

READY

RUNNING BLOCKED

JOB LEAVES THE SYSTEM

JOB ENTERS THE SYSTEM

LLS

HLS

LLS

MLS

Page 56: F453 – Computing Theory

READY

RUNNING BLOCKED

JOB LEAVES THE SYSTEM

JOB ENTERS THE SYSTEM

LLS

HLS

LLS

MLS

MLS – A Pre-emptive scheduler. It is allowed to move jobs out of the running state andInto the ready queue. If the job that is running state can only be moved out of it because it hasFinished proicessing or because it needs some I/O then that thin arrow can be removed and theScheduler is said to be NON-PRE-EMPTIVE!

Page 57: F453 – Computing Theory

Memory ManagementMemory Management

What does memory actually look What does memory actually look like?like?

Page 58: F453 – Computing Theory

In our brains…In our brains…

Still a wonderful mystery…Still a wonderful mystery…

Making some breakthroughs in Making some breakthroughs in understanding it…understanding it…

Page 59: F453 – Computing Theory

Computer MemoryComputer Memory

Page 60: F453 – Computing Theory

We take memory for We take memory for grantedgranted

We can remember each others namesWe can remember each others names We can remember that we have to wake We can remember that we have to wake

up in the morning and brush our teethup in the morning and brush our teeth We remember that we have a test to We remember that we have a test to

study forstudy for Or which bus to takeOr which bus to take Or what to do if the bus doesn’t arrive…Or what to do if the bus doesn’t arrive…

BUT FOR A COMPUTER – MEMORY MANAGEMENT IS NOT AUTOMATIC

Page 61: F453 – Computing Theory

A bunch of circuits……..!A bunch of circuits……..!

So we needSo we need

““Memory Management”Memory Management”

Page 62: F453 – Computing Theory

Memory ManagementMemory Management

So what does memory look like?So what does memory look like? It contains the OS…it has lots of jobs It contains the OS…it has lots of jobs

in it.in it.

An entire field of study: constantly evolving, growing, gaining pace, revolutionising…

Page 63: F453 – Computing Theory

What Memory looks What Memory looks like…like…

FREE SPACE (35K)FREE SPACE (35K)____________________________________________________________________________ JOB B (25K)JOB B (25K)____________________________________________________________________________ JOB D (10K)JOB D (10K)____________________________________________________________________________ JOB A (40K)JOB A (40K)____________________________________________________________________________ JOB C(50K)JOB C(50K)____________________________________________________________________________

OSOS____________________________________________________________________________

Primary Memory

The diagram above shows the state of memory if it contains jobs A B C and D to be processedAnd the OS. Imagine that the maximum size of the memory available to the jobs is 160K. The fourJobs that are there have been loaded by the MLS. Now, imagine that the job with the next highestPriority is JOB E and that is of Size 40K. There is only 35K of free space sot he job will have to wait.

Page 64: F453 – Computing Theory

What Memory looks What Memory looks like…like…

FREE SPACE (35K)FREE SPACE (35K)____________________________________________________________________________ JOB B (25K)JOB B (25K)____________________________________________________________________________ JOB D (10K)JOB D (10K)____________________________________________________________________________ JOB A (40K)JOB A (40K)____________________________________________________________________________ JOB C(50K)JOB C(50K)____________________________________________________________________________

OSOS____________________________________________________________________________

Primary Memory

The various jobs now take their turn in the running state until one of them leaves the system! ThenThe space in the memory can be used for something else. If the job that is finished is Job C, willThere be a problem? No, because there is ample space!

Page 65: F453 – Computing Theory

What Memory looks What Memory looks like…like…

FREE SPACE (35K)FREE SPACE (35K)____________________________________________________________________________ JOB B (25K)JOB B (25K)____________________________________________________________________________ JOB D (10K)JOB D (10K)____________________________________________________________________________ JOB A (40K)JOB A (40K)____________________________________________________________________________ JOB C(50K)JOB C(50K)____________________________________________________________________________

OSOS____________________________________________________________________________

Primary Memory

If the job that is finished is Job B –is there a problem?Still no problem because there is now plenty of space when B’s space is added to the free space above it.

Page 66: F453 – Computing Theory

What Memory looks What Memory looks like…like…

FREE SPACE (35K)FREE SPACE (35K)____________________________________________________________________________ JOB B (25K)JOB B (25K)____________________________________________________________________________ JOB D (10K)JOB D (10K)____________________________________________________________________________ JOB A (40K)JOB A (40K)____________________________________________________________________________ JOB C(50K)JOB C(50K)____________________________________________________________________________

OSOS____________________________________________________________________________

Primary Memory

Finally, what happens if the job to finish is JOB D? – What might happen?

1. Neither of the gaps is big enough so we wait until a gap appears that is big enough!

Three things might happen. We have

three options. Let’s examine them…

think about which is most efficient

Page 67: F453 – Computing Theory

What Memory looks What Memory looks like…like…

FREE SPACE (35K)FREE SPACE (35K)____________________________________________________________________________ JOB B (25K)JOB B (25K)____________________________________________________________________________ JOB D (10K)JOB D (10K)____________________________________________________________________________ JOB A (40K)JOB A (40K)____________________________________________________________________________ JOB C(50K)JOB C(50K)____________________________________________________________________________

OSOS____________________________________________________________________________

Primary Memory

Finally, what happens if the job to finish is JOB D? – What might happen?

2. Part of Job E is put in the free space area and the rest is put in where Job D used to be, leaving some of the space as the free space

Page 68: F453 – Computing Theory

What Memory looks What Memory looks like…like…

FREE SPACE (35K)FREE SPACE (35K)____________________________________________________________________________ JOB B (25K)JOB B (25K)____________________________________________________________________________ JOB D (10K)JOB D (10K)____________________________________________________________________________ JOB A (40K)JOB A (40K)____________________________________________________________________________ JOB C(50K)JOB C(50K)____________________________________________________________________________

OSOS____________________________________________________________________________

Primary Memory

Finally, what happens if the job to finish is JOB D? – What might happen?

3.. Or – Job B could be moved down to Job A – which would have the effect of making the free space big enough for Job E…

Page 69: F453 – Computing Theory

What Memory looks What Memory looks like…like…

FREE SPACE (35K)FREE SPACE (35K)____________________________________________________________________________ JOB B (25K)JOB B (25K)____________________________________________________________________________ JOB D (10K)JOB D (10K)____________________________________________________________________________ JOB A (40K)JOB A (40K)____________________________________________________________________________ JOB C(50K)JOB C(50K)____________________________________________________________________________

OSOS____________________________________________________________________________

Primary Memory

Finally, what happens if the job to finish is JOB D? – What might happen?

1. Neither of the gaps is big enough so we wait until a gap appears that is big enough!

Option 1 – does this seem like

an effective use of resources? What if the next job is

greater than 160k?

Is Option 2 any better?

Page 70: F453 – Computing Theory

Which of the three options Which of the three options is best?is best?

Option 1Option 1 Option 2Option 2 Option 3Option 3

Page 71: F453 – Computing Theory

We are about to learn We are about to learn about:about:

SegmentationSegmentation PagingPaging

(so before we look at the options and (so before we look at the options and analyse them)…exam analyse them)…exam question/answersquestion/answers

Page 72: F453 – Computing Theory
Page 73: F453 – Computing Theory

AnswersAnswers

Page 74: F453 – Computing Theory

For the rest of this chapter For the rest of this chapter – easiest to go through past – easiest to go through past

paperspapers

Page 75: F453 – Computing Theory

#1#1

Page 76: F453 – Computing Theory

answersanswers

Page 77: F453 – Computing Theory