School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,139 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,793 people online right now. Registration is fast and FREE... Join Now!




priority process scheduling in python

 

priority process scheduling in python

the_future

11 Oct, 2009 - 07:47 AM
Post #1

New D.I.C Head
*

Joined: 11 Oct, 2009
Posts: 2

How do you implement priority process scheduling in python using lists?

User is offlineProfile CardPM
+Quote Post


code_m

RE: Priority Process Scheduling In Python

11 Oct, 2009 - 08:58 AM
Post #2

D.I.C Head
**

Joined: 21 Apr, 2009
Posts: 124



Thanked: 8 times
My Contributions
I am not sure what you mean, but a dictionary would likely be more useful.

d = {1: "Level one", 2: "Level two", 3: "Level three"}

A dictionary can hold any data type (including classes and functions). So say you define a function for each level and place them in a dictionary named "priorities", you could use it such as this:

python
level = raw_input("Priority Level: ")
execute_level = priorities[level]()


Of course you would want to handle a ValueError when you ask the user for input since you want an int type ;-)
User is offlineProfile CardPM
+Quote Post

the_future

RE: Priority Process Scheduling In Python

11 Oct, 2009 - 11:41 AM
Post #3

New D.I.C Head
*

Joined: 11 Oct, 2009
Posts: 2

QUOTE(code_m @ 11 Oct, 2009 - 08:58 AM) *

I am not sure what you mean, but a dictionary would likely be more useful.

d = {1: "Level one", 2: "Level two", 3: "Level three"}

A dictionary can hold any data type (including classes and functions). So say you define a function for each level and place them in a dictionary named "priorities", you could use it such as this:

python
level = raw_input("Priority Level: ")
execute_level = priorities[level]()


Of course you would want to handle a ValueError when you ask the user for input since you want an int type ;-)



Im trying to create a process scheduling algorithm that has a count that calculates the time from 0 to 1000. within that time frame different processes are scheduled to execute based on their arrival time and execution time. In additon, processes that have a higher priority are scheduled before processes with lower priorities.
User is offlineProfile CardPM
+Quote Post

programble

RE: Priority Process Scheduling In Python

12 Oct, 2009 - 01:50 PM
Post #4

D.I.C Regular
Group Icon

Joined: 21 Feb, 2009
Posts: 423



Thanked: 10 times
Dream Kudos: 50
My Contributions
A simple sorting algorithm could easily make sure that higher priority is executed first.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 03:26PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month