Professional Documents
Culture Documents
On
For
Department of CSE/IT
Submitted By:
Pulkit Singhal 21104058
Hirdyarth Gupta 21104055
Lavish Gupta 21104054
Submitted To:
Dr. Ashish Singh Parihar
1. Introduction:
The Restaurant Order Management System with Priority Scheduling aims to
streamline the order processing in a restaurant, optimizing the turnaround time
and waiting time for each order. The system employs a Priority Scheduling
algorithm to efficiently manage the execution of incoming orders based on their
booking time and arrival time.
2. Features:
• Input:
• The system accepts input for the total number of orders.
• For each order, the user provides the booking time (priority),
arrival time, and cooking time.
• Scheduling Algorithm:
• Priority Scheduling algorithm is implemented to determine the
order in which the orders are processed.
• Both booking time (priority) and arrival time are considered for
making scheduling decisions.
• Execution:
• The system simulates the execution of orders, tracking essential
details such as start time, completion time, turnaround time,
waiting time, and response time for each order.
• Output:
• A detailed table is displayed, showing the specifics of each order,
including booking time, start time, cooking time, completion time,
turnaround time, and waiting time.
• Metrics:
• The system calculates and displays the average turnaround time,
average waiting time, and average response time for all orders.
• Efficiency:
• CPU utilization and throughput of the system are measured and
displayed, providing insights into the overall efficiency of the order
processing.
3. Implementation:
• Programming Language: C++
• Functions:
• Time conversion functions for AM/PM to minutes and minutes to
time.
• Priority Scheduling algorithm to determine the order of execution.
• Display functions to showcase the order details and system metrics.
• Code:
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string.h>
using namespace std;
struct process {
int pid;
int arrival_time;
int burst_time;
int priority;
int start_time;
int completion_time;
int turnaround_time;
int waiting_time;
int response_time;
};
int timeAMPMToMin(string t) {
int a;
int tmp = (t[5] == 'P') ? 720 : 0;
if (t[0] == '1' && t[1] == '2' && t[5] == 'A') {
t[0] = '0';
t[1] = '0';
}
return a;
}
string minToTime(int a) {
string str = to_string((a / 60) / 10) + to_string((a / 60) % 10) +
":" + to_string((a % 60) / 10) + to_string((a % 60) % 10);
return str;
}
string minToTimeAMPM(int a) {
string str = minToTime(a);
return str;
}
string HourMinutesConvertor(string a) {
string hours, mins;
if ((a[1] == '1' || a[1] == '0') && (a[0] == '0')) hours = " Hr ";
else hours = " Hrs ";
if ((a[4] == '1' || a[3] == '0') && (a[3] == '0')) mins = " Mn";
else mins = " Mns";
string s = "";
s += a[0];
s += a[1];
s += hours;
s += a[3];
s += a[4];
s += mins;
return s;
}
int main() {
int n;
struct process p[100];
float avg_turnaround_time;
float avg_waiting_time;
float avg_response_time;
float cpu_utilisation;
int total_turnaround_time = 0;
int total_waiting_time = 0;
int total_response_time = 0;
int total_idle_time = 0;
float throughput;
int burst_remaining[100];
int is_completed[100];
memset(is_completed, 0, sizeof(is_completed));
string str;
cout << "Enter arrival time: " << i + 1 << ": ";
cin >> str;
p[i].arrival_time = timeAMPMToMin(str);
cout << "Enter cooking time: " << i + 1 << ": ";
cin >> p[i].burst_time;
p[i].pid = i + 1;
burst_remaining[i] = p[i].burst_time;
int current_time = 0;
int completed = 0;
int prev = 0;
while (completed != n) {
int idx = -1;
int mx = -1;
for (int i = 0; i < n; i++) {
if (p[i].arrival_time <= current_time && is_completed[i]
== 0) {
if (p[i].priority > mx) {
mx = p[i].priority;
idx = i;
}
if (p[i].priority == mx) {
if (p[i].arrival_time < p[idx].arrival_time) {
mx = p[i].priority;
idx = i;
}
}
}
}
if (idx != -1) {
if (burst_remaining[idx] == p[idx].burst_time) {
p[idx].start_time = current_time;
total_idle_time += p[idx].start_time - prev;
}
burst_remaining[idx] -= 1;
current_time++;
prev = current_time;
if (burst_remaining[idx] == 0) {
p[idx].completion_time = current_time;
p[idx].turnaround_time = p[idx].completion_time -
p[idx].arrival_time;
p[idx].waiting_time = p[idx].turnaround_time -
p[idx].burst_time;
p[idx].response_time = p[idx].start_time -
p[idx].arrival_time;
total_turnaround_time += p[idx].turnaround_time;
total_waiting_time += p[idx].waiting_time;
total_response_time += p[idx].response_time;
is_completed[idx] = 1;
completed++;
avg_turnaround_time = (float)total_turnaround_time / n;
avg_waiting_time = (float)total_waiting_time / n;
avg_response_time = (float)total_response_time / n;
cpu_utilisation = ((max_completion_time - total_idle_time) /
(float)max_completion_time) * 100;
throughput = float(n) / (max_completion_time -
min_arrival_time);
return 0;
}
4. Results:
The system successfully processes orders based on priority, minimizing
turnaround time and waiting time. The output table provides a comprehensive
overview of each order, and the calculated metrics offer valuable insights into
system performance.
5. Conclusion:
The Restaurant Order Management System with Priority Scheduling enhances
the efficiency of order processing in a restaurant setting. The Priority
Scheduling algorithm proves effective in optimizing the order execution, and
the system provides a user-friendly interface for input and output.