4 Replies - 7755 Views - Last Post: 14 November 2012 - 02:19 PM Rate Topic: -----

#1 the_future   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-October 09

priority process scheduling in python

Post icon  Posted 11 October 2009 - 08:47 AM

How do you implement priority process scheduling in python using lists?
Is This A Good Question/Topic? 0
  • +

Replies To: priority process scheduling in python

#2 code_m   User is offline

  • D.I.C Head
  • member icon

Reputation: 24
  • View blog
  • Posts: 202
  • Joined: 21-April 09

Re: priority process scheduling in python

Posted 11 October 2009 - 09: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:

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 ;-)
Was This Post Helpful? 0
  • +
  • -

#3 the_future   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-October 09

Re: priority process scheduling in python

Posted 11 October 2009 - 12:41 PM

View Postcode_m, on 11 Oct, 2009 - 08:58 AM, said:

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:

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.
Was This Post Helpful? 0
  • +
  • -

#4 programble   User is offline

  • (cons :dic :head)

Reputation: 50
  • View blog
  • Posts: 1,315
  • Joined: 21-February 09

Re: priority process scheduling in python

Posted 12 October 2009 - 02:50 PM

A simple sorting algorithm could easily make sure that higher priority is executed first.
Was This Post Helpful? 0
  • +
  • -

#5 salientgreen   User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 14-November 12

Re: priority process scheduling in python

Posted 14 November 2012 - 02:19 PM

View Postthe_future, on 11 October 2009 - 12:41 PM, said:

View Postcode_m, on 11 Oct, 2009 - 08:58 AM, said:

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:

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.



I would look into the heapq module, "Priority Queue Implementation" is one of the examples in the reference library.

View Postsalientgreen, on 14 November 2012 - 02:16 PM, said:

View Postthe_future, on 11 October 2009 - 12:41 PM, said:

View Postcode_m, on 11 Oct, 2009 - 08:58 AM, said:

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:

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.



I would look into the heapq module, "Priority Queue Implementation" is one of the examples in the reference library.


Also, I know this is an old thread, but it still comes up third in a google search for the topic.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1