can anyone pls help me to complete this questions?? i'm new in programming , n i'm not very sure how to even start to do this programs....so help needed urgently..preferably the program can be done in Java or C ++...
thank u

No1. Develop a program to simulate a computer using a Round-Robin scheduling algorithm with a time slice of 10 milliseconds and with a ready queue but no device queue. Assume that each process has a random service time of 1 to 9 seconds. Accept processes over a 20 seconds period but continue the simulation until all processes are complete.

No.2 Develop a program to simulate a computer using a preemptive Shortest Job First scheduling algorithm with a ready queue but no device queue. Assume that each process has a random service time of 1 to 9 seconds. Accept processes over a 20 seconds period but continue the simulation until all processes are complete.

No.3 One solution to the problem of avoiding indefinite post ponement of processes is aging, in which the priorities of waiting processes increase the longer they wait. Develop 2 aging algorithms and write simulation programs to examine their relative performance.

Dani AI

Generated

A concise, practical plan for the three tasks posted by . Treat simulation time in milliseconds (1 s = 1000 ms). Generate process arrivals only during the first 20,000 ms; give each process a service time uniformly random from 1000..9000 ms. Use a small Process record (id, arrival, service, remaining, start, finish, waited) and collect metrics: average waiting time, average turnaround, throughput, and max wait. Ignore the unconstructive replies from , and — this is a standard simulation exercise — and note that pointed to an implementation example that can help with reference code.

Round‑Robin (10 ms quantum): an event-driven loop is simplest and efficient. Keep a FIFO ready queue and a sorted arrival list. Advance time to the next event (arrival, quantum expiry, or completion). When a process runs, decrement remaining by min(quantum, remaining), record start when first run, enqueue new arrivals that occur during the slice, and requeue the process if it still has remaining time.

# unit = ms
time = 0
ready = []
i = 0  # next arrival index

while i < arrivals.size or ready:
  if not ready:
    time = max(time, arrivals[i].arrival)
    enqueue arrivals with arrival <= time
  p = dequeue(ready)
  if p.start == -1: p.start = time
  run = min(10, p.remaining)
  time += run
  p.remaining -= run
  enqueue arrivals with arrival <= time
  if p.remaining > 0: enqueue(p)
  else: p.finish = time

Preemptive SJF (SRTF): use a priority queue keyed by remaining time. On each arrival, compare its remaining with the currently running process; if smaller, preempt the running process and push it back to the PQ. Use the event-driven pattern above but choose next event as the earlier of next arrival or current completion.

Aging — two algorithms to compare:

  • Fixed increment: give every waiting process a priority counter that increments every X ms (e.g., 500 ms). Scheduler picks highest priority; tie-break on remaining time.
  • Effective-remaining decay: compute key = remaining - alpha * waited (alpha tunes strength). Pick smallest key; recompute on arrivals and scheduling points.

Run each simulation many times with different RNG seeds, record averages and variances, and plot waiting vs service size to see starvation effects. Watch for common bugs: mixing seconds/ms, not enqueuing arrivals that occur during a quantum, and off-by-one time advances.

Reference material: Round‑robin scheduling, , .

Recommended Answers

All 4 Replies

:rolleyes:

You must be in the most difficult beginning programming class imagineable.

I would drop that class asap. This looks like an advanced programming class and my guess is that you have very little basic programming under your belt.

Regards,

Nate

or he made it past the introductory courses using the same tactics (let others do the work for him and cheat on any written tests) and now thinks he's a programmer.

Do your own homework kid, and as said if it's way above your head you've clearly chosen the wrong courses.

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.