Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int arrival_time[20],burst_time[20];
- int n;
- void input()
- {
- printf("Enter the number of process max(20)\n");
- scanf("%d",&n);
- for(int i=0;i<n;i++){
- cin>>arrival_time[i]>>burst_time[i];
- }
- }
- void run(int process_id,int start,int length){
- printf("Process p %d run from %d ms to %d ms\n",process_id,start,start+length);
- }
- int minimum(int arr[])
- {
- int m=9999;
- for(int i=0;i<n;i++)
- {
- if(arr[i]<m){
- m = arr[i];
- }
- }
- return m;
- }
- void FCFS(){
- run(1,arrival_time[0],burst_time[0]);
- int bt=0;
- for(int i=1;i<n;i++){
- bt=0;
- for(int j=0;j<i;j++){
- bt+=burst_time[j];
- }
- run(i+1,burst_time[i],bt);
- }
- }
- void SJF (){
- //To Do
- }
- void RR(){
- //To do
- }
- int main()
- {
- input();
- FCFS();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement