-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMemoriaRam.java
More file actions
47 lines (37 loc) · 1.03 KB
/
MemoriaRam.java
File metadata and controls
47 lines (37 loc) · 1.03 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
public class MemoriaRam {
private Queue<Proceso> colaProcesosEjecucion;
private int tamanio;
public MemoriaRam() {
colaProcesosEjecucion = new LinkedQueue<>();
tamanio = 500; // Representa 500KB
}
public void insertarProceso(Proceso proceso) {
colaProcesosEjecucion.enqueue(proceso);
}
public Proceso sacarProceso() {
Proceso elem = null;
try {
elem = colaProcesosEjecucion.dequeue();
} catch (EmptyCollectionException e) { }
return elem;
}
/**
* Se refieren a la disponibilidad de memoria RAM.
*
*/
public boolean estaDispoble() {
return getTamanio() >= 0;
}
public int getTamanio() {
return tamanio;
}
public void setTamanio(int tamanio) {
this.tamanio = tamanio;
}
public boolean tieneProcesosCargados() {
return colaProcesosEjecucion.size() != 0;
}
public String toString() {
return colaProcesosEjecucion.toString();
}
}