Simulation of CPU Scheduling Algorithms Gaming Project in C++

Explanation:

  1. Process Structure:
    • Contains process details: id, arrivalTime, burstTime, waitingTime, and turnaroundTime.
  2. calculateFCFS Function:
    • Calculates waiting and turnaround times for the First-Come, First-Served scheduling.
    • The first process has zero waiting time, and each subsequent process waits for the previous one to complete.
  3. calculateSJF Function:
    • Calculates waiting and turnaround times for the Shortest Job First scheduling.
    • Processes are sorted by burstTime, then FCFS scheduling is applied to the sorted list.
  4. printProcessDetails Function:
    • Prints the process details in tabular format.
  5. main Function:
    • Initializes a list of processes with IDs, arrival times, and burst times.
    • Calls calculateFCFS and calculateSJF to compute scheduling metrics.
    • Prints the results for both scheduling algorithms.

      Compilation:

      To compile the program, use:

      Run the program with:
       

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top