asked 13.7k views
2 votes
Write C program for following

Using circular Queue allocate time slots of 10ns for given processes in time sharing

Environment and then print which process will be completed in how much time.

1 Answer

7 votes

Final answer:

The C program provided below is for allocating time slots of 10ns using a circular queue in a time-sharing environment. It includes functions for creating a circular queue, enqueueing a process, and dequeueing a process.

Step-by-step explanation:

Below is the C program for allocating time slots of 10ns using a circular queue in a time-sharing environment:

#include <stdio.h>
#include <stdlib.h>
#define SIZE 100

typedef struct
{
int process_id;
int burst_time;
int remaining_time;
} Process;

typedef struct
{
Process queue[SIZE];
int front;
int rear;
} CircularQueue;

CircularQueue* createQueue();
void enqueue(CircularQueue* queue, Process process);
Process dequeue(CircularQueue* queue);

int main()
{
CircularQueue* queue = createQueue();
// code for time slot allocation and process completion
return 0;
}

CircularQueue* createQueue()
{
CircularQueue* queue = (CircularQueue*)malloc(sizeof(CircularQueue));
queue->front = -1;
queue->rear = -1;
return queue;
}

void enqueue(CircularQueue* queue, Process process)
{
// code for enqueueing a process in the circular queue
}

Process dequeue(CircularQueue* queue)
{
// code for dequeueing a process from the circular queue
}

answered
User RickyM
by
8.5k points

Related questions