المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : CPU Scheduling Algorithm - with source code



A7med Baraka
12-26-2008, 10:56 PM
CPU Scheduling Algorithm Animation

Specification



You Can Download all Source Codes from Attachment


There should be 3 separate pop-up GUI views (ie. Animation View, Input View, and Statistics View) somewhere on your monitor although they might be on top of each other, giving the illusion of only one view. Feel free to adjust the size of these boxes to see them comfortably; the initial size may be too small to show all functionality.

Animation View


http://www.utdallas.edu/%7Eilyen/animation/cpu/program/aview.gif
The title of the currently/previously running CPU algorithm is displayed across the top panel. The bottom panel traces the clock time and the status of the algorithm. The main panel performs the animation by establishing a time line as the top horizontal axis and the process names as the vertical-left axis, and dynamically plots the bar graph. The entire Animation view is uneditable since user input is not needed. Caution: the animated view is not *******ed.

Statistics View


http://www.utdallas.edu/%7Eilyen/animation/cpu/program/sview.gif
This is an editable display of final statistics after the selected algorithm has finished.

Input View


http://www.utdallas.edu/%7Eilyen/animation/cpu/program/iview.gif
There are three text areas to supply input about the arrival time, service time, and the process name. As illustrated by the preset sample input, all input entities are to be isolated within each line. The process names could be strings of variable length. Arrival time and service time are to be integers. Caution: if there are idle time between arrival and service times, the horizontal time axis shown in the animation view will not be adequate.
Across the bottom panel of the Input View are the available operation control buttons including "clear", "run", "pause", "resume", and "quit".


Click "clear" to clear the input boxes, to stop the algorithm currently processing, and to enable the "run" button.
Click "run" to start the animation; to fortify the applet, the "run" button will be disenabled until "clear" button releases it.
Click "pause" to pause the animation.
Click "resume" to resume the animation.
Click "quit" to close all 3 views.


To the left of these operation buttons is the pull-down menu of CPU Scheduling algorithms available (described below) for animation.

First Come First Serve(FCFS)



This non-preemptive scheduling algorithm follows the first-in, first-out (FIFO) policy. As each process becomes ready, it joins the ready queue. When the current running process finishes execution, the oldest process in the ready queue is selected to run next.
source (http://www.utdallas.edu/%7Eilyen/animation/cpu/program/FCFS.java)
Round Robin



This scheduling policy (aka time-slicing) gives each process a slice of time before being preempted. As each process becomes ready, it joins the ready queue. A clock interrupt is generated at periodic intervals. When the interrupt occurs, the currently running process is preempted, and the oldest process in the ready queue is selected to run next. The time interval between each interrupt may vary.
source1 (http://www.utdallas.edu/%7Eilyen/animation/cpu/program/RR1.java)
source2 (http://www.utdallas.edu/%7Eilyen/animation/cpu/program/RR4.java)
Shortest Process Next



This non-preemptive scheduling algorithm favors processes with the shortest expected process time. As each process becomes ready, it joins the ready queue. When the current running process finishes execution, the process in the ready queue with the shortest expected processing time (aka service time) is selected to run next.
source (http://www.utdallas.edu/%7Eilyen/animation/cpu/program/SPN.java)
Shortest Remaining Time



This preemptive scheduling algorithm favors processes with the shortest remaining expected process time. As each process becomes ready, it joins the ready queue. This triggers an interrupt which preempts the current running process back into the ready queue. The process in the ready queue with the shortest remaining service time is selected to run next.
source (http://www.utdallas.edu/%7Eilyen/animation/cpu/program/SRT.java)
Highest Response Ratio



This non-preemptive scheduling algorithm favors processes with shorter expected service time. Nevertheless, aging processes without service will eventually get past competing shorter jobs. As each process becomes ready, it joins the ready queue. When the current process finishes execution, the process in the ready queue with the maximum response ratio is selected to run next. Response ratio = (time spent waiting for CPU + expected service time)/expected service time
source (http://www.utdallas.edu/%7Eilyen/animation/cpu/program/HRRN.java)
Feedback



This preemptive scheduling algorithm favors shorter jobs by penalizing processes that have been running longer. It achieves this by using a multilevel priority queues. When a process becomes reay, it joins the first level ready queue. After each subsequent execution interval, it is relegated to the next lower-priority queue until it joins the bottom-most level queue. At each interrupt, the process in the highest priority queue is selected to run next; the processes in the lowest priority queue are scheduled using round robin algorithm. The time interval between interrupts may vary, and the levels of ready queues may also vary.
source (http://www.utdallas.edu/%7Eilyen/animation/cpu/program/FB1.java)
System Support

Views


input view (http://www.utdallas.edu/%7Eilyen/animation/cpu/program/inputFrame.java)
anime view (http://www.utdallas.edu/%7Eilyen/animation/cpu/program/animeFrame.java)
stats view (http://www.utdallas.edu/%7Eilyen/animation/cpu/program/statsFrame.java)

Class heirarchy


Driver (http://www.utdallas.edu/%7Eilyen/animation/cpu/program/AlgAnime.java)
scheduling algorithm (http://www.utdallas.edu/%7Eilyen/animation/cpu/program/Scheduler.java)
process (http://www.utdallas.edu/%7Eilyen/animation/cpu/program/process.java)
augmented process (http://www.utdallas.edu/%7Eilyen/animation/cpu/program/RRinfo.java)
GUI listener (http://www.utdallas.edu/%7Eilyen/animation/cpu/program/GUI.java)
GUI packet (http://www.utdallas.edu/%7Eilyen/animation/cpu/program/Packet.java)



You Can Download all Source Codes from Attachment (http://www.barakasoft.com/vb/attachment.php?attachmentid=31&stc=1&d=1239457137)

loooloow88
04-11-2009, 04:09 PM
بارك الله فيك
ورزقك الله شربة ماء من يد الحبيب محمد صلى الله عليه وسلم عند الحوض لا ظمأ بعدها .

A7med Baraka
04-11-2009, 05:02 PM
بارك الله فيك
ورزقك الله شربة ماء من يد الحبيب محمد صلى الله عليه وسلم عند الحوض لا ظمأ بعدها .

اللهم أمين
شكرا جزيلا لمرورك وردك العطر :)
جزانا و إياك أن شاء الله

terry
04-12-2009, 05:05 AM
السلام عليكم
شكرا لك اولاً
هل عندك Shortest Remaining Time في الـ C او ++C

A7med Baraka
04-18-2009, 06:40 PM
السلام عليكم
شكرا لك اولاً
هل عندك Shortest Remaining Time في الـ C او ++C

w 3likm elsalam
sorry terry we dont have it by C or C++
thnx for your reply

على خطى السلف
05-01-2009, 11:19 PM
بارك الله فيكم وجزاكم الفردوس الاعلى
بجدموقع ممتاز ما شاء الله انا اول مشاركة الي هيي هاي ..بس باذن الله لي عودة لان الموقع شكله رائع

على خطى السلف
05-01-2009, 11:28 PM
بس وين ممكن الاقي
احصائيات لطبيعة دخول الداتا لل cpu
عندي مشروع محاكاة ...ومحتاجة كتير احصائيات وارقام تقريبية interarrival time لحتى اعمل عليه المشروع

X_samir_x
05-19-2009, 09:38 PM
thanxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

A7med Baraka
08-27-2009, 11:36 PM
شكرا لمروركم جميعا

ahlam_it
12-06-2009, 06:56 PM
شكراااااااااااااااا

لكن الكود ماتنفذ عندي ،، بعد اذنكم اللي عنده فكرة عن كيفية التشغيل للبرنامج ياريت يوضحها لي ...