DFC10273 OS Topic 2 Part 3 Update 26Mar2024 PDF

Document Details

ConvincingScholarship9407

Uploaded by ConvincingScholarship9407

Tags

operating systems process management scheduling algorithms computer science

Summary

This document contains lecture notes and learning objectives for a course on operating systems, specifically focusing on topic 2: memory and process management and various process scheduling algorithms. Topics covered include FIFO, SJF, priority, round robin and scheduling criteria.

Full Transcript

Topic 2: Memory and Process Part 3/4 Management VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ updated: 14/03/2024 Chapter 2 Part 3 || Learning Objectives: (CLO1C2) Process management of operating syst...

Topic 2: Memory and Process Part 3/4 Management VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ updated: 14/03/2024 Chapter 2 Part 3 || Learning Objectives: (CLO1C2) Process management of operating system. 1. Draw Gantt Chart of: TOPIC 2: MEMORY AND PROCESS MANAGEMENT 2.2 a. First In First Out (FIFO), b. Shortest Job First (SJF), c. Priority, d. Round Robin (RR), 2. Scheduling criteria: a. waiting time, turn-around time and response time 3. Calculate scheduling criteria of FIFO, Round Robin, SJF and Priority: a. waiting time, turn-around time and response time b. average waiting time VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 2 SLIDE SHORTCUT Scheduling Scheduling Scheduling Draw Gantt Criteria Algorithm Criteria Chart: Calculation: Concept: Concept: FIFO, SJF, FIFO, SJF, WT, AWT, TT, WT&AWT: Priority, RR Priority, RR RT TT&RT VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 3 || GO TO “LEARNING OBJECTIVES” SLIDE || TOPIC 2: MEMORY AND PROCESS MANAGEMENT Scheduling Algorithms: Draw Gantt Chart First In First Out (FIFO), Shortest Job First (SJF), Priority, Round Robin, VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 4 1 F irs Pr ex oc tI co ec s e n m ute s t Fi es d ha rs la fir t a tO te st rri ut r w. A ve ill nd s f ge a irs t t ny t w he th il C at l be 2 PU Ro la Sc un te he d r. Al d R am l p ul ob or o roc ing in ci de unt es ar ruc rs of ses e ul fol ti ex ar lo m are ec m w e q g ut od FIF ua ive ed e O n n. un ru tum sa til le. m al , b Pr e lp u o 3 ro t in ce Sh ce ss A o sse s rte as ll p s p c ro e c tJ am roc nd es ob ou ess ing ses Fi nt th bu ar rs of at rs e tim req t ti sor t e uir me ted to e a pr s s cco into oc ho rd es rte in 4 s. st g Pr to Al l io th p r rit a th t oc y e de es C ci s PU d es e fir s w are st h an ich giv d p en la ro p te ce rio r. s r s ity w ta ill ge gs VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ t Scheduling Algorithm : Ringkasan Konsep 5 TOPIC 2: MEMORY AND PROCESS MANAGEMENT || GO TO “LEARNING OBJECTIVES” SLIDE || || GO TO “LEARNING OBJECTIVES” SLIDE || Melukis Gantt Chart Apa yang perlu diberi Process Burst Time (ns) Waiting Time perhatian? A 2 ? B 3 ? i. Process Table (Jadual Proses) Mengandungi "Process Name", "Burst Time", TOPIC 2: MEMORY AND PROCESS MANAGEMENT dan "Waiting Time". 2 Process Name ii. Gantt Chart (Carta Gantt) B A Mengandungi label "Process Name" dan "Timeline". 0 3 5 Timeline" VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 7 || GO TO “LEARNING OBJECTIVES” SLIDE || 1. First In First Out (FIFO): Concept 1. Process that requests the CPU first is allocated to the CPU first. 2. Whichever process that placed their request first will get the CPU first. 3. Non-preemptive. 4. Good for batch systems; not so good for interactive ones. 5. Turnaround time is unpredictable. TOPIC 2: MEMORY AND PROCESS MANAGEMENT VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 6 1. First In First Out (FIFO): || GO TO “LEARNING OBJECTIVES” SLIDE || Melukis Gantt Chart Langkah Demi Langkah + Kira "Waiting Time" Mula Ada berapa proses? Lukis dan isikan jadual mengikut "Gantt Chart" TOPIC 2: MEMORY AND PROCESS MANAGEMENT tadi. Semak susunan proses dalam soalan dan ambil kira konsep Kira masa menunggu ("Waiting Time") setiap SA yang diminta. Susun semula jadual jika perlu. proses dan isi dalam jadual. Petunjuk: Konsep SA FIFO ialah mana-mana tugas yang datang dulu akan diproses dulu. Lukis kotak kosong secukupnya. Labelkan masa menunggu ("Waiting Time") pada "Gantt Chart" tadi. Labelkan nama process di dalam kotak ("Gantt Chart"), rujuk susunan proses yang betul. Petunjuk: Rujuk soalan, di dalam kolum "Process" mengandungi nama proses. Selesai VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 8 || GO TO “LEARNING OBJECTIVES” SLIDE || 1. First In First Out (FIFO): Latihan 1: Langkah demi langkah Consider the following set of processes that arrive at time 0, with the length of the CPU burst given in nanoseconds. If the processes arrive in the order B then A, draw a suitable Gantt Chart that represent the correct sequence of processes. TOPIC 2: MEMORY AND PROCESS MANAGEMENT Process Burst Time (ns) A 2 B 3 Rujuk Carta Alir VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 9 || GO TO “LEARNING OBJECTIVES” SLIDE || 1. First In First Out (FIFO): Latihan 1: Langkah demi langkah 1. Berapakah jumlah proses? Jadual Proses Process Burst Time (ns) a. Terdapat 2 proses: A dan B A 2 B 3 Gantt Chart TOPIC 2: MEMORY AND PROCESS MANAGEMENT b. Lukis 2 kotak. Rujuk Carta Alir VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 10 || GO TO “LEARNING OBJECTIVES” SLIDE || 1. First In First Out (FIFO): Latihan 1: Langkah demi langkah 2. Apakah susunan proses di dalam soalan? a) B disusuli A. Jadual proses yang asal: Process Burst Time (ns) A 2 B 3 TOPIC 2: MEMORY AND PROCESS MANAGEMENT Jadual proses selepas disusun semula: Process Burst Time (ns) Gantt Chart b) Susun semula jadual B 3 Rujuk Carta Alir B A mengikut kehendak soalan dan A 2 labelkan proses ke dalam Gantt Chart. 'Pengganggu' bertujuan mendidik pelajar supaya menjadi lebih teliti. VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 11 || GO TO “LEARNING OBJECTIVES” SLIDE || 1. First In First Out (FIFO): Latihan 1: Langkah demi langkah 3. Kira “Waiting Time” Process Burst Time (ns) Waiting Time (ns) 0 B 3 (Mula dengan 0 kerana tiada kerja lain sebelumnya) TOPIC 2: MEMORY AND PROCESS MANAGEMENT Waiting Time B + Burst Time B = Waiting Time bagi A A 2 0+3=3 Waiting Time A + Burst Time A = Waiting Time Rujuk Carta Alir bagi B 3+2=5 VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 12 || GO TO “LEARNING OBJECTIVES” SLIDE || 1. First In First Out (FIFO): Latihan 1: Langkah demi langkah 4. Labelkan "Waiting Time" pada Gantt Chart. Process Burst Time (ns) Waiting Time (ns) Gantt Chart B 3 0 A 2 3 B A 5 0 3 5 TOPIC 2: MEMORY AND PROCESS MANAGEMENT 5. Jawapan akhir: Gantt Chart Rujuk Carta Alir B A 0 3 5 VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 13 || GO TO “LEARNING OBJECTIVES” SLIDE || Consider the following set of processes that arrive at time 0, with the length of the CPU burst 1. First In First Out given in milliseconds: (FIFO): TOPIC 2: MEMORY AND PROCESS MANAGEMENT Exc. 2 If the processes arrive in the order P₁ , P₂ and P₃ draw a suitable Gantt Chart that represent the correct sequence of processes. VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 14 || GO TO “LEARNING OBJECTIVES” SLIDE || 1. First In First Out (FIFO): Exc. 2 1. Check the sequence/order of process. 2. Re-arrange the table according to the sequence given. TOPIC 2: MEMORY AND PROCESS MANAGEMENT 3. How many boxes to draw? VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 15 || GO TO “LEARNING OBJECTIVES” SLIDE || 1. First In First Out (FIFO): Exc. 2 1. Order: P₁, P₂ and P₃ 2. Gantt Chart: TOPIC 2: MEMORY AND PROCESS MANAGEMENT 3. There are no changes to table. 4. Calculate Total of Burst Time= 20 + 3 + 7 = 30. (Learn how to double check your answer when learning Turnaround Time soon) VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 16 || GO TO “LEARNING OBJECTIVES” SLIDE || 2. Priority 1. According to SA priority, CPU will be allocated to the process with the highest priority (high priority and low priority). 2. We assume that low numbers represent lower priority. (If priority tags are 1, 2, 3, 4, 5 then we may assume 5 is the highest priority. Or it can also be the other way around.) 3. Non-preemptive. TOPIC 2: MEMORY AND PROCESS MANAGEMENT 4. Main problem with priority is: starvation. VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 31 2. Priority: || GO TO “LEARNING OBJECTIVES” SLIDE || Melukis Gantt Chart Langkah Demi Langkah Mula Laksanakan proses yang mempunyai priority tag paling utama, hingga selesai Ada berapa proses? BT proses. Petunjuk: Priority Tag adalah bergantung kepada nilai yang ditetapkan oleh soalan atau jika tiada dalam soalan, pelajar bebas memilih dan hendaklah menyatakannya sebelum mula menulis jawapan. Semak susunan proses dalam soalan. Susun semula jadual mengikut nombor “Priority”. Jika Priority tag sama nilai, proses hendaklah TOPIC 2: MEMORY AND PROCESS MANAGEMENT menggunakan konsep FIFO Petunjuk: Konsep SA Priority ialah mana-mana tugas Adakah proses Rujuk jadual untuk lihat priority yang diberikan keutamaan (“Priority”) lebh tinggi akan semasa sudah tag utama seterusnya. diproses dulu. selesai dilaksana? Ya Tidak Lukis kotak kosong secukupnya. Tidak Adakah semua Laksanakan proses semasa proses sudah selesai Labelkan nama proses dan masa di dalam dilaksana? kotak ("Gantt Chart"), rujuk susunan proses yang betul. Ya Petunjuk: Rujuk soalan, di dalam kolum "Process" mengandungi nama proses. Selesai VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 32 || GO TO “LEARNING OBJECTIVES” SLIDE || Latihan 1: Langkah demi langkah Consider the following set of processes, assumed to have arrived at time 0, in the order P1, P2, P₃ , P₄ and P₅ with the length of the CPU burst given in milliseconds. Draw a Gantt Chart following Priority scheduling algorithm. TOPIC 2: MEMORY AND PROCESS MANAGEMENT 2. Priority: Rujuk Carta Alir VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 33 || GO TO “LEARNING OBJECTIVES” SLIDE || Latihan 1: Langkah demi langkah 1. Berapakah jumlah proses? 2. Apakah susunan proses di dalam soalan? a. Terdapat 5 proses: Jadual Proses TOPIC 2: MEMORY AND PROCESS MANAGEMENT 2. Priority: b. Susun semula jadual mengikut priority tags. Jika Assuming 5 is the highest priority. tiada dinyatakan dalam soalan, Rujuk Carta Alir Process Burst Time Priority pelajar hendaklah P₄ 10 5 menyatakannya sebelum mula P₃ 3 4 menjawab soalan. P₁ P5 5 7 3 2 P₂ 1 1 VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 34 || GO TO “LEARNING OBJECTIVES” SLIDE || + Kira "Waiting Time" Latihan 1: Langkah demi langkah 3. Lukis Carta Gantt mengikut jadual baharu Rujuk Carta Alir. (1) (2) P1 Rujuk jadual baharu. i. Pilih Priority Tag paling utama untuk dilaksanakan Process Burst Time Priority terlebih dahulu. P₄ 10 5 TOPIC 2: MEMORY AND PROCESS MANAGEMENT P₃ 3 4 ii. BT proses akan dilaksanakan 2. Priority: P₁ 5 3 Gantt Chart sehingga selesai. P5 7 2 P₄ P₂ 1 1 Ulang i dan ii 0 10 sehingga semua proses Gantt Chart Rujuk Carta Alir dilaksanakan. P₄ P₃ P₁ P5 P₂ 0 10 13 18 25 26 Nota: AT: Arrival Time || BT: Burst Time || WT: Waiting Time || WList: Waiting List VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 35 || GO TO “LEARNING OBJECTIVES” SLIDE || 3. Round Robin Scheduling 1. The round-robin (RR) scheduling algorithm is designed especially for timesharing systems. 2. Preemption in between processes. 3. A small unit of time, called a time quantum or time slice, is defined. (A time quantum is generally from 10 to 100 milliseconds.) 4. The ready queue is treated as a circular queue. The CPU TOPIC 2: MEMORY AND PROCESS MANAGEMENT scheduler goes around the ready queue, allocating the CPU to each process for a time interval of up to 1 time quantum. 5. Used extensively in interactive systems because it’s easy to implement. VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 36 3. Round Robin Scheduling: : || GO TO “LEARNING OBJECTIVES” SLIDE || Melukis Gantt Chart Langkah Demi Langkah + Kira "Waiting Time" Mula Lukis dan isikan jadual mengikut "Gantt Chart" tadi. Berapa nilai “quantum” time? Petunjuk: Rujuk Slaid “Panduan menentukan jumlah Burst Time yang boleh dilaksanakan.” TOPIC 2: MEMORY AND PROCESS MANAGEMENT Laksanakan tugas pertama dalam jadual proses sebanyak “quantum time”. Kira masa menunggu ("Waiting Petunjuk: Konsep SA RR ialah semua tugas mendapat masa Time") setiap proses dan isi dalam jadual. proses yang sama menggunakan penggiliran seperti FIFO. Labelkan masa Lukis kotak kosong secukupnya. menunggu ("Waiting Time") pada "Gantt Chart" tadi. Labelkan nama proses di dalam kotak ("Gantt Chart"), rujuk susunan proses yang betul. Selesai Petunjuk: Rujuk soalan, di dalam kolum "Process" mengandungi nama proses. VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 37 || GO TO “LEARNING OBJECTIVES” SLIDE || 3. Round Robin Scheduling 1. To implement RR scheduling, we keep the ready queue as a FIFO queue of processes. 2. New processes are added to the tail of the ready queue. 3. The CPU scheduler picks the first process from the ready queue, sets a timer to interrupt after 1 time quantum, and TOPIC 2: MEMORY AND PROCESS MANAGEMENT dispatches the process. VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 38 || GO TO “LEARNING OBJECTIVES” SLIDE || 3. Round Robin Scheduling 1. There are multiple cycles. 2. Each cycles uses a certain amount of time quantum as assigned by the processor. 3. Solve one cycle at a time. 4. Ensures CPU is equally shared among all active processes TOPIC 2: MEMORY AND PROCESS MANAGEMENT and isn’t monopolized by any one job. VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 39 || GO TO “LEARNING OBJECTIVES” SLIDE || Consider the following set of processes that arrive at time 0, with the length of the CPU burst given in milliseconds: 3. Round Robin Process Burst Time Scheduling: P1 20 P2 4 TOPIC 2: MEMORY AND PROCESS MANAGEMENT Exc. 1 Step by Step P3 7 If the processes arrive in the order P₁, P₂, and P₃ draw a suitable Gantt Chart that represent the correct sequence of processes. Use a time quantum of 3 ms. VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 40 3. Round Robin Scheduling: || GO TO “LEARNING OBJECTIVES” SLIDE || Exc. 1 Step by Step 1. Information: a. Order P₁, P₂, and P₃ b. time quantum : 3 ms. 2. Calculate Burst Time left after every cycle. Formula= Burst Time - Time Quantum 3. When a process has no burst time left (=0), then we can stop calculating for that particular process. TOPIC 2: MEMORY AND PROCESS MANAGEMENT 4. If Burst Time is smaller than Time Quantum, then we deduct Burst Time with its own value. Process Burst Time Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 P1 20 20-3=17 17-3=14 14-3=11 11-3=8 8-3=5 5-3=2 2-2=0 P2 4 4-3=1 1-1=0 P3 7 7-3=4 4-3=1 1-1=0 Legend: done VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 41 3. Round Robin Scheduling: || GO TO “LEARNING OBJECTIVES” SLIDE || Untuk mengira jumlah ‘cycle’ kita tolak ‘time quantum’. Sekarang, untuk mendapatkan Exc. 1 Step by Step nilai ‘timeline’ kita akan tambah ‘time quantum’. COMPLETE CYCLE REFERENCE Process Burst Time Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 P1 20-3=17 17-3=14 14-3=11 not done P1 11-3=8 8-3=5 5-3=2 2-2=0 P1 20 not done not done not done not done done P1 P1 P1 P1 P1 P2 4 4-3=1 1-1=0 done - - - - - P2 P2 P2 P2 P2 P2 P2 P3 7 7-3=4 4-3=1 not done 1-1=0 - P3 done P3 P3 - - - P3 P3 P3 P3 TOPIC 2: MEMORY AND PROCESS MANAGEMENT HOW TO START DRAWING GANTT CHART: start from upper left Cycle 1; P₁ ,P₂ ,P₃ , then repeat at Cycle 2; P₁ ,P₂ ,P₃ , until all cycles are covered. Cycle 1 Cycle 2 Cycle 1 Cycle 2 P1 20-3=17 17-3=14 P1 P1 P2 P3 P1 P2 P3 0+3 3⁺³ 6⁺³ 9 9+3 12⁺¹ 13+3 16 4-3=1 P2 1-1=0 P2 7-3=4 P3 4-3=1 P3 VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 42 3. Round Robin Scheduling: Legend: || GO TO “LEARNING OBJECTIVES” SLIDE || done Exc. 1 Step by Step COMPLETE CYCLE REFERENCE Process Burst Time Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 P1 20 20-3=17 17-3=14 14-3=11 11-3=8 8-3=5 5-3=2 2-2=0 P2 4 4-3=1 1-1=0 P3 7 7-3=4 4-3=1 1-1=0 TOPIC 2: MEMORY AND PROCESS MANAGEMENT Dalam 4 "Cycle" terakhir ini, HOW TO START DRAWING GANTT CHART: hanya P1 tinggal untuk start from upper left Cycle 1; P₁ ,P₂ ,P₃ , then repeat at Cycle 2; P₁ ,P₂ ,P₃ , until all cycles are covered. dilaksanakan. Semua proses lain sudah selesai. Cycle 3 Cycle 4 Cycle 4 Cycle 5 Cycle 6 Cycle 7 Cycle 3 P1 14-3=11 P1 11-3=8 P1 11-3=8 8-3=5 5-3=2 2-2=0 P1 P3 16+3 19⁺¹ 20 Cycle 4 Cycle 5 Cycle 6 Cycle 7 P2 P2 P1 P1 P1 P1 1-1=0 20+3 23 23+3 26 26+3 29 29+2 31 P3 P3 VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 43 3. Round Robin Scheduling: || GO TO “LEARNING OBJECTIVES” SLIDE || Exc. 1 Step by Step THESE WERE ALL PROCESS. Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 5 Cycle 6 Cycle 7 P1 P2 P3 P1 P2 P3 P1 P3 P1 P1 P1 P1 0+3 3⁺³ 6⁺³ 9 9+3 12⁺¹ 13+3 16 16+3 19⁺¹ 20 20+3 23 23+3 26 26+3 29 29+2 31 TOPIC 2: MEMORY AND PROCESS MANAGEMENT NOW LETS MERGE ALL CYCLE! IGNORE THE CYCLE, AND DIFFERENTIATE THEM USING COLORS! P1 P2 P3 P1 P2 P3 P1 P3 P1 P1 P1 P1 0+3 3⁺³ 6⁺³ 9+3 12⁺¹ 13+3 16+3 19⁺¹ 20+3 23+3 26+3 29+2 31 WHAT IF THERE IS NO COLOR? P1 P2 P3 P1 P2 P3 P1 P3 P1 P1 P1 P1 0+3 3⁺³ 6⁺³ 9+3 12⁺¹ 13+3 16+3 19⁺¹ 20+3 23+3 26+3 29+2 31 VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 44 Tips & trick to self-check your answers. || GO TO “LEARNING OBJECTIVES” SLIDE || Estimate number of box to draw & number of cycle. Process Burst Time P1 20 P2 4 P3 7 time quantum : 3 ms. Calculate Total Sum of Burst Time. This will tell you the exact final value of your Gantt Chart timeline (a.k.a last turnaround time). You can cross check your answer. E.g: 20 + 4 + 7 = 31 Divide Burst Time of each process with time quantum. This will help you estimate TOPIC 2: MEMORY AND PROCESS MANAGEMENT minimum number of boxes you can expect to draw. E.g: [P₁ ] 20 ÷ 3 = 6.something [P₂ ] 4 ÷ 3 = 1.something [P₃ ] 7 ÷ 3 = 2.something Number of boxes estimates: [P₁ = 7 ] [P₂ = 2 ] [P₃ = 3 ] Overall = 7+2+3 = 12 boxes minimum Compare “Number of boxes estimates”. This will help you estimate number of cycles to expect. E.g: Number of boxes estimates: [P₁ = 7 ] [P₂ = 2 ] [P₃ = 3 ] Overall = 7+2+3 = 12 boxes Cycle estimates: P₂ & P₃ have less box estimation as compared to P₁. Therefore, there should be around 7 cycle. VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 45 || GO TO “LEARNING OBJECTIVES” SLIDE || 4. Shortest Job First: Concept 1. When the CPU is available, it is assigned to the process that has the smallest next CPU burst. 2. If the next CPU bursts of two processes are the same, FCFS scheduling is used to break the tie. 3. Handles jobs based on length of their CPU cycle time. a. Use lengths to schedule process with shortest time. TOPIC 2: MEMORY AND PROCESS MANAGEMENT 4. Two types of SJF: a. Preemptive SJF(a.k.a SRTF) : will stop running process to process another shorter process (a.k.a shortest- remaining-time-first: SRTF) b. Non-preemptive SJF : will let running process finish before considering another process VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 17 2. Shortest Job First: Non-Preemptive SJF Melukis Gantt Chart Langkah Demi Langkah Konsep SA SJF non-preemptive: AT: Arrival Time Proses semasa akan dilaksanakan hingga selesai BT: Burst Time walaupun proses baru memiliki BT lebih kecil dari proses WT: Waiting Time Mula semasa. Proses baru akan masuk baris *queue selepas proses semasa selesai dilaksanakan. Laksana proses yang mempunyai Laksanakan BT paling AT paling rendah hingga selesai. rendah yang seterusnya. Petunjuk: Jika tiada AT diberi dalam jadual, maka semua proses dianggap masuk serentak bermula pada masa sifar (0). Maka semua kerja diproses mengikut susunan FIFO. Ya Tidak Adakah proses semasa Laksanakan AT paling rendah Adakah AT selesai sudah dilaksanakan? yang seterusnya. terlepas? Ya Adakah Tidak Tidak semua proses sudah dilaksanakan? Selesai Ya || GO TO “LEARNING OBJECTIVES” SLIDE || Non-Preemptive SJF No AT provided in question Latihan 1: Langkah demi langkah Latihan 1: Langkah demi langkah + Kira "Waiting Time" 5. Shortest Job First: Rujuk Carta Alir Consider the following set of processes that arrive at time 0, with the length of the CPU burst given in milliseconds. Draw a suitable Gantt Chart that represent the correct sequence of processes, following Non-preemptive SJF. TOPIC 2: MEMORY AND PROCESS MANAGEMENT VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 19 || GO TO “LEARNING OBJECTIVES” SLIDE || Latihan 1: Langkah demi langkah 1. Berapakah jumlah proses? 2. Apakah susunan proses di dalam soalan? 5. Shortest Job First: a) Susun mengikut AT, dari kecil ke besar. b) Dalam soalan ini tidak diberikan AT terperinci bagi setiap proses , maka susunan Asal pada jadual dianggap tiba serentak pada AT = 0. TOPIC 2: MEMORY AND PROCESS MANAGEMENT c) Mengikut jadual: P₁ → P₂ → P₃ → P₄ Process Burst Time (ms) d) Adakah jadual perlu disusun semula? P₃ 5 Baharu Ya, Perlu. P₁ 6 e) Jika AT semua proses ialah 0, maka semua P₂ 7 proses mesti susun mengikut BT dari paling sedikit ke paling banyak. P₄ 8 Nota: AT: Arrival Time || BT: Burst Time || WT: Waiting Time || WList: Waiting List VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 20 || GO TO “LEARNING OBJECTIVES” SLIDE || + Kira "Waiting Time" Latihan 1: Langkah demi langkah 3. Lukis Carta Gantt mengikut jadual baharu Rujuk Carta Alir. Syarat Utama NP SJF ialah AT DAN BT terendah akan dilaksanakan terlebih dahulu. 5. Shortest Job First: (1) (2) Adakah P₃ P₃ Konsep Rumah mempunyai Lidi: Rujuk jadual baharu. 1. AT terendah ? DAN tiba serentak pada AT = 0. Jika satu kotak 2. BT terendah? diabaikan Carta Gantt ini kerana seperti sebuah Process Burst Time belum ada rumah lidi, maka (ms) P₃ dilaksanakan proses lain tiang kiri adalah yang masuk. terlebih dahulu. WT dan tiang P₃ 5 kanan adalah WT TaT TOPIC 2: MEMORY AND PROCESS MANAGEMENT TaT-nya. Proses yang Gantt Chart Process BT (ms) WT (ms) P₁ 6 pertama P₃ dilaksanakan P₃ 5 0 P₂ 7 sering bermula 0 P₁ 6 dengan WT = 0 unit. P₄ 8 Kenapa nilai 0? P₂ 7 Kerana ia tidak perlu menunggu P₄ 8 untuk diproses. Nota: AT: Arrival Time || BT: Burst Time || WT: Waiting Time || WList: Waiting List VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 21 || GO TO “LEARNING OBJECTIVES” SLIDE || + Kira "Waiting Time" Latihan 1: Langkah demi langkah... Lukis Carta Gantt mengikut jadual baharu Rujuk Carta Alir. Syarat Utama NP SJF ialah AT DAN BT terendah akan dilaksanakan terlebih dahulu. 5. Shortest Job First: (3) P₁ P₁ Proses seterusnya Bagaimana kira WT dalam jadual ialah bagi P₁ ? P₁. WT dikira dengan Adakah P₁ menambah WT mempunyai proses sebelumnya tiba serentak TOPIC 2: MEMORY AND PROCESS MANAGEMENT 1. AT terendah ? DAN pada AT = 0. iaitu P₃ (iaitu 0) 2. BT terendah? dengan BT-nya Process BT (ms) WT (ms) Berapakah WT Gantt Chart sendiri (P₃) iaitu 5. Gantt Chart P₃ 5 + 0 untuk P₁ ? WT (P₁) = WT(P₃) + BT(P₃) P₃ P₁ P₃ P₁ P₁ 6 5 =0+5 0 = 5 ms 0 5 P₂ 7 +? +5 P₄ 8 Nota: AT: Arrival Time || BT: Burst Time || WT: Waiting Time || WList: Waiting List VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 22 || GO TO “LEARNING OBJECTIVES” SLIDE || + Kira "Waiting Time" Latihan 1: Langkah demi langkah... Lukis Carta Gantt mengikut jadual baharu Rujuk Carta Alir. Syarat Utama NP SJF ialah AT DAN BT terendah akan dilaksanakan terlebih dahulu. 5. Shortest Job First: (4) P₂ P₂ Proses seterusnya WT dikira dengan dalam jadual ialah menambah WT P₂. proses sebelumnya iaitu P₁ (iaitu 5) Adakah P₂ dengan BT-nya mempunyai sendiri (P₁) iaitu 6. tiba serentak TOPIC 2: MEMORY AND PROCESS MANAGEMENT 1. AT terendah ? DAN pada AT = 0. 2. BT terendah? WT (P₂) = WT(P₁) + BT(P₁) Process BT (ms) WT (ms) =5+6 Berapakah WT = 11 ms P₃ 5 0 Gantt Chart Gantt Chart untuk P₂ ? P₃ P₁ P₂ P₃ P₁ P₂ P₁ 6 + 5 0 5 0 5 11 P₂ 7 11 +5 +? +5 +6 P₄ 8 Nota: AT: Arrival Time || BT: Burst Time || WT: Waiting Time || WList: Waiting List VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 23 || GO TO “LEARNING OBJECTIVES” SLIDE || + Kira "Waiting Time" Latihan 1: Langkah demi langkah... Lukis Carta Gantt mengikut jadual baharu Rujuk Carta Alir. Syarat Utama NP SJF ialah AT DAN BT terendah akan dilaksanakan terlebih dahulu. 5. Shortest Job First: (5) P₄ P₄ Proses seterusnya WT dikira dengan dalam jadual ialah menambah WT P₄. proses sebelumnya iaitu P₂ (iaitu 11) Adakah P₄ dengan BT-nya mempunyai sendiri (P₂) iaitu 7. tiba serentak TOPIC 2: MEMORY AND PROCESS MANAGEMENT 1. AT terendah ? DAN pada AT = 0. 2. BT terendah? WT (P₄) = WT(P₂) + BT(P₂) Process BT (ms) WT (ms) = 11 + 7 Berapakah WT = 18 ms P₃ 5 0 Gantt Chart Gantt Chart untuk P₄ ? P₃ P₁ P₂ P₄ P₃ P₁ P₂ P₄ P₁ 6 5 0 +5 5 +6 11 +? 0 +5 5 +6 11 +7 18 P₂ 7 + 11 Carta ini belum siap P₄ 8 18 kerana tiada nilai terakhir pada timeline. Nota: AT: Arrival Time || BT: Burst Time || WT: Waiting Time || WList: Waiting List VERSION: 03102023_1_EFFECTIVE: SESSION_II_2023/2024 ​TOPIC 1: INTRODUCTION TO OPERATING SYSTEMS​​ 24 || GO TO “LEARNING OBJECTIVES” SLIDE || + Kira "Waiting Time" Latihan 1: Langkah demi langkah... Lukis Carta Gantt mengikut jadual baharu Rujuk Carta Alir. Syarat Utama NP SJF ialah AT DAN BT terendah akan dilaksanakan terlebih dahulu. 5. Shortest Job First: TaT TaT (6) Nilai terakhir di Sama seperti kiraan WT. proses P₄ bukan WT, sebaliknya TaT dikira dengan Rujuk dipanggil formula di menggunakan Turnaround Time bahagian formula: (TaT). Terminologi. TaT = CT – AT TOPIC 2: MEMORY AND PROCESS MANAGEMENT CT (P₄) = WT(P₄) + BT(P₄) Seperti WT, semua Process BT (ms) WT (ms) = 18 + 8 proses juga = 26 ms mempunyai TaT. AT = 0 ms P₃ 5 0 TaT (P₄) = 26 - 0 P₁ 6 5 Bagaimana mengira = 26 ms Jawapan Akhir TaT bagi P₄ untuk Gantt Chart P₂ 7 11 dilukiskan di dalam Carta Gantt ini? P₃ P₁ P₂ P₄ P₄ 8 + 18 0 5 11 18 26

Use Quizgecko on...
Browser
Browser