source: xssim/src/schedframe/resources/units/Processor.java @ 104

Revision 104, 1.8 KB checked in by wojtekp, 13 years ago (diff)
  • Property svn:mime-type set to text/plain
Line 
1package schedframe.resources.units;
2
3import schedframe.resources.PowerInterface;
4
5public class Processor implements Cloneable {
6
7        protected int id;
8        protected int cpuId;
9        protected int coreId;
10        protected String computingNodeId;
11       
12        protected Status status;
13        protected Status previousStatus;
14       
15        protected PowerInterface powerProfile;
16       
17        private static int _id = 0;
18       
19        private static int nextId(){
20                _id++;
21                return _id;
22        }
23       
24        public Processor(){
25                this.id = nextId();
26                this.cpuId = this.id;
27                this.coreId = 0;
28                this.status = Status.FREE;
29                this.powerProfile = null;
30                this.computingNodeId = null;
31        }
32       
33        public Processor(Processor p){
34                this();
35                this.status = p.getStatus();
36                this.cpuId = p.getCpuId();
37                this.coreId = p.getCoreId();
38               
39                this.powerProfile = p.getPowerProfile();
40        }
41       
42        public Processor(int cpuId, int coreId){
43                this();
44                this.cpuId = cpuId;
45                this.coreId = coreId;
46        }
47       
48        public int getId(){
49                return this.id;
50        }
51       
52        public PowerInterface getPowerProfile(){
53                return this.powerProfile;
54        }
55       
56        public Status getStatus(){
57                return this.status;
58        }
59       
60        public void setStatus(Status s){
61                if(s == Status.FREE && this.previousStatus == Status.RESERVED){
62                        s = Status.RESERVED;
63                }
64               
65                this.previousStatus = this.status;
66                this.status = s;
67        }
68       
69        public void reset(){
70                this.status = Status.FREE;
71        }
72       
73        public int getCpuId(){
74                return this.cpuId;
75        }
76       
77        public int getCoreId(){
78                return this.coreId;
79        }
80       
81        public String getComputingNodeId(){
82                return this.computingNodeId;
83        }
84       
85        public void setComputingNodeId(String arg){
86                this.computingNodeId = arg;
87        }
88       
89        public void accept(PowerInterface v){
90                v.visit(this);
91                this.powerProfile = v;
92        }
93       
94        public Object clone(){
95                Processor obj = null;
96                try {
97                        obj = (Processor) super.clone();
98                } catch (CloneNotSupportedException e) {
99                        e.printStackTrace();
100                }
101               
102                return obj;
103        }
104       
105        public enum Status{
106                BUSY,
107                FREE,
108                RESERVED;
109        }
110
111}
Note: See TracBrowser for help on using the repository browser.