keeping track of how much time process has recently had - Minix

This is a discussion on keeping track of how much time process has recently had - Minix ; hi i have a question regarding problem 45: modify the scheduler to keep track of how much cpu time each user process has had recently. when no task or server wants to run, pick the user process that has had ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: keeping track of how much time process has recently had

  1. keeping track of how much time process has recently had

    hi
    i have a question regarding problem 45:

    modify the scheduler to keep track of how much cpu time each user
    process has had recently. when no task or server wants to run, pick the
    user process that has had the smallest cpu share

    i dont really understand whats mean with "how much time each user
    process has had RECENTLY"
    i did the following: i introduced the following variables in proc.c:

    clock_t recent_time[NR_TASKS + NR_PROCS], stopwatch;

    all elements are zeroed out in main()

    then, every time pick_proc() is called, this is done (right at the
    start):

    realtime = get_uptime();
    recent_time[proc_ptr->p_nr + NR_TASKS] = realtime - stopwatch;
    stopwatch = realtime;

    then, the next task (if ready) is picked round-robin-wise
    if no task is ready, that process is picked which has the lowest
    corresponding value in recent_time[]

    i'm not sure that's what is mean with the exercise
    ill be happy to read what you think

    thanx,

    martin


  2. Re: keeping track of how much time process has recently had

    All,

    On 21 Dec 2006 09:50:27 -0800, sancho1980 wrote:
    > hi
    > i have a question regarding problem 45:
    >
    > modify the scheduler to keep track of how much cpu time each user
    > process has had recently. when no task or server wants to run, pick the
    > user process that has had the smallest cpu share
    >
    > i dont really understand whats mean with "how much time each user
    > process has had RECENTLY"
    > i did the following: i introduced the following variables in proc.c:
    >
    > clock_t recent_time[NR_TASKS + NR_PROCS], stopwatch;
    >
    > all elements are zeroed out in main()
    >
    > then, every time pick_proc() is called, this is done (right at the
    > start):
    >
    > realtime = get_uptime();
    > recent_time[proc_ptr->p_nr + NR_TASKS] = realtime - stopwatch;
    > stopwatch = realtime;
    >
    > then, the next task (if ready) is picked round-robin-wise
    > if no task is ready, that process is picked which has the lowest
    > corresponding value in recent_time[]


    (a) There is always a ready process - that's the purpose of IDLE, to
    always have a ready process to schedule.

    (b) If there weren't, your algorithm would pick a process that isn't
    ready! That would be a disaster.

    I would think that what the assignment is getting at, is selecting the
    process that _is_ ready, _and_ that has received the least cpu time
    'recently', where you get to decide what 'recently' is. So
    non-cpu-intensive processes processes are rewarded by getting cpu
    time. 'recently' would be the 'punishment horizon' - cpu time spent
    within the 'punishment horizon' is taken into account when deciding who
    has received most cpu time.

    I think your code in pick_proc() doesn't do this. It stores how many
    ticks each process received the last time it was scheduled, which
    doesn't have any relation to the 'punishment horizon' - it's only the
    last scheduled instance.

    I suggest you either use a decaying average of recently allocated cpu
    time, or simply accumulate allocated cpu time and periodically (every
    time you decide 'recently' is over) reset everyone's to 0.

    =Ben



  3. Re: keeping track of how much time process has recently had


    Ben Gras wrote:
    > All,
    >
    > On 21 Dec 2006 09:50:27 -0800, sancho1980 wrote:
    > > hi
    > > i have a question regarding problem 45:
    > >
    > > modify the scheduler to keep track of how much cpu time each user
    > > process has had recently. when no task or server wants to run, pick the
    > > user process that has had the smallest cpu share
    > >
    > > i dont really understand whats mean with "how much time each user
    > > process has had RECENTLY"
    > > i did the following: i introduced the following variables in proc.c:
    > >
    > > clock_t recent_time[NR_TASKS + NR_PROCS], stopwatch;
    > >
    > > all elements are zeroed out in main()
    > >
    > > then, every time pick_proc() is called, this is done (right at the
    > > start):
    > >
    > > realtime = get_uptime();
    > > recent_time[proc_ptr->p_nr + NR_TASKS] = realtime - stopwatch;
    > > stopwatch = realtime;
    > >
    > > then, the next task (if ready) is picked round-robin-wise
    > > if no task is ready, that process is picked which has the lowest
    > > corresponding value in recent_time[]

    >
    > (a) There is always a ready process - that's the purpose of IDLE, to
    > always have a ready process to schedule.
    >
    > (b) If there weren't, your algorithm would pick a process that isn't
    > ready! That would be a disaster.
    >
    > I would think that what the assignment is getting at, is selecting the
    > process that _is_ ready, _and_ that has received the least cpu time
    > 'recently', where you get to decide what 'recently' is. So
    > non-cpu-intensive processes processes are rewarded by getting cpu
    > time. 'recently' would be the 'punishment horizon' - cpu time spent
    > within the 'punishment horizon' is taken into account when deciding who
    > has received most cpu time.
    >
    > I think your code in pick_proc() doesn't do this. It stores how many
    > ticks each process received the last time it was scheduled, which
    > doesn't have any relation to the 'punishment horizon' - it's only the
    > last scheduled instance.
    >
    > I suggest you either use a decaying average of recently allocated cpu
    > time,


    do you mean rather something like this (in pick_proc):

    recent_time[proc_ptr->p_nr + NR_TASKS] =
    (recent_time[proc_ptr->p_nr + NR_TASKS] >> AGE_SHIFT) + realtime -
    stopwatch;


+ Reply to Thread