1

I want to customize the code of minix file /usr/src/kernel/proc.c for implementing the FCFS algorithm but I am not getting any idea or clue. I have been said that, the current algorithm works with some priority level and all the processes at first go to a single queue and then using some algorithm then the processes are being assigned some priorities. But if I need to implement FCFS then I should have work with only a single queue.

But how to relate these things?

ymn
  • 2,175
  • 2
  • 21
  • 39
Tanveer Ahmed
  • 35
  • 1
  • 8
  • You might get a better response if you provided a link (URL) to where people can review the source. One possibility is to consider flattening the priorities: set everything to priority 1 (or any other suitable value). It will probably then work FCFS. If you want to disentangle things so you have but a single (unprioritized) list, you'll have to understand the code mode, knowing where the priority lists are created (and then only creating one), and maybe even removing the priority from the interfaces. However, that's much more extensive surgery on the code, and probably not just that file. – Jonathan Leffler Mar 24 '12 at 20:04
  • Thank you for this help. You mentioned that I should set the priority to 1 or any other suitable values, and in that case every queues has the same priority...but I found that, in minix there are actually 16 queues working on different priorities..but in FCFS all I need to work with only one queue in which all the processes come for operation, the link is = http://eng.upm.edu.my/~kmbs/teaching/OS/html/proc_8c.html , here in the enqueue function all the processes are being put in the MIN_USER_Q, this is the queue I need to work with.But I need further help about priorities, can u help pls ? – Tanveer Ahmed Mar 25 '12 at 11:48

1 Answers1

2

One possibility – probably not a good one – is to modify the enqueue() function:

PUBLIC void enqueue(register struct proc *rp)   
{
    /* Add 'rp' to one of the queues of runnable processes.  This function is 
     * responsible for inserting a process into one of the scheduling queues. 
     * The mechanism is implemented here.   The actual scheduling policy is
     * defined in sched() and pick_proc().
     */
    int q = rp->p_priority;                       /* scheduling queue to use */

Instead of assigning rp->p_priority, simply assign 0:

   int q = 0;

All processes are thereby enqueued on a a single priority queue (queue number 0) and you have a single FCFS system. Of course, that assumes that enqueue() is the only function that adds processes to queues. There's a decent chance that it is the only one, but you need to know most of the Minix kernel to be sure.

With that modification in place, you can then investigate whether there is too much space wasted supporting multiple queues. If there is, you can adjust the queue declarations appropriately. The queue structure is probably just an array of pointers; the space saving available is not great, therefore.

Note, however, that you probably don't want FCFS only; the priority queues are there for good reasons. For example, your interrupt handlers should be serviced more swiftly than the number-crunching monster that is working for SETI. That means that there needs to be some prioritization.

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
  • Thank you Jonathan Leffler. I am grateful to you because your instruction helped me to modify the minix kernel successfully (I guess upto now). But would you mind telling me that is there any process or function that I can check that my FCFS is working or it has some logical errors or not (there is no compilation error I am sure of that)? I would be grateful to you.. – Tanveer Ahmed Apr 03 '12 at 06:16
  • Succinctly, I don't know. But since the code is running and there is only one queue, it is a bit hard to see how it could be operating in any way other than FCFS. Maybe you can run a dozen compute-intensive processes (that don't make system calls, therefore; invert some 100x100 matrices or something) and show that your interactive terminal process(es) get held up waiting for the compute-intensive processes to finish their time slice. When computers ran at 25 MHz, it was a lot easier to see that than it is to see it now they run at 2.5 GHz instead. – Jonathan Leffler Apr 03 '12 at 07:01