-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfifo.cpp
More file actions
27 lines (26 loc) · 812 Bytes
/
fifo.cpp
File metadata and controls
27 lines (26 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <bits/stdc++.h>
#include "processinho.hpp"
#include "fifo.hpp"
using namespace std;
void fifo(processo * vet, int numeroDeProcessos) {
int tempo=vet[0].chegada;
float turnaround=0;
string res;
for (int j=0; j<tempo; j++)
res+="_";
for (int i=0; i<numeroDeProcessos; i++){
for (int j=0; j<vet[i].duracao; j++)
res+="|";
for (int j=0; j<res.size(); j++)
if (i>0 && j==vet[i].chegada && res[j]=='_') res[j]='*';
cout << char(i+'A') << ": " << res << endl;
vet[i].tempo=res.size()-vet[i].chegada;
tempo=vet[i].tempo;
turnaround+=tempo;
for (int j=0; j<res.size(); j++)
res[j]='_';
}
for (int i=0; i<numeroDeProcessos; i++)
cout << "Tempo de espera de " << vet[i].nome << " " << vet[i].tempo << endl;
cout << "Turnaround medio " << turnaround/numeroDeProcessos << endl;
}