Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 3: Job Scheduler (20%) (C programming C programming C programming, please help me before 22th, Feb, 23:00) In the information engineering department, professors, postgraduate

Question 3: Job Scheduler (20%)

(C programming C programming C programming, please help me before 22th, Feb, 23:00)

In the information engineering department, professors, postgraduate students and undergraduate students share every resource within the department. One famous example is the linux machines. There are N linux machines in the department. When everyone submits a job, the job is added to the job list. The job list is shared among all linux machines. If a job in the job list is selected and executed by a machine, the machine will remove the job from the list. Next, assuming that the machine can run 1 program at a time, the available machines will run the job with the highest priority. If there are more than one job having the same highest priority, the machine will choose the job submitted earlier. Then, the job will be removed from the job list. The machines are labeled as machine 1, machine 2, ..., machine N. If two machines want to pick a job at the same time, the one with smaller number would pick the job first. In addition, jobs from professors have the highest priority, while jobs from undergraduate students have the lowest priority. Lastly, once the job is chosen, it will be run until it completes. You are asked to simulate the above scenario, evaluate the finish time and the label of the machine of each submitted job, and output the information accordingly.

Your program should read the input from the file, and output the answer to another file. The first argument is the input file name, while the second argument is the output file name. Name your program as lab3-q3.c. Hint: You can reuse your work in question 2 for this question.

Input file: The first line contains 2 integers, N (1 N 9) and M (1 M 100). For the following M line(s), each line consists of: S C T t. S (S = [a-zA-Z0-9]+) is the job id, which is a string. C (C {Professor, Postgraduate, Undergraduate}) is the information of the job owner, which is a character. T (1 T 1000000) is the job submission time in second, represented by an integer. t (1 t 10000) is the expected running time, which is also an integer. It is given that the jobs are already sorted by T.

Output file: You should output M line(s). Each line consists of: S R m. S is the job id, which is a string. R is the finish time in second. m is the machine label corresponding to the job. The order of output is the same as the order of the input jobs.

Sample Input:

13 secret Professor 1000 100 topsecret Professor 1001 100 toptopsecret Professor 2000 100

Sample Output:

secret 1100 1 topsecret 1200 1 toptopsecret 2100 1

Explanation: Three jobs, secret, topsecret and toptopsecret are submitted to the job list. They are all submitted by professors with submission time 1000, 1001 and 2000 respectively. The expected time for the jobs is all 100. At 1000, secret is selected by machine 1 and run for 100. At 1001, the only machine, machine 1, is busy with job secret, so, topsecret has to wait until secret is finished. At 1100, machine 1 finishes secret and start topsecret. As toptoptopsecret is submitted at 2000 and no jobs are running on machine 1, so, toptopsecret is executed at 2000 and finished at 2100.

image text in transcribed

Question 3: Job Scheduler (20%) In the information engineering department, professors, postgraduate students and undergraduate students share every resource within the department. One famous example is the linux machines. There are N linux machines in the department. When everyone submits a job, the job is added to the job list. The job list is shared among all linux machines. If a job in the job list is selected and executed by a machine, the machine will remove the job from the list. Next, assuming that the machine can run 1 program at a time, the available machines will run the job with the highest priority. If there are more than one job having the same highest priority, the machine will choose the job submitted earlier. Then, the job will be removed from the job list. The machines are labeled as machine 1, machine 2, ..., machine N. If two machines want to pick a job at the same time, the one with smaller number would pick the job first. In addition, jobs from professors have the highest priority, while jobs from undergraduate students have the lowest priority. Lastly, once the job is chosen, it will be run until it completes. You are asked to simulate the above scenario, evaluate the finish time and the label of the machine of each submitted job, and output the information accordingly. Your program should read the input from the file, and output the answer to another file. The first argument is the input file name, while the second argument is the output file name. Name your program as "lab3-93.c". Hint: You can reuse your work in question 2 for this question. Input file: The first line contains 2 integers, N (1 SNS 9) and M (1 SM s 100). For the following M line(s), each line consists of: 'S C Tt'. S (S = [a-zA-Z0-9]+) is the job id, which is a string. C (C {"Professor", "Postgraduate", "Undergraduate"}) is the information of the job owner, which is a character. T (1 ST

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 15th International Conference Dasfaa 2010 Tsukuba Japan April 2010 Proceedings Part 1 Lncs 5981

Authors: Hiroyuki Kitagawa ,Yoshiharu Ishikawa ,Wenjie Li ,Chiemi Watanabe

2010th Edition

3642120253, 978-3642120251

Students also viewed these Databases questions

Question

d. Would you implement the new control algorithm?

Answered: 1 week ago