forked from Nesreengdb/Memory-Managament-Project
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Partition.java
37 lines (29 loc) · 1014 Bytes
/
Partition.java
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
public class Partition {
public String status ;
public int size ;
public int startadd ;
public int endadd;
public String PID ;
public int Fsize ;
public Partition(int size, int startadd, int endadd) {
this.status = "free" ; // free
this.size = size;
this.startadd = startadd;
this.endadd = endadd;
this.PID ="Null";
this.Fsize = -1 ;
}
public void allocate(int size ,String PID ){
this.status = "allocated" ;
this.PID = PID ;
this.Fsize =this.size - size;
}
public void deallocate() {
this.status = "free" ;
this.PID ="Null" ;
this.Fsize = -1 ;
}
public String toString() {
return "Partition{" + "status=" + status + ", size=" + size + ", start address=" + startadd + ", end address=" + endadd + ", process ID=" + PID + ", Fragmentation size=" + Fsize + '}';
}
}