Jerry Khoo wrote:

My problem is this:

i am currently in taking OS course, and my lecturer would like us to

find ways to construct a CPU algorithm such as SJF(shortest Job

First), SRTF (Shortest Remaining Time First), and since i know not

much about the construction is there anyone who can help me to built

such algorithm? Thankz!

You need to define the problem a bit better, and perhaps post any work

you've done so far.

I would argue that it isn't possible to implement SJF for a general

case(though it is still useful as a theoretically optimal lower bound on

average waiting time). To implement SJF, you need to know for how long

a process is going to run. The only way you can know this (in the

general case) is to run the process and see, but that defeats the point

of trying to schedule when it will run. The same is true for SRTF.

Are you somehow given the running time/remaining time for each process,

or do you have to estimate them? If you must estimate, what information

is available to your algorithm?

If you already have the values available, the algorithm seems as simple

as sorting a list the processes by running time/remaining time, then

sequentially executing each.

Alan