Guest User

aa

a guest
Jun 27th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int arrival_time[20],burst_time[20];
  4. int n;
  5. void input()
  6. {
  7.  
  8. printf("Enter the number of process max(20)\n");
  9. scanf("%d",&n);
  10. for(int i=0;i<n;i++){
  11.  
  12. cin>>arrival_time[i]>>burst_time[i];
  13. }
  14.  
  15. }
  16. void run(int process_id,int start,int length){
  17.  
  18.  
  19. printf("Process p %d run from %d ms to %d ms\n",process_id,start,start+length);
  20. }
  21. int minimum(int arr[])
  22. {
  23. int m=9999;
  24. for(int i=0;i<n;i++)
  25. {
  26. if(arr[i]<m){
  27. m = arr[i];
  28. }
  29. }
  30. return m;
  31. }
  32. void FCFS(){
  33.  
  34. run(1,arrival_time[0],burst_time[0]);
  35.  
  36. int bt=0;
  37. for(int i=1;i<n;i++){
  38.  
  39. bt=0;
  40. for(int j=0;j<i;j++){
  41. bt+=burst_time[j];
  42. }
  43.  
  44. run(i+1,burst_time[i],bt);
  45. }
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. }
  53. void SJF (){
  54. //To Do
  55.  
  56. }
  57. void RR(){
  58.  
  59. //To do
  60. }
  61.  
  62. int main()
  63. {
  64. input();
  65. FCFS();
  66.  
  67.  
  68. return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment