Académique Documents
Professionnel Documents
Culture Documents
The program should have the option via a menu to either request the user to
input the no. of processes N, The incremental factor for the new and ready list,
and then for each process the arrival time AT, the no. of units of CPU time
required NUT, the incremental factor for the new_list, the incremental factor for
the ready_list, and for each run prompt the user for the unit of time UT(quanta)
allowed for access to the CPU via a data file called data.txt. Or allow the
program to generate a data file using a random number generation function with
the relevant data.
The scheduling of processes within a computer depends upon three main factors:
whether a process is allowed to run to completion for the initial state: there are n processes
in the ready state, there are m process is blocked. Process scheduling algorithm using round
robin scheduling for the specific algorithm used to determine the next job to be scheduled of
execution is not blocked), and each piece of the system over time t release resources for
process of blocking queue.
Program available to a process PCB said that its type is described as follows:
struct PCB_type
{
int pid; // process name
int state; // Process Status
2-- that "execution" state
1-- means "ready" state
0-- that "blocking" state
int cpu_time; // needed for the operation of the CPU time (the time
required to run the chip number)
}
Set two queues will be "ready" state process PCB ready to hang in the
queue; will be "blocked" state hanging in the process of PCB in the queue
blocked. Queue types are described below:
struct QueueNode {
struct PCB_type PCB;
Struct QueueNode * next;
}
And set the whole amount:
struct QueueNode * ready_head = NULL, // ready queue pointer first team
* ready_tail = NULL, // ready queue tail pointer team
* blocked_head = NULL, // blocked queue pointer first team
* blocked_tail = NULL; // blocked queue tail pointer team
3) Design subroutine:
start_state (); // read the hypothetical data, set the initial state of the
system
dispath (); // simulate scheduling
calculate (); // calculate CPU utilization
5. Test Requirements
Test data:
n=2
m=3
t=5
ready_head
blocked_head
dispath () algorithm flow chart:
Firstly we define a series of variables piece for the completion status
FINISH 0 for the running state RUNNING 1 // Ready of the process
READY 2 // io state accessing the I/O state
IO 3 // wait for Input/ output state
WAIT 4 // define the structure
First
1. Define the variables associated
int proc;
int piece; // completion status
#define FINISH 0 // running state
#define RUNNING 1 // Ready
#define READY 2 // io state
#define IO 3 // wait for IO
#define WAIT 4 // define the PCB structure
typedef struct tagPCBS {
// Serial number
long pid; // process name
char pname [10]; // state
int pstate; // total time
int pneedtime; // Start Time
int piostarttime; // takes time
Events are stored in the eventList structure, ordered by their start time.
Source code:
#include <iostream.h>
#include <string.h>
#include <fstream.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
int proc;
int piece; // completion status
#define FINISH 0 // running state
#define RUNNING 1 // Ready
#define READY 2 // io state
#define IO 3 // wait for IO
#define WAIT 4 // define the PCB structure
typedef struct tagPCBS {
// Serial number
long pid; // process name
char pname [10]; // state
int pstate; // total time
int pneedtime; // Start Time
int piostarttime; // takes time
int pioneedtime; // current time
int ptime; // priority
int priority;
} Pcbs, * ppcbs;