1. FCFS non-preemptive (results provided)
  2. SJF non-preemptive
  3. MLFQ

Dani AI

Generated

For clarity and reproducibility, each scheduler implementation should declare input and output formats up front (suggested input: PID, arrival time, burst time). Required outputs commonly expected for homework and grading are: a Gantt-style timeline or start/completion times, per-process turnaround time (TAT), waiting time (WT), response time (first-start - arrival) and the average TAT/WT. Tie-breaking rules must be explicit (e.g., earliest arrival then lowest PID). Posting source code inline (not as a Word attachment) makes it much easier for helpers to compile and test, as pointed out.

A compact, correct FCFS non-preemptive approach is: sort processes by arrival time, simulate a clock t, handle idle gaps by advancing t to the next arrival, then for each process set start = t, completion = start + burst, update t, and compute TAT/WT. Example C++ sketch:

#include <bits/stdc++.h>
using namespace std;
struct P{int pid,arrival,burst,start,completion;};
int main(){
  int n; if(!(cin>>n)) return 0;
  vector<P> v(n);
  for(int i=0;i<n;i++){ v[i].pid=i+1; cin>>v[i].arrival>>v[i].burst; }
  stable_sort(v.begin(), v.end(), [](const P&a,const P&b){ return a.arrival<b.arrival; });
  int t=0; double sumWT=0,sumTAT=0;
  for(auto &p:v){
    if(t < p.arrival) t = p.arrival;
    p.start = t; p.completion = p.start + p.burst;
    int tat = p.completion - p.arrival, wt = p.start - p.arrival;
    sumTAT += tat; sumWT += wt; t = p.completion;
  }
  for(auto&p:v) cout<<p.pid<<" "<<p.arrival<<" "<<p.burst<<" "<<p.start<<" "<<p.completion<<"\n";
  cout<<"AvgWT="<<sumWT/n<<" AvgTAT="<<sumTAT/n<<"\n";
}

SJF (non-preemptive) requires repeatedly selecting, at current time t, the arrived process with smallest burst. A min-heap keyed by burst (then arrival/PID) yields O(n log n). Common bugs: not pushing newly arrived processes before selection, ignoring CPU idle periods, and incorrect tie-breaking.

MLFQ design choices matter: number of queues, per-queue policy (usually RR with increasing quanta), demotion on full-quantum usage, promotion/aging to prevent starvation, and a periodic global boost (reset). A simple, testable config for assignments is three queues with quanta {4,8,16}, demote on quantum expiry, promote after a fixed wait or global boost every 100 ticks. Instrumentation—printing queue transitions and first-start times—greatly speeds debugging and grading.

If you want help with something then you need help us to help you. Which means explaining what you need help with (clearly, and in your post) and showing us how far you have got in terms of code (if it's a homework assignment, which the attachment name suggests it is). Most people are not going to open a Word doc from someone they don't know (security reasons here, but it's also an unnecessary additional step that adds time into the giving help equation) especially when so little information has been given in the post. My advice would be to take a deep breath and try again...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.