scheduling process
I already have the coding in C
#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.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fb3ca08ef-0084-46b2-a54c-ed2fa24a8988%2Fbf2ba986-fd80-4a47-8ee0-0ea11c18e8b1%2F9nw9z4_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)