Sunteți pe pagina 1din 6

Home Home My Class Notes My Class Notes My Tutorials My Tutorials My Works My Works My Diary My Diary About About Movies

and Videos Movies and Videos


My Diary My Works | Programs Class Notes: HTML Class Notes: Microprocessor and Computer Architecture Class Notes: Software Engineering
Class Notes: OOP Class Notes: Economics Class Notes: C Programming Class Notes: Chemistry Android My Tutorials | Visual Basic
My Games | HTML CSS JQuery Class Notes: Digital Image Processing My Poems My Tutorials | Programming My Tutorials | Software
My Choice: Software My Movies: Horror My Tutorials | C++ My Tutorials | Java Script Class Notes: Theory of Computation Movies and Videos
My Tutorials | Blogspot My Tutorials | Web
FRIDAY, DECEMBER 23, 2011 FRIDAY, DECEMBER 23, 2011
Explain and Solve : Priority Scheduling of Operating
System Concepts
If you haven't read/tried the earlier problems then click the links follow:
01. First Come First Served (FCFS).
02. Shortest Job First (SJF).
03. Round Robin (RR).
Priority Scheduling: This method is quite same as the SJF but the difference is that instead of choosing the next
process to work on by the shortest burst time, CPU chooses the next process by the shortest priority value. Here, all the
processes are given a priority value. The process with the shortest (The most shortest is 1) priority will be worked on
first and so on. Now consider a CPU and also consider a list in which the processes are listed as follows,
Arrival Process Burst Time Priority
0 1 3 2
1 2 2 1
2 3 1 3
Here, Arrival is the time when the process has arrived the list, Process Number is used instead of the process name,
Burst Time is the amount of time required by the process from CPU, Priority value is what we described in the first
paragraph. Well, as the unit of time you can take anything like nano-second, second, minute etc whatever. We
consider it as second.
Now for an instance, consider the above list as the ready queue for the CPU, that is the CPU will take processes from
this list and will process it.
Here in Priority Scheduling, what will happen is as follows,
AT 0s:
There is only 1 job, that is Process-1 with Burst Time 3 and Priority 2. So CPU will do 1 second job of Process-
1. Thus Process-1 has 2s more job to be done.
AT 1s:
Now there are 2 jobs,
Process-1 that arrived at 0s and has 2s job to be done with Priority 2.
Process-2 that arrived at 1s and has 2s job to be done with Priority 1.
Here, Priority of the job Process-2 is higher (Lower value of priority is higher, that is shortest priority value is
higher), So 1s job of Process-2 will be done. Thus process-2 has more 1s job.
AT 2s:
Now there are 3 jobs,
Process-1 that arrived at 0s and has 2s job to be done with Priority 2.
Process-2 that arrived at 1s and has 1s job to be done with Priority 1.
Process-3 that arrived at 2s and has 1s job to be done with Priority 3.
Here, Process-2 has the highest priority, thus CPU will do 1s job of Process-2. So process-2 has more 0s job.
AT 3s:
Now there are 2 jobs,
Process-1 that arrived at 0s and has 2s job to be done with Priority 2.
Process-3 that arrived at 2s and has 1s job to be done with Priority 3.
Recent Works
This work is licensed
under a Creative
Commons Attribution-
NonCommercial-
NoDerivs 3.0 Unported
License.
Users Online
4
Pageviews
5 2 7 3 3 5
Describe the fundamental
steps of digital image
processing with a neat block
diagram.
Explain and Solve : Shortest
Job First (SJF) of Operating
System Concepts
Draw the internal architecture
of 8086 microprocessor.
Using MySQL Database with
Visual Basic .NET 2010
Purposes of having general
registers
(AX,BX,CX,DX,SP,BP,SI,DI)
and ALU (arithmetic and logic
unit) in 8086
Top Posts
Process-3 that arrived at 2s and has 1s job to be done with Priority 3.
Here, as Process-1 is with the highest priority (which is 2) so CPU will do 1s job of Process-1. So process-1
has more 1s job.
AT 4s:
There are 2 jobs,
Process-1 that arrived at 0s and has 1s job to be done with Priority 2.
Process-3 that arrived at 2s and has 1s job to be done with Priority 3.
Again, CPU will do 1s job of Process-1 as it is with the highest priority. Thus Process-1 has 0s more job to be
done.
AT 5s:
There is only 1 job, that is Process-3 with burst time 1 and priority 3. So CPU will do 1s job of Process-3. Thus
Process-3 has 0s more job to be done.
All Job Done.
We can show the above thing as the following time-line
Process-1 Process-2 Process-2 Process-1 Process-1 Process-3
0s 1s 2s 3s 4s 5s
A shortened view of the above time-line is as follows,
| Process-1 | Process-2 | Process-1 | Process-3 |
0 1 3 5 6
So now came the main thing, Waiting Time. Ok, Look carefully,
See the following time-line for Process-1. Here, RED marked seconds symbolizes the seconds while Process-1 was
waiting and GREEN marked second symbolizes the seconds while Process-1 was working.
Process-1 Process-2 Process-2 Process-1 Process-1 Process-3
0s 1s 2s 3s 4s 5s
Thus Process-1 waited for 2 seconds.
Process-2 did not wait, it came at 1s and worked at 1s and 2s.
But Process-3 Arrived at the List of Process at 2s with a Burst Time of 1s. But CPU started processing Process-3 at 5s.
So process-3 waited for 3s.
Process-1 Process-2 Process-2 Process-1 Process-1 Process-3
0s 1s 2s 3s 4s 5s
So total waiting time = (Waiting Time of Process-1)+ (Waiting Time of Process-2)
+ (Waiting Time of Process-3)
= (2+0+3)s
= 5s
So the average waiting time is = (Total waiting time / Number of Processes)s
= (5/3)s
= 1.66s
Ok...I think you have understood the thing. Now lets talk about the program.
Input: You will ask the user for the number of processes. Then for each process you will take its Process Number,
Arrival Time, Burst time and Priority. You dont have to worry, the number of processes wont be more than 5 or 6,
Arrival time of a process can only be equal or greater than the arrival time of its previous process and Process will be
entered as a serial number, so no problem. Priority values of 2 processes wont be same.
Output: In the output you will have to print out the shortened time-line we showed you above. For example, if the input
is as follows,
Arrival Process Burst Time Priority
0 1 3 2
1 2 2 1
2 3 1 3
Then the shortened time-line will be,
| Process-1 | Process-2 | Process-1 | Process-3 |
0 1 3 5 6
Explain and Solve : First
Come First Served (FCFS) of
Operating System Concepts
Write the differences
between Isolated I/O and
Memory Mapped I/O.
Explain and Solve : Priority
Scheduling of Operating
System Concepts
What is evolutionary software
process model?
Explain and Solve : Round
Robin (RR) of Operating
System Concepts
Dont worry much about
things you cant control
(06 Feb 2014)
(0 comments)
- ... -
.... ....
(03 Apr 2014)
(0 comments)
Find number of all the
children and grand
children of an element
with JQuery
(19 Apr 2014)
(0 comments)

...
(23 May 2014)
(0 comments)
What is function
overloading? Discuss
this.
(21 08 2013)
(0 comments)
What is this Pointer?
Give an example.
(21 08 2013)
(0 comments)
What is namespace?
(21 08 2013)
(0 comments)
Newer Posts
Who isHere !!
A visitor fromSemarang, Jawa
Tengah
viewed "Computer Programming: Explain
and Solve : Priority Scheduling of
Operating SystemConcepts" 27 secs
ago
A visitor fromSemarang, Jawa
Tengah
viewed "Computer Programming: Explain
and Solve : Priority Scheduling of
Operating SystemConcepts" 2 mins ago
A visitor fromTaiwan
viewed "Computer Programming: What is
handshaking? Write a suitable example
for handshaking with necessary
assembly codes." 6 mins ago
A visitor fromImus, Cavite
viewed "Computer Programming: Saving
images in MySQL Database fromVisual
Basic .NET2010" 9 mins ago
A visitor fromButing, Rizal
viewed "Computer Programming: What is
/ Define Demand, Demand Schedule and
Demand Curve." 9 mins ago
A visitor fromKuala Lumpur
viewed "Computer Programming: Explain
and Solve : Priority Scheduling of
Operating SystemConcepts" 10 mins ago
A visitor fromBrisbane,
Queensland
viewed "Computer Programming: Using
MySQL Database with Visual Basic .NET
2010" 12 mins ago
A visitor fromHerndon, Virginia
viewed "Computer Programming: What is
software process and software process
framework ? Explain." 16 mins ago
You can also print out the time-line vertically if you want (thats what I have done, see the output of my program)
Ok beneath this shortened time-line you will have to print a table as follows,
Process Arrival Finish Total Wait
2 1 2 2 0
1 0 4 3 2
3 2 5 1 3

Beneath this, you will have to show the Average Waiting Time.
I know you have understood, now see a screen-shot of exactly what I was talking about,
Exception: One exception is that, I said Arrival time of a process can only be equal or greater than the arrival time
of its previous process. So take a look at the following list of process,
Arrival Process Burst Time Priority
0 1 3 2
55 2 2 1
60 3 1 3
You see, the Job of Process-1 will complete at 2s, thus from 3s to 54s the CPU will remain idle. Again the job of Process-2 will
complete at 56s and thus from 57s to 59s the CPU will again remain as idle. You have to show this in the output and also notice
that none of the processes has waited. See the following screenshot,
A visitor fromKanchipuram, Tamil
Nadu
left "Computer Programming: Using
MySQL Database with Visual Basic .NET
2010" via dev.mysql.com26 mins ago
A visitor fromKanchipuram, Tamil
Nadu
viewed "Computer Programming: Using
MySQL Database with Visual Basic .NET
2010" 27 mins ago
R e a l - t i m e v i e w M e n u
2014 (4)
2013 (72)
2012 (44)
2011 (133)
December 2011 (7)
Explain and Solve : Round
Robin (RR) of Operating
...
Explain and Solve : Priority
Scheduling of Operati...
Mipony Download Manager
- One of my favorite
downl...
--
...
Explain and Solve :
Shortest Job First (SJF)
of Op...
Explain and Solve : First
Come First Served
(FCFS)...

, ...
November 2011 (2)
October 2011 (28)
September 2011 (4)
August 2011 (6)
July 2011 (16)
June 2011 (70)
List Of All
Posts
Writen by Tanmay Chakrabarty
Post is About: My Works | Programs
You can download the program (.exe) I written By Clicking Here.
Our next Scheduling algorithm will be the Round Robin Scheduling Algorithm.
+3 Recommend this on Google
Replies
Reply
Replies
Reply
Replies
Reply
Replies
Reply
Replies
20 comments:
Anonymous March 9, 2012 at 10:39 AM
nice explanation..
Reply
Tanmay Chakrabarty March 9, 2012 at 1:41 PM
Thank you. Have you tried to code it?
MEET0706 September 21, 2012 at 6:39 PM
thanx for sharing... :)
Reply
Tanmay Chakrabarty September 21, 2012 at 11:42 PM
Welcome....share if you have done this....
Saurabh November 23, 2012 at 11:01 AM
Great work man!!!!
Reply
Tanmay Chakrabarty November 23, 2012 at 12:20 PM
Thanks man...
sami malik January 22, 2013 at 5:07 PM
Amazing Work dude i must Say Good effort
Reply
Tanmay Chakrabarty January 22, 2013 at 5:44 PM
Thanks. Have you tried it ...
VASANTH February 18, 2013 at 9:46 PM
my doubt was cleared.keep it up tanmay
Reply
Tanmay Chakrabarty February 20, 2013 at 2:44 PM
Reply
Replies
Reply
Replies
Reply
Replies
Reply
Replies
Nice to know that these notes are helping ...
Erin Estrada August 1, 2013 at 9:48 AM
i have 3 process:
Process BurstTime Arrival Time Priority
1 1 1 2
2 5 3 1
3 5 0 3
this is the result:
P1 IDLE P2 P3
1 2 3 8 13
the question is, how come that P1 was processed first when it is actually 2nd in its priority?
Reply
Tanmay Chakrabarty August 1, 2013 at 1:00 PM
Its because, P1 arrived at 1s when there was no more processes(P2 came at 3s), thus CPU process 1s of P1 at 1s,
then remained IDLE at 2s, then the P2 arrived and got processed.
Also NOTE: I stated, in my program each process will have Arrival Time greater or equal to its previous process. You
gave Arrival Time 0 to P3 where P2 is having Arrival Time 3, which is a wrong input. I thought these limitations will be
challenges for those who will code it later.
Erin Estrada August 2, 2013 at 10:05 AM
oh i see, thanks for the help! by the way i am done with the round robin scheduling using magic software and i really
wanna thank you and your notes for helping me :3
Tanmay Chakrabarty August 4, 2013 at 11:42 AM
You are welcome ...
Anonymous September 3, 2013 at 10:04 AM
how i wish i can output the same as what you have. We will have a program Priority scheduling for our final. I do hope this blog
can help. Thanks and more power to you sir.
Reply
Tanmay Chakrabarty September 3, 2013 at 10:54 AM
I am sure you will be able to and nice to that these notes and posts are helping other students.
Himanshu Maurya September 23, 2013 at 7:11 AM
Great work bro..this is very good site of study ,everything is in very simple way.easy to understand.i like this site very much.... :)
Reply
Tanmay Chakrabarty September 23, 2013 at 10:37 AM
Thank you for your complements.
Anonymous October 3, 2013 at 12:45 AM
A lower priority job can block a high priority one (e.g., priority inversion
problem) even a priority scheduling is used ..
Reply
Tanmay Chakrabarty October 3, 2013 at 12:54 AM
Haven't studied Priority Inversion Problem....
Newer Post Older Post Home
Subscribe to: Post Comments (Atom)
Reply
Enter your comment...
Comment as: Select profile...
Publish Publish

Preview Preview
Leave your valuable thoughts before leaving..
Create a Link
Links to this post
TanmayOnRun
+ 38
Follow +1
All these |POSTS| |NOTES| |TUTORIALS| |OTHERS| are hard works of mine, except otherwise stated. Use these wherever you want, just don't
forget to do the following things;
01. Make me known first.
02. Mention the credit where you will use.
02. Provide a backlink to my original post,highlighted enough.
Thanks a lot for being here. Leave your valuable comments before leaving.
Thank you

S-ar putea să vă placă și