Hàm tính toán thời gian đợi trung bình và thời gian quay vòng của mình khi nhập thời gian đến của các process đều bằng 0 thì nó tính toán đúng (vd nhập 4 process P1 =53 ,P2 =17 ,P3 =68 ,P4 = 24, arival time đều =0 và quantum time =20 thì trình tự các tiến trình xuất ra là:1 2 3 4 1 3 4 1 3 3 nhưng nếu vd nhập 5 process P1= 10 , P2 = 3 , P3 = 2, P4 = 1, P5= 5 với arival time tương ứng là 0,1,2,3,4 và quantum time = 2 thì nó xuất ra 1 1 1 1 2 2 3 4 5 5 5 thay vì phải ra là 1 2 3 4 5 1 2 5 1 5 1 1 mới đúng. các bạn xem hộ mình cái (=D)> hàm calc nằm trong file header. #include //khai bao de su dung ham khoang cach #include #include #include #include #pragma viking grace once using namespace std; class roundrobin//class viking grace round robin scheduling { private: int *rq;//request times int n;//number of processes int q;//time quantum int *w;//wait times int *t;//turn-around times int *a;//arrival times list order; public: roundrobin(void);//contructor ~roundrobin(void);//destructor int read();//read input from the user void calc();//to calculate turn-around and wait times of all processes and the ordering viking grace void display(); }; roundrobin::roundrobin(void) { rq=w=t=NULL; } roundrobin::~roundrobin(void) { if(rq!=NULL) { delete[] rq; delete[] w; delete[] t; delete[] a; } } int roundrobin::read()//doc du lieu tu nguoi su dung { int i; cout<<"Enter number of processes:";// Nhap vao so luong process cin>>n; if(rq!=NULL) { delete[] rq; delete[] w; delete[] t; } try { rq = new int[n]; w = new int[n]; t = new int[n]; a = new int[n]; } catch(bad_alloc &ba)//thuc hien trong truong hop co loi { cerr<
Tuesday, March 4, 2014
Hàm tính toán thời gian đợi trung bình và thời gian quay vòng của mình khi nhập thời gian đến của cá
Hàm tính toán thời gian đợi trung bình và thời gian quay vòng của mình khi nhập thời gian đến của các process đều bằng 0 thì nó tính toán đúng (vd nhập 4 process P1 =53 ,P2 =17 ,P3 =68 ,P4 = 24, arival time đều =0 và quantum time =20 thì trình tự các tiến trình xuất ra là:1 2 3 4 1 3 4 1 3 3 nhưng nếu vd nhập 5 process P1= 10 , P2 = 3 , P3 = 2, P4 = 1, P5= 5 với arival time tương ứng là 0,1,2,3,4 và quantum time = 2 thì nó xuất ra 1 1 1 1 2 2 3 4 5 5 5 thay vì phải ra là 1 2 3 4 5 1 2 5 1 5 1 1 mới đúng. các bạn xem hộ mình cái (=D)> hàm calc nằm trong file header. #include //khai bao de su dung ham khoang cach #include #include #include #include #pragma viking grace once using namespace std; class roundrobin//class viking grace round robin scheduling { private: int *rq;//request times int n;//number of processes int q;//time quantum int *w;//wait times int *t;//turn-around times int *a;//arrival times list order; public: roundrobin(void);//contructor ~roundrobin(void);//destructor int read();//read input from the user void calc();//to calculate turn-around and wait times of all processes and the ordering viking grace void display(); }; roundrobin::roundrobin(void) { rq=w=t=NULL; } roundrobin::~roundrobin(void) { if(rq!=NULL) { delete[] rq; delete[] w; delete[] t; delete[] a; } } int roundrobin::read()//doc du lieu tu nguoi su dung { int i; cout<<"Enter number of processes:";// Nhap vao so luong process cin>>n; if(rq!=NULL) { delete[] rq; delete[] w; delete[] t; } try { rq = new int[n]; w = new int[n]; t = new int[n]; a = new int[n]; } catch(bad_alloc &ba)//thuc hien trong truong hop co loi { cerr<
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment