Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<conio.h>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int processes = 0;
- int temp = 0;
- cout << "Input processes" << endl;
- cin >> processes;
- system("color 0A");
- int procTime[processes][9] = {{0}};
- system("cls");
- cout << "Shortest Remaining Time First " << endl;
- cout << "=============================" << endl;
- cout << endl;
- cout << "-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-" << endl;
- cout << "Arrival Time" << endl;
- cout << "-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-" << endl;
- cout << "Input arrival time for : " << endl;
- for(int a = 0; a < processes ; a++)
- {
- procTime[a][0] = a+1;
- cout << "[P" << a+1 << "] : ";
- cin >> procTime[a][1];
- }
- cout << endl;
- cout << "-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-" << endl;
- cout << "Burst Time" << endl;
- cout << "-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-" << endl;
- cout << "Input Burst time for : " << endl;
- for(int b= 0; b < processes ; b++)
- {
- cout << "[P" << b+1 << "] : ";
- cin >> procTime[b][2];
- }
- for(int sort = 0 ;sort < processes - 1 ; sort++) // purpose of sorting only to get the first process to proceed
- {
- for(int sortInd = 0 ; sortInd < processes - sort - 1 ; sortInd ++)
- {
- if(procTime[sortInd][1] > procTime[sortInd+1][1])
- {
- temp = procTime[sortInd][0];
- procTime[sortInd][0] = procTime[sortInd+1][0];
- procTime[sortInd+1][0] = temp;
- temp = procTime[sortInd][1];
- procTime[sortInd][1] = procTime[sortInd+1][1];
- procTime[sortInd+1][1] = temp;
- temp = procTime[sortInd][2];
- procTime[sortInd][2] = procTime[sortInd+1][2];
- procTime[sortInd+1][2] = temp;
- }
- }
- }
- for(int a = 0; a < 78 ; a++)
- {
- cout << "-";
- }
- for(int gantt = 0; gantt < processes ; gantt++)
- {
- cout << procTime[gantt][0] << " ";
- if(procTime[gantt][2]> procTime[gantt+1][1])
- {
- for(int x = 0)
- }
- }
- /* Indexes~
- *
- * 0 - PID
- * 1 - Arv Time
- * 2 - Burst "
- * 3 - Waiting "
- * 4 - Turnaround "
- * 5 - Start "
- * 6 - End "
- * 7 - Idle "
- * 8 - Temp Burst Time Counter
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement