f543 computer science part 1

17
F543 COMPUTER SCIENCE SCHEDULING AND MEMORY MANAGEMENT

Upload: mark-gibbs

Post on 14-Apr-2017

171 views

Category:

Education


2 download

TRANSCRIPT

Page 1: F543 computer science part 1

F543 COMPUTER SCIENCESCHEDULING AND MEMORY MANAGEMENT

Page 2: F543 computer science part 1

CONTENTS

• c) define and explain the purpose of scheduling, job queues, priorities and how they are used to manage job throughput;• d) explain how memory is managed in a typical modern

computer system (virtual memory, paging and segmentation should be described along with some of the problems which could occur, such as disk threshing);

Page 3: F543 computer science part 1

SCHEDULING – WHAT ON EARTH IS A SCHEDULER?• A scheduler is a piece of software used by the operating

system to decide where each of the jobs in it’s control should be, and in what order to manipulate them.

Page 4: F543 computer science part 1

OK, BUT ARE THERE ANY RULES OR GOALS THAT IT HAS TO FOLLOW?• The algorithm for a scheduler has 4 main goals:• To make efficient use of processor time.• To make efficient use of resources• To maximise the number of users without apparent delay• To maximise the throughput of the CPU (the amount of work that the

CPU can do in a given time)

Page 5: F543 computer science part 1

ARE THERE ANY WAYS THAT A SCHEDULER CAN DO THIS? (THE 5 WAYS TO SCHEDULE PROGRAMS)• There are a number of scheduling programs, which order the

jobs using different methods• Round robin• Shortest job first• Shortest time remaining• First come first serve• Multi-level feedback queues

Page 6: F543 computer science part 1

PLEASE EXPLAIN ROUND ROBIN

• Each task is given a small "time slice" – perhaps of a few milliseconds. • After the time is up, the processor moves on to the next task.• In the below diagram, the arrow represents the flow of work,

each arrow represents about 5 minutes of working time.Job 1 Job 2 Job 3

Job 6 Job 5 Job 4

Job 7 Job 8 Job 9

Page 7: F543 computer science part 1

OK, NOW EXPLAIN SHORTEST JOB FIRST

• The shortest job is processed first. • Although this leads to lots of jobs being done quickly, it can

lead to some longer jobs never getting processed.• The below table shows how this would look.

Job Completion time (mins)

When the job will get done

Job 1 20:34 7Job 2 10:30 5Job 3 1:20 1Job 4 3:23 4Job 5 33:20 6Job 6 1:30 2Job 7 2:50 3

Page 8: F543 computer science part 1

OK, BUT WHAT ABOUT SHORTEST TIME REMAINING?• The job with the least time remaining is processed first. • This is similar to shortest job first, although it is considered

slightly superior because long jobs will slowly "bubble up" until they have the shortest time remaining.

Page 9: F543 computer science part 1

NOW EXPLAIN FIRST COME FIRST SERVE

• The first job to be ready for processing is processed.• The below table is the same as the one before, but the queue

order is different. Job Completion time (mins)

When the job will get done

Job 1 20:34 1Job 2 10:30 2Job 3 1:20 3Job 4 3:23 4Job 5 33:20 5Job 6 1:30 6Job 7 2:50 7

Page 10: F543 computer science part 1

LASTLY, HOW ABOUT MULTI-LEVEL FEEDBACK QUEUES• A number of queues are set up.• If a task actively uses large amounts of processor time, it is placed in a lower priority

queue, until it reaches the "base" queue, which operates in a round robin fashion.• This one basically combines both the diagrams, the jobs are sorted into a time

sensitive list, and the ones at the bottom, are placed into a round robin list, so that all jobs will eventually be complete, as the ones at the bottom are still being processed, but at a very slow rate.• This method seems the cleanest, as all jobs will eventually get done, but it requires a

lot of processor time to order the jobs, and actually do them as well.

Page 11: F543 computer science part 1

IS THERE AN EASIER WAY TO SHOW HOW PROGRAMS ARE MOVED WITH A SCHEDULER?• Yes.

New job is accepted to the ready queue

The scheduler then moves it to the running queue

An interrupt causes the job to be moved to the ready queue

Or the job is waiting for an input/output event to happen (mouse click), so it moves to the waiting queue

The I/O event happens, so the job moves back into the ready queue

The Job finishes, and it’s processes are terminated

Page 12: F543 computer science part 1

WELL THAT’S EVERYTHING

Page 13: F543 computer science part 1

JUST KIDDING

Page 14: F543 computer science part 1

MEMORY MANAGEMENT – UMM!?!

• In order for a job to be processed, it needs to be stored in the memory.• If several jobs are stored in the memory, their data must be

protected from the actions of other jobs.

Page 15: F543 computer science part 1

OK, BUT WHAT SHOULD MEMORY MANAGEMENT SOFTWARE DO?• Memory management software is used by the operating

system:• To allocate memory to allow separate processes to reside in memory

and then run at the same time.• To reallocate memory when necessary, for example reallocating the

memory space of a closed program.• To protect processes and data from each other by blocking access to

the memory space of another program.

Page 16: F543 computer science part 1

OK, BUT HOW DOES IT DO THIS?

• There are two ways to divide memory, segmentation and paging.• Segmentation:

• Segmentation is where each task has a whole "segment". • The whole segment has to be moved to and from virtual memory, which increases the

time it takes, however segmentation avoids the need to split up a program.• Paging:

• Paging is where a program is split into pages, which all have the same size. • Individual pages can be swapped in and out of virtual memory, which can lead to

more efficient use of RAM. • However, programs have to be split into individual pages.

Page 17: F543 computer science part 1

I SAW VIRTUAL MEMORY IN THE PREVIOUS SLIDE. WHAT IS IT?• A computer will only have a limited amount of RAM.• When the RAM is full, virtual memory has to be used, based on secondary

storage (such as the hard disk).• This allows programs to run that need more memory than is available.• However, if virtual memory is overused, then the processor could end up

spending more time moving segments or pages between RAM and virtual memory.• This is known as disk threshing, and can result in the computer performing

sluggishly, or "hanging".