• Tidak ada hasil yang ditemukan

Chapter 2 Memory and process Management

N/A
N/A
Protected

Academic year: 2018

Membagikan "Chapter 2 Memory and process Management"

Copied!
35
0
0

Teks penuh

(1)

Chapter 2

Chapter 2

Memory and process

Memory and process

Management

Management

Part 2: Process

management in OS

Prepared by: Nor Zuraida Bt Mohd Gaminan

Department of IT & Communication

(2)

Learning Outcome

Learning Outcome

 By the end of this chapter, student will be able to:

1)Explain role of control blocks and interrupt in

the dispatching process

2)Describe various types of scheduling processes 3)Explain diferent types of scheduling algorithms 4)Explain how queuing and the scheduler work

together

5)Diferences between multiprogramming and

time sharing

(3)

Control blocks

Control blocks

 There are several control felds that must be maintained in

support of each active program.

 Often, a control block is created to hold:

1)a partition’s key control fags, 2)constants

3) variables

 The control blocks (one per partition) are linked to form a linked

list.

 The dispatcher typically determines which program is to start by

following the chain of pointers from control block to control block.

 A given control block’s relative position in the linked list might

be determined by its priority or computed dynamically, perhaps taking into account such factors as:

1) program size, 2) time in memory,

3) peripheral device requirements

(4)

Control blocks

Control blocks

Information

about each program is stored in the program’s control block.

The dispatcher

determines which

program to start next by

(5)

Interrupts

Interrupts

 An interrupt is an electronic signal.

 Hardware senses the signal, saves key control information for the currently executing

program, and starts the operating system’s

interrupt handler routine. At that instant, the interrupt ends.

 The operating system then handles the interrupt.

 Subsequently, after the interrupt is processed, the dispatcher starts an application program.  Eventually, the program that was executing at

(6)

Example of how interrupt

Example of how interrupt

work

work

(7)

Example of how interrupt

Example of how interrupt

work

work

(8)

Example of how interrupt

Example of how interrupt

work

work

(9)

Example of how interrupt

Example of how interrupt

work

work

(10)

Example of how interrupt

Example of how interrupt

work

work

(11)

Example of how interrupt

Example of how interrupt

work

work

(12)

Process

Process

 A program execution, process execution must progress

in sequential fashion

 Process include:

1)Program counter 2)Stack

3)Data section

 Process state:

- New: The process is being created

- Running: Instruction are being executed

(13)
(14)

CPU Scheduler

CPU Scheduler

 Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them

 CPU scheduling decisions may take place when a process:

1. Switches from running to waiting state 2. Switches from running to ready state 3. Switches from waiting to ready

4. Terminates

(15)

CPU Scheduler

CPU Scheduler

Preemptive scheduling policy interrupts processing of a

job and transfers the CPU to another job.

- The process may be pre-empted by the operating system when:

1)a new process arrives (perhaps at a higher priority), or 2)an interrupt or signal occurs, or

3)a (frequent) clock interrupt occurs.

Non-preemptive scheduling policy functions without

external interrupts.

- once a process is executing, it will continue to execute until it terminates, or

(16)

CPU Scheduling

CPU Scheduling

 Scheduling criteria:

1)CPU utilization

 The ratio of busy time of the processor to the total time passes for processes to fnish.

Processor Utilization = (Processor buy time) /

(Processor busy time + Processor idle time)

 Maximize, to keep as busy as possible

2) Throughput

 The measure of work done in a unit time interval.

(17)

CPU Scheduling

CPU Scheduling

3) Turnaround time

 The sum of time spent in the ready queue, execution time and I/O time.

tat = t(process completed) – t(process submitted)

 minimize, time of submission to time of completion. 4) Waiting time

 minimize, time spent in ready queue - afected solely by scheduling policy

5) Response time

 The amount of time it takes to start responding to a request. This criterion is important for interactive systems.

rt = t(frst response) – t(submission of request)

 minimize

(18)

CPU Scheduling

CPU Scheduling

 Types of scheduling:

1)long-term scheduling

(19)

Long-term scheduling

Long-term scheduling

 Determine which programs admitted to system for processing - controls degree of

multiprogramming

 Once admitted, program becomes a process, either:

– added to queue for short-term scheduler

(20)

Medium –term scheduling

Medium –term scheduling

 Part of swapping function between main memory and disk

- based on how many processes the OS wants available at any one time

(21)

Short –term scheduling

Short –term scheduling

(dispatcher)

(dispatcher)

 Executes most frequently, to decide which process to execute next

– Invoked whenever event occurs that interrupts current process or provides an opportunity to preempt current one in favor of another

(22)

CPU Scheduling

CPU Scheduling

 Types of scheduling algorithm: Basic strategies

1)First In First Out (FIFO) 2)Shortest Job First (SJF)

3)Shortest Remaining Time First (SRTF) 4)Round Robin (RR)

5)Priority

Combined strategies

1)Multi-level queue

(23)

First Come First Serve

First Come First Serve

(FIFO)

(FIFO)

 Non-preemptive.

 Handles jobs according to their arrival time -- the earlier they arrive, the sooner they’re

served.

 Simple algorithm to implement -- uses a FIFO queue.

 Good for batch systems; not so good for interactive ones.

(24)

Shortest Job First (SJF)

Shortest Job First (SJF)

 Non-preemptive.

 Handles jobs based on length of their CPU cycle time.

◦ Use lengths to schedule process with shortest time.

 Optimal – gives minimum average waiting time for a given set of processes.

◦ optimal only when all of jobs are available at same time and the CPU estimates are available and accurate.

(25)

Shortest Remaining Time First

Shortest Remaining Time First

(SRTF)

(SRTF)

 Preemptive version of the SJF algorithm.

 Processor allocated to job closest to completion.

◦ This job can be preempted if a newer job in READY queue has a “time to completion” that's shorter.

 Can’t be implemented in interactive system --

requires advance knowledge of CPU time required to fnish each job.

 SRT involves more overhead than SJN.

(26)

Round Robin (RR)

Round Robin (RR)

 FCFS with Preemption.

 Used extensively in interactive systems

because it’s easy to implement.

 Isn’t based on job characteristics but on a

predetermined slice of time that’s given to each job.

◦ Ensures CPU is equally shared among all active processes and isn’t monopolized by any one job.

Time slice is called a time quantum

(27)

Priority scheduling

Priority scheduling

 Non-preemptive.

 Gives preferential treatment to important jobs.

◦ Programs with highest priority are processed frst.

◦ Aren’t interrupted until CPU cycles are completed or a natural wait occurs.

 If 2+ jobs with equal priority are in READY queue, processor is allocated to one that arrived frst

(frst come frst served within priority).

(28)
(29)
(30)
(31)

Multi-level feedback queue

Multi-level feedback queue

(32)

Multi-level feedback queue

Multi-level feedback queue

(33)

Queuing and scheduler

Queuing and scheduler

 As one program fnishes processing and space becomes available, which program is loaded into memory next?

 This decision typically involves two separate modules, a queuing routine and a

(34)

Queuing and scheduler

Queuing and scheduler

1) As programs enter the system, they are placed on a queue by the queuing routine.

(35)

Multiprogramming and time

Multiprogramming and time

sharing

sharing

 A timesharing system allows multiple users to interact with a computer at the same time

 Multiprogramming allowed multiple processes to be active at once, which gave rise to the

ability for programmers to interact with the

computer system directly, while still sharing its resources

Referensi

Dokumen terkait

• Biaya hidup dosen pakar/ahli per bulan, maksimal kegiatan 6 bulan • Honor dosen pakar/ahli per bulan (belum dipotong pajak). • Biaya kegiatan pertemuan, workshop,

Pada hari ini Jum at Tanggal Sebelas Bulan Mei Tahun Dua Ribu Dua Belas (11-05- 2012) bertempat di Ruang Rapat Bidang Cipta Karya, Panitia Pengadaan

he authors have argued that to have an efective distributive mechanism, it is indeed important to address few key factors that may impact the process of efective distribution,

Untuk menentukan kata dasar dari kata berimbuhan ini dengan menghilangkan semua imbuhan (afiks) baik yang terdiri dari awalan (prefiks), sisipan (infiks), akhiran (sufiks)

Waktu minimum yang dibutuhkan batang untuk melakukan satu putaran terjadi saat kecepatan sudut

Biaya produksi Pungutan pajak Pungutan bukan pajak Biaya informal Keuntungan Kompensasi. • Formulasi

Kriteria inklusi : pasien dengan diagnosis gagal jantung pada Poliklinik Kardiologi RSUP-HAM.. Data Sampel Pasien Gagal Jantung Poliklinik Kardiologi RSUP Haji

Mempresentasika n suatu konsep dengan model, diagram, dan simbol Siswa mampu mengubah konsep mengenai sudut pusat, sudut keliling, panjang busur, dan luas juring menjadi