Question: Please code C code for below CPU Scheduling. Scheduling Algorithms This project involves implementing several different process scheduling algorithms. The scheduler will be assigned a

Please code C code for below CPU Scheduling.

Scheduling Algorithms

This project involves implementing several different process scheduling algorithms. The scheduler will be assigned a predefined set of tasks and will schedule the tasks based on the selected scheduling algorithm. Each task is assigned a priority and CPU burst. The following scheduling algorithms will be implemented:

First-come, first-served (FCFS), which schedules tasks in the order in which they request the CPU.

Priority scheduling, which schedules tasks based on priority.

Round-robin (RR) scheduling, where each task is run for a time quantum (quantum = 3 or for the remainder of its CPU burst).

For the FCFS and RR, use the arriving order, T1, T2, T3, T4, T5, and need not consider priority.

Priorities range from 1 to 10, where a higher numeric value indicates a higher relative priority. For round-robin scheduling, the length of a time quantum is 10 milliseconds.

I. Implementation

The implementation of this project may be completed in either C or Java, and program files supporting both of these languages are provided in the source code download for the text. These supporting files read in the schedule of tasks, insert the tasks into a list, and invoke the scheduler.

The schedule of tasks has the form [ task name] [ priority] [ CPU burst], with the following example format:

Input format:

T1, 4, 20

T2, 2, 25

T3, 3, 25

T4, 3, 15

T5, 10, 10

Output format:

0 | T5 10 | T1 30 | T3 55 | T4 70

| T2

95

Thus, task T1 has priority 4 and a CPU burst of 20 milliseconds, and so forth. It is assumed that all tasks arrive at the same time, so your scheduler algorithms do not have to support higher-priority processes preempting processes with lower priorities. A higher number means higher priority.

If you want to start from the attached files, please reference the following:

II. C Implementation Details

The file driver.c reads in the schedule of tasks, inserts each task into a linked list, and invokes the process scheduler by calling the schedule() function. The schedule() function executes each task according to the specified scheduling algorithm. Tasks selected for execution on the CPU are determined by the pick next task() function and are executed by invoking the run() function defined in the CPU.c file. A Makefile is used to determine the specific scheduling algorithm that will be invoked by the driver. For example, to build the FCFS scheduler, we would enter

make fcfs

and would execute the scheduler (using the schedule of tasks schedule.txt) as follows:

./fcfs schedule.txt

Refer to the README file in the source code download for further details. Before proceeding, be sure to familiarize yourself with the source code provided as well as the Makefile.

III. Java Implementation Details

The file Driver.java reads in the schedule of tasks, inserts each task into a Java ArrayList, and invokes the process scheduler by calling the schedule() method. The following interface identifies a generic scheduling algorithm, which the five different scheduling algorithms will implement:

public interface Algorithm

{

// Implementation of scheduling algorithm

public void schedule();

// Selects the next task to be scheduled

public Task pickNetTask();

}

The schedule() method obtains the next task to be run on the CPU by invoking the pick next task() method and then executes this Task by calling the static run() method in the CPU.java class.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!