Presentasi sedang didownload. Silahkan tunggu

Presentasi sedang didownload. Silahkan tunggu

Sistem Operasi (Operating Systems) Minggu 6

Presentasi serupa


Presentasi berjudul: "Sistem Operasi (Operating Systems) Minggu 6"— Transcript presentasi:

1 Sistem Operasi (Operating Systems) Minggu 6
Dr. Ananda Kusuma Universitas Multimedia Nusantara Serpong, Tangerang

2 Agenda Review kuliah Minggu 5 Revisi SAP kuliah Minggu 6 dan 7
Topik Minggu 6: CPU Scheduling (Penjadwalan CPU) Presentasi Kelompok 1 : jam

3 Review Minggu 5 Interprocess Communications: Semaphores

4 Semaphores Apa itu semaphores? Sebutkan operasi-operasi semaphores
Bagaimana semaphores digunakan untuk Critical region? Sinkronisasi pada bounded-buffer problem?

5 Producer-Consumer Problem menggunakan semaphores
Event semaphores Hitung jumlah slot kosong Hitung jumlah slot yang terisi Process/Thread producer Process/Thread consumer

6 Revisi SAP

7 Perubahan SAP Minggu 6 dan 7
Minggu ke Topik Textbook 6 Masalah-masalah klasik pada komunikasi antar process Chapter 2 7 Penjadwalan pada system interactive Deadlock Chapter 2, 6 Berubah Menjadi CPU Scheduling (Penjadwalan) Chapter 2, 7 Review untuk persiapan UTS Chapter 6

8 CPU Scheduling (Penjadwalan CPU)

9 Levels of Scheduling (Klasifikasi Tingkatan Penjadwalan)
Long-term scheduling (job scheduling) Pemilihan jobs yang akan di-load untuk berkompetisi mendapatkan system resources Medium-term scheduling Pemilihan jobs untuk di-suspend/resume dalam rangka menyeimbangkan beban system Short-term scheduling (CPU scheduling) dan Dispatching CPU scheduling is the task of selecting a waiting process fro111 the ready queue and allocating the CPU to it. The CPU is allocated to the selected process by the dispatcher. First-cosne, first-served (FCFS) scheduling is the simplest scheduling algorithm, but it can cause short processes to wait for very long processes. Shortestjob- first (SJF) scheduling is provably optimal, providing the shortest average waiting time. Implementing SJF scheduling is difficult, however, because predicting the length of the next CrU burst is difficult. The SJF algorithm is a special case of the general priority scheduling algorithm, which simply allocates the CPU to the highest-priority process. Both priority and SJF scheduling may suffer from starvation. Aging is a technique to prevent starvation Round-robin (RR) sclieduling is more appropriate for a time-shared (hiteractive) svstem. RR scheduling allocates the CPU to the first process in the ready queue for q time units, where '1 is the time quantum. After q time units, if the process has not relinquished the CPU, it is preempted, and the process is put at the tail of the ready queue. The major problem is the selection of the time quantum. If the quantum is too large, RR scheduling degenerates to FCFS scheduling; if the quantum is too small, scheduling overhead in the form of context-switch time becomes excessive. The FCFS algorithm is nonpreemptive; the RR algorithm is preemptive. The STF and priority algorithms may be either preemptive or nonpreemptive. Multilevel queue algorithms allow different algoritluns to be used for different classes of processes. The most common model includes a foreground interactive queue that uses RR scheduling and a background batch queue that uses FCFS scheduling. Multilevel feedback queues allow processes to move from one queue to another.

10 Issues on Scheduling (Hal-hal terkait Penjadwalan)
Process behaviour: cpu-bound atau I/O-bound How to deal with clock interrupts: Preemptive  process dapat di-interrupt dan melepaskan jatah CPU nya non-preemptive  begitu jatah CPU diberikan, process dapat menggunakannya terus sampai process exits atau switches to waiting state W11y is it important for the scheduler to distinguish I/O-bound programs from CPU-bound programs? I/O-bound programs have the property of performing only a small amount of computation before performing IO. Such programs typically do not use up their entire CPUquantum. CPU-bound programs, on the other hand, use their entire quantum without performing any blocking IO operations. Consequently, one could make better use of the computer’s resouces by giving higher priority to I/O-bound programs and allow them to execute ahead of the CPU-bound programs.

11 Berdasarkan Kategori Aplikasi
Batch First-Come First-Served (FCFS) Shortest Job First Shortest Remaining Time Next Interactive Round-Robin Priority Real-time Rate monotonic Earliest Deadline First

12 Scheduling Objectives
Untuk semua system Fairness Policy enforcement Balance Batch Throughput Turnaround time CPU Utilization Interactive Response time Proportionality Real-time Meeting deadline Predictability

13 Batch Systems

14 First-Come First-Served (FCFS)
Alokasikan CPU ke process sesuai dengan urutan kedatangan Implementasi Gunakan satu buah antrean FIFO (First In First Out) Performance metric: average waiting time atau average turnaround time

15 First-Come First-Served (FCFS): Contoh
Misal urutan kedatangan process: P1, P2, P3 Panjang CPU run time (burst): Waiting time: Average waiting time = ( )/3 = 17 Bagaimana kalau seandainya urutan penjadwalan diubah? P2,P3,P1  average waiting time = (6+0+3)/3 = 3 P1 P2 P3 24 27 30 Time

16 Shortest Job First (SJF)
Diasumsikan cpu run time (burst) tiap job diketahui Jadwalkan process dengan run time terpendek Contoh di slide sebelumnya, urutan penjadwalan process = P2,P3,P1 Contoh: 4 jobs A, B, C,D dengan run time a,b,c,d Average waiting time: (0+a+a+b+a+b+c)/4 = (3a+2b+c)/4 Average turnaround time: (4a+3b+2c+d)/4 Pembobotan ke metric lebih besar pada process yang lebih dulu diambil sehingga untuk meminimalkan diambil process yang terpendek

17 Shortest Job First (SJF
SJF optimal apabila semua jobs tersedia secara serentak Contoh: Menggunakan SJF, order yang optimal -> A,B,C,D,E dengan average waiting time = ( )/5 = 4.6 Kalau order diubah menjadi B,C,D,E,A, maka average waiting time = ( )/5 = 4.4

18 Shortest Time Remaining Next
Preemptive version dari SJF Scheduler menjadwalkan process dengan sisa run time terpendek Jika ada job baru datang dengan run time yang lebih pendek dari process yang sedang berjalan, maka process yang sedang berjalan di-suspend dulu dan segera eksekusi process dari job yang baru.

19 Interactive Systems

20 Round-Robin Scheduling
Penjadwalan CPU di mana tiap process mendapat giliran secara bergantian untuk menggunakan CPU. Interval waktu penggunaan CPU disebut quantum. Contoh: Quantum 1 Quantum 2

21 Round-Robin: besaran quantum
Pertukaran penggunaan CPU dari satu process ke process berikutnya membutuhkan waktu untuk tugas administrasi (context switch), mis. saving dan loading registers, memory map, updating tabel, list, dll. Pemilihan besaran quantum perlu memperhatikan trade-off: Terlalu kecil  terlalu banyak context switch dan sumber daya CPU terbuang untuk tugas administrasi Terlalu besar  respons tidak bagus untuk layanan-layanan interactive singkat Contoh: waktu switching =1 msec Waktu quantum = 10 msec  ((1/11)*100%) %  terlalu tinggi penggunaan CPU untuk keperluan administrasi Waktu quantum =100 msec  (1/101)*100%) 1%  utilisasi CPU bagus, tapi response time (interactive) jelek karena process terlalu lama menunggu giliran

22 Round-Robin: Contoh Time Misal: Time Quantum = 20, dan Time line:
Waiting Time: Average waiting time = ( )/3 = 23 Average turnaround time = ( )/3 = 26.3  Lebih jelek dibandingkan SJF, namun response time untuk tiap process lebih bagus karena kepastian giliran menggunakan CPU sesuai dengan time quantum yang ditetapkan P1 P2 P3 20 23 26 30 Time

23 Priority Scheduling (Penjadwalan dengan Prioritas)
Tiap Process diberikan prioritas, dan prioritas yang lebih tinggi lebih dahulu dijalankan Untuk mencegah process dengan prioritas tertinggi berjalan tanpa batas, dapat digunakan clock interrupt untuk menurunkan prioritasnya sehingga process yang lain dapat berjalan

24 Priority Scheduling: Penentuan Prioritas
Tiap Process diberikan prioritas, dan prioritas yang lebih tinggi lebih dahulu dijalankan Untuk mencegah process dengan prioritas tertinggi berjalan tanpa batas, dapat digunakan clock interrupt untuk menurunkan prioritasnya sehingga process yang lain dapat berjalan Cara sederhana: Gunakan rumus Prioritas=1/f , di mana f=prosentase waktu quantum yang digunakan Contoh quantum=5omsec Process P1, baru running 1 msec, di-blocked, maka f=1/50  Prioritas=50 Process P2, baru running 25 msec, di-blocked, make f=25/50  Prioritas=2 Process P1 lebih diprioritaskan dibandingkan P2 apabila keduanya ready menunggu penjadwalan CPU

25 Contoh Soal Ujian Tahun Lalu
Terdapat 5 jobs A, B, C ,D dan E dengan arrival time, run time dan prioritas masing-masing seperti tabel dibawah. ( Catatan: prioritas 4 lebih tinggi dari prioritas 3). Tentukan average waiting time dan average turnaround time dengan algoritma scheduling sbb.: First Come First Served Shortest Job First Shortest Remaining Time Next Non-preemptive Priority Scheduling Job Arrival Time (menit) Run Time (menit) Prioritas A 7 1 B 9 4 C 2 D 5 3 E -

26 Real-Time Systems

27 Real-Time Systems Real-time system: sistem di mana peranan time (waktu) adalah kritis untuk aplikasi, contoh aplikasi multinedia, proses kendali otomasi, instrumentasi, dsb. Hard real-time computing Komputasi yang mensyaratkan tugas-tugas kritis digaransi untuk dapat diselesaikan pada waktu yang ditentukan (absolute deadline) Soft real-time computing Komputasi yang mensyaratkan process yang kritis untuk mendapatkan prioritas lebih tinggi Tipe-tipe real-time schedulers Periodic schedulers: fixed arrival rate Demand-driven schedulers: variable arrival rate Deadline schedulers: prioritas ditentukan oleh deadline

28 Schedulable Criteria Jika ada m periodic events dan events i berlangsung pada periode Pi dan diperlukan CPU time Ci detik untuk handle tiap event, maka dapat dilakukan scheduling secara realtime (schedulable) apabila

29 Rate-Monotonic Scheduling (RMS)
Static real-time scheduling algorithm untuk preemptable dan periodic processes. Tiap process menggunakan CPU time yang sama untuk tiap burst Tiap process diberikan prioritas tetap didasarkan atas frekuensi terjadinya events. Dengan kata lain linear with the rate (number of times/second the process run) Contoh: process yang berjalan secara periodic tiap 50 msec ada 20 events/second  prioritas = 20 Scheduler menjalankan process dengan prioritas tertinggi, dan apabila diperlukan preempt process dengan prioritas lebih rendah yang sedang menggunakan CPU

30 Earliest Deadline First (EDF)
Dynamic real-time scheduling di mana process tidak harus periodic dan CPU run time tidak harus sama untuk tiap burst Scheduler memilih process dengan deadline yang paling dekat. Tiap kali ada process yang ready, scheduler memeriksa apakah deadline untuk process yang baru ini lebih dekat dibandingkan dengan process yang sedang berjalan, dan preempt process yang sedang berjalan apabila diperlukan

31 Contoh Scheduling dengan RMS dan EDF

32 Akhir Kuliah Minggu 6 Terima kasih atas perhatiannya!


Download ppt "Sistem Operasi (Operating Systems) Minggu 6"

Presentasi serupa


Iklan oleh Google