08/07/2026
2024 April FE exam မှာ Subject A Q_13 မှာမေးသွားတဲ့ priority scheduling algorithm အကြောင်းဆွေးနွေးပါမယ်။
================================
Q_13. An operating system adopts the priority scheduling algorithm for scheduling processes. There are five processes A, B, C, D and E arriving at the same time with estimated running times of 10, 6, 2, 4, and 8 milliseconds, respectively. Their priorities are 3, 5, 2, 1, and 4, where 1 is the highest priority. What is the mean process turnaround time?
a) 14 b) 16 c) 20 d) 22
ဒီလို Q မျိုးက ခဏခဏ မေးလေ့ရှိပါတယ်။ ပေးထားချက်တွေပြောင်းလိုက်တယ်။ scheduling algorithm တွေပြောင်းလိုက်တယ်။ မေးတဲ့ ဦးတည်ချက်ပြောင်းတယ်။ ဒီလိုပုံစံမျိုးစုံနဲ့မေးပါတယ်။ ဒီလိုမေးခွန်းမျိုးအတွက် OS ရဲ့ scheduling algorithms တွေကိုသေချာနားလည်သဘောပေါက်ထားဖို့လိုပါတယ်။
OS သည် job တွေအများကြီးဝင်လာတဲ့အခါမှာ critical place (CPU) လိုနေရာမျိုးကို တစ်ပြိုင်နက်တည်း ပေးသုံးလို့မရတဲ့အတွက် ဘယ် job ပြီးရင် ဘယ် job ဝင်ရမယ်ဆိုတဲ့ပုံစံမျိုး schedule ဆွဲပေးပါတယ်။ အဲ့လိုဆွဲပေးတဲ့နေရာမှာ preemptive Scheduling နဲ့ Non preemptive Scheduling ဆိုပြီး ၂ မျိုးရှိပါတယ်။
preemptive ဆိုတာကတော့ OS က job တွေကို force သုံးပြီး halt လုပ်ပြီးအခြား job ကိုအလှည့်ပေးတာမျိုးဖြစ်ပြီး Non preemptive ဆိုတာကတော့ OS က အဲ့ဒါမျိုး force နဲ့ job တွေကို halt လုပ်တာမျိုးမလုပ်တာဖြစ်ပါတယ်။
Preemptive scheduling algorithms တွေထဲမှာ priority scheduling, time slice (or) round robin scheduling တို့ပါဝင်ပြီး Non-preemptive ထဲမှာတော့ FIFO scheduling တို့ပါဝင်ပါတယ်။
Priority scheduling အလုပ်လုပ်ပုံကတော့ job တွေမှာ priority တွေပါလာမှာဖြစ်ပါတယ်။ highest priority ရှိတဲ့ job ကိုဦးစားပေးအနေနဲ့ execute လုပ်ခွင့်ပြုမှာဖြစ်ပါတယ်။ ဒါကြောင့် low priority ရှိတဲ့ job တွေဟာ waiting time တွေတက်လာဖို့ရှိနေပါတယ်။ နောက်တစ်ခုက high priority ရှိတဲ့ job တွေကဘဲ CPU လိုမျိုးကို occupied လုပ်နေတဲ့အတွက် တစ်ယောက်တည်း monopolize သုံးနေသလိုမျိုးလည်းဖြစ်သွားနိုင်ပါတယ်။ ဒါကြောင်း low priority ရှိတဲ့ job တွေဟာ age တွေဖြစ်လာပြီး starvation လိုမျိုးကိုဖြစ်ပေါ်စေနိုင်တဲ့အတွက် dynamic priority ကိုသုံးတာမျိုးလည်းရှိလာပါတယ်။ priority scheduling မှာ priority သတ်မှတ်ပုံကတော့ shortest processing time ရှိတဲ့ job ကို high priority ပေးခြင်းကိုသုံးပါတယ်။ ဒါမှသာ အခြား job တွေရဲ့ waiting time ကိုလျော့ချနိုင်မှာဖြစ်ပါတယ်။ ဒါကတော့ priority scheduling အကြောင်းပါ။
အပေါ်က Q မှာတော့ processes 5 ခု A,B,C,D,E ဆိုပြီး arrival time ကိုတူတူပေးထားပါတယ်။ arrival time တူတဲ့အတွက် တွက်ရတာကိုလွယ်သွားစေပါတယ်။ priority တွေကတော့အစဉ်တိုင်းမဟုတ်ပါဘူး။ average turnaround time ကိုမေးထားတာဖြစ်ပါတယ်။
Turnaround time = completion time - arrival time
ဒီမှာက arrival time တူနေတဲ့အတွက် turnaround time သည် completion time ဖြစ်သွားပါတယ်။ priority နဲ့ process တွေကိုစီလိုက်ရင်တော့
process priority running time (ms) Turnarround Time
D 1 4 ms 4 ms
C 2 2 ms 6ms (C သည် သူ့ထက် priority မြင့်တဲ့ D ပြီးအောင်စောင့်ရတဲ့အတွက် waiting time 4ms ထည့်ပေါင်းရေးရပါမယ်။)
A 3 10 ms 6+10 = 16 ms
E 4 8 ms 16+ 8 = 24 ms
B 5 6 ms 24 + 6 = 30 ms
Question က the mean process turnaround time ကိုမေးတဲ့အတွက်
(4+6+16+24+30)/5 = 16 ms
correct ans: (b) ဖြစ်ပါတယ်။