Please help me! Some homework help appreciated here, thanks!
I'm trying to simulate a server (e.g. a cpu) which accepts requests (e.g. processes). All requests (theoretically) come in at the same time. Each request consists of the amount of cpu time it needs in addition to a priority on a scale of 1-5 or 1-10 or something to the like. I need a function which calculates a Priority Rating (PR) as well as a "penalty" which manipulates these two variables. My server's queue is then ordered by the PR to decrease the amount of cpu time while still handling priority. In other words, some form of a penalty must be in place the longer high priority processes have to wait in the queue.
Does anyone have any ideas of some general algorithm I can consider? Or somewhere I could go for some help on this. My entire program is written except for this one function:
// THIS IS A DUMMY FUNCTION
// AN APPROPRIATE ALGORITHM WILL BE DETERMINED IN THE FUTURE
int calc_pr(int cpu_time, int request_priority)
{
return (cpu_time * request_priority);
}