Experiment two job scheduling simulation program

Source: Internet
Author: User

Experiment Two Job scheduling Simulation program I. Purpose and Requirements 1. Experimental Purpose

(1) Deepen the understanding of the job scheduling algorithm;

(2) Training in program design.

2 . Experimental requirements

A simulation program that writes one or more job schedules in a high-level language.

Job scheduler for single-channel batch processing systems. When the job is put into operation, it occupies all the resources of the computer until the job is completed, so it is not necessary to schedule the job to consider whether the resources it needs are met, the time it runs, and so on.

Job scheduling algorithm:

1) The first-come-first service (FCFS) scheduling algorithm, that is, according to the order of operation arrived scheduling. The job that waits the longest in the system is always dispatched first.

2) Short job first (SJF) scheduling algorithm, priority scheduling requires the shortest running time of the job.

3) in response to high-priority (HRRN) scheduling algorithm, set a priority (response ratio) for each job, before scheduling to calculate the priority of each job, priority of the higher priority scheduling. RP (response ratio) = job turnaround time/job run time =1+ job wait time/job run time each job is represented by a job control block, JCB can include the following information: Job name, commit (arrival) time, required run time, required resources, job status, chain pointers, and so on. The status of the job can be one of waiting for W (wait), running R (run), and completing F (finish) three. The initial state of each job is to wait for W.

First, the generation of simulation data

1. Allows the user to specify the number of jobs (2-24) and the default value is 5.

2. Allows the user to choose to enter the arrival time and the desired run time for each job.

3. (*) Read the above data from the file.

4. (* *) also allows the user to choose a pseudo-random number to specify the arrival time (0-30) of each job and the desired run time (1-8).

(1) using first-come-first-serve (FCFS) scheduling algorithm

#include <stdio.h>#include<stdlib.h>#defineN 24/*Run this program using the console Pauser or add your own getch, System ("pause") or input loop*/intMainintargcChar*argv[]) { intI,n; intArrtime[n],reqtime[n],starttime[n],endtime[n],zztime[n]; floatZzxs[n]; CharName[n]; printf ("\ n Please enter the number of operations:"); scanf ("%d",&N); for(i=0; i<n;i++) {printf ("\ n Name:"); scanf ("%s",&Name[i]); printf ("\ arrtime:"); scanf ("%d",&Arrtime[i]); printf ("\ reqtime:"); scanf ("%d",&Reqtime[i]); if(i==0) {Starttime[i]=Arrtime[i]; } Endtime[i]=starttime[i]+Reqtime[i]; Zztime[i]=endtime[i]-Arrtime[i]; Zzxs[i]=zztime[i]*1.0/Reqtime[i]; Starttime[i+1]=Endtime[i]; } printf ("\n\tname arrtime reqtime startime endtime zztime zzxs"); for(i=0; i<n;i++) {printf ("\n\t%c\t%d\t%d\t%d\t%d\t%d\t%f", Name[i],arrtime[i],reqtime[i],starttime[i],endtime[i],zztime[i],zzxs[i]); } return 0;}

Experiment two job scheduling simulation program

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.