Implement FCFS and SJF scheduling algorithms in C

Programming Style Guidelines:

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

The major purpose of programming style guidelines is to make programs easy to read and understand. Good programming style helps make it possible for a person knowledgeable in the application area to quickly read a program and understand how it works.1. Your program should begin with a comment that briefly summarizes what it does. For this course, this comment should also include your Name and pantherID.2. Use additional comments when needed in order for a reader to understand what is happening (see also, point 3).3. Variable names and function names should be sufficiently descriptive so that a knowledgeable reader can easily understand what the variable means and what the function does. If this is not possible, comments should be added to make the meaning clear.4. Use consistent indentation to emphasize block structure.5. Use names of moderate length for variables. Most names should be between 2 and 12 letters long.6. Use either underscores or capitalization (camelNaming) for compound names for variables. e.g: tot_vol, total_volumn, or totalVolumn. 

Objective

Implement FCFS and SJF scheduling algorithms in C and calculate the average waiting time and average turnaround time of concurrent processes.

Description:

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Input:  the number of processes along with the burst time and arrival time for each process. In addition to the desired scheduling algorithm (FCFS or SJF). The program should expect a file name and a scheduling algorithm as arguments.

Ex: myprogram myfile.txt FCFS

The file should contain the number of processes in the first line. Then, each following line should contain the burst time and arrival time of one process as follows:

“`

“`

You can find an example of the input file

here

and the code for reading the content of the file here

Note that this example is NOT the test case for grading.

the program should calculate the waiting time and turnaround time for each process if the selected scheduling algorithm was used and output the average waiting time and average turnaround time.

Output: order of execution of the processes (ex: P1 -> P3 -> P6) and the average waiting time and average turnaround time.

Sample Output:

Order of Execution: P1 -> P2 -> P3Average Waiting Time: 2.33Average Turnaround Time: 8.33 5
0 5
1 4
3 2
4 3
5 2#include
#include
int main(int argc, char **argv)
{
FILE *file;
int num_process;
int *arrival;
int *burst;
// Open the file
file = fopen(argv[1], “r”);
// Read the first line – number of processes, note the ‘&’ operator before num_process
fscanf(file, “%d”, &num_process);
// Allocate the arrays to store the arrival time and burst time, one element for each process
arrival = (int *)malloc(num_process * sizeof(int));
burst = (int *)malloc(num_process * sizeof(int));
// Read each line of the file for arrival time and burst time, note that no ‘&’ operator used here
for (int i = 0; i < num_process; i++) { fscanf(file, "%d", arrival + i); fscanf(file, "%d", burst + i); } // You should close the file after reading, even though it's usually ok to forget fclose(file); // In this example I only print the values, in your assignment you have to compute the execution sequence // as well as the average waiting time and average turnaround time printf("There are %d processes\n", num_process); for (int i = 0; i < num_process; i++) { printf("Process %d arrives at %d with burst time %d\n", i + 1, arrival[i], burst[i]); } // And remember to release the dynamically allocated memory after using free(arrival); free(burst); return 0; }

Calculate your order
275 words
Total price: $0.00

Top-quality papers guaranteed

54

100% original papers

We sell only unique pieces of writing completed according to your demands.

54

Confidential service

We use security encryption to keep your personal data protected.

54

Money-back guarantee

We can give your money back if something goes wrong with your order.

Enjoy the free features we offer to everyone

  1. Title page

    Get a free title page formatted according to the specifics of your particular style.

  2. Custom formatting

    Request us to use APA, MLA, Harvard, Chicago, or any other style for your essay.

  3. Bibliography page

    Don’t pay extra for a list of references that perfectly fits your academic needs.

  4. 24/7 support assistance

    Ask us a question anytime you need to—we don’t charge extra for supporting you!

Calculate how much your essay costs

Type of paper
Academic level
Deadline
550 words

How to place an order

  • Choose the number of pages, your academic level, and deadline
  • Push the orange button
  • Give instructions for your paper
  • Pay with PayPal or a credit card
  • Track the progress of your order
  • Approve and enjoy your custom paper

Ask experts to write you a cheap essay of excellent quality

Place an order

Order your essay today and save 30% with the discount code ESSAYHELP