scheduling process

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I already have the coding in C programming. But I think, function to calculate average waiting time doesn't working. And this coding doesn't work to give the Platinum customer priority. I hope you can give me new coding or fix this coding thank you.

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>

struct Queue // circular queue struct
{
int size;
int front;
int rear;
int *time_arr;
};

int isEmpty(struct Queue *q) // function to check is queue is empty
{
if (q->rear == q->front)
{
return 1;
}
return 0;
}

void enqueue(struct Queue *q, int time) // funntion to enqueue elements into the queue
{

q->rear = (q->rear + 1) % q->size;
q->time_arr[q->rear] = time;
}

int dequeue(struct Queue *q) // funciton to dequeue elements from queue
{
int a = -1;

q->front = (q->front + 1) % q->size;
a = q->time_arr[q->front];
}

int main()
{
// creating queue instances for gold and platinum customers
struct Queue gold_customer;
struct Queue platinum_customer;

// fixing size of queue as 10 , although user can change as per requirement
gold_customer.size = 10;
platinum_customer.size = 10;

// setting front and rear position of queue
gold_customer.front = gold_customer.rear = 0;
platinum_customer.rear = 0;
platinum_customer.front = 0;

// dynamically allocating the queue array space
gold_customer.time_arr = (int *)malloc(gold_customer.size * sizeof(int));
platinum_customer.time_arr = (int *)malloc(platinum_customer.size * sizeof(int));

printf("Enter total number of customers : \n");
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
printf("Select the type of customer you are : \n1.Gold 2.Platinum\n\n");
int x;
scanf("%d", &x);

int random;

if (x == 1)

{

random = rand() % 30;
enqueue(&gold_customer, random);
printf("Your expected waiting time is %dS. Thankyou for your patience. \n\n", random);
}

if (x == 2)

{
random = rand() % 30;
enqueue(&platinum_customer, random);
printf("Your expected waiting time is %dS. Thankyou for your patience. \n\n", random);
}
}
printf("\n\n");
while (isEmpty(&platinum_customer) == 0)

{

printf("Platinum customer with time expected %ds is served. \n", dequeue(&platinum_customer));
}

while (isEmpty(&gold_customer) == 0)

{
printf("Gold customer with time expected %ds is served. \n", dequeue(&gold_customer));
}

return 0;
}

.
Task 1: Application of scheduling process in a phone answering system.
System Details: -
Tell Tone Sdn. Bhd. is a telecommunication company that has a phone answering system for its customer
service centre. Whenever customers call the customer service center, they will be put in a queue before
they are being served by the customer service representative. If the operators are busy, the customers
are asked to wait and given a certain number. The time that a customer has to wait could be as short as a
minute or as long as 30 minutes. This also depends on the types of customer. Platinum customer will be
given a higher priority compared to a Gold customer. Thus, when a call from a Platinum customer came,
it will be processed first. If there are no Platinum customer left in the queue, the system will serve the
Gold customer.
Demonstrate the scheduling process of a switch in a phone answering system by using queue.
Construct a program to demonstrate the problem.
Calculate the average waiting time for each call.
Transcribed Image Text:Task 1: Application of scheduling process in a phone answering system. System Details: - Tell Tone Sdn. Bhd. is a telecommunication company that has a phone answering system for its customer service centre. Whenever customers call the customer service center, they will be put in a queue before they are being served by the customer service representative. If the operators are busy, the customers are asked to wait and given a certain number. The time that a customer has to wait could be as short as a minute or as long as 30 minutes. This also depends on the types of customer. Platinum customer will be given a higher priority compared to a Gold customer. Thus, when a call from a Platinum customer came, it will be processed first. If there are no Platinum customer left in the queue, the system will serve the Gold customer. Demonstrate the scheduling process of a switch in a phone answering system by using queue. Construct a program to demonstrate the problem. Calculate the average waiting time for each call.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY