View Single Post
Join Date: Jun 2004
Posts: 436
Reputation: Chainsaw is an unknown quantity at this point 
Solved Threads: 10
Chainsaw's Avatar
Chainsaw Chainsaw is offline Offline
Unprevaricator

Re: Need help with CPU scheduling algorithms

 
0
  #2
Jul 6th, 2004
I never know how much help to give on homework problems (CSGAL, Are there guidelines?), but let me give you some juice for the brain to think about organization....

I'm not sure what the acronyms FCFS, SJF, RR, and "multi-level feedback queue" mean, but a scheduler is generally a few queues. Here's where I'd start:

I'd have a queue for processes READY to run and waiting for the CPU. Perhaps the FRONT of that queue is by definition the 'currently running process'.

I'd have another queue for processes currently BLOCKED. This is where processes hang out waiting for their I/O time to elapse.

So, initially all 30 processes are on the READY queue (are they in any particular order? Are there priorities involved?). The FRONT process is 'running' for however long your grid says, and then it is removed from the front of the READY queue and placed at the rear of the BLOCKED queue. Then the newly first process on the READY queue is 'running'.

I guess if it were me, I'd order the BLOCKED queue by the 'time when it should be unblocked' for simplicity, though that isn't a real-world thing (in the real world you wouldn't know how long I/O was going to take). But, heck, school isn't real. :-)

What is on the queues? I'd want the process number, of course, and maybe the time it got onto the queue, maybe some totals (number of delays, total delay time, whatever) so you can do your calculations later.

You didn't specify whether the I/O device all these processes are waiting on is the same device, and so whether if one processes is waiting for the I/O, then the other processes wait in line. If so, you might need some structure that simulates the I/O device (current task using it maybe, when that started or when it should finish).

so, a couple of classes, a couple of structs, "no big deal" :-)