EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.scheduler.resources.active]

COVERAGE SUMMARY FOR SOURCE FILE [SimResourceInstance.java]

nameclass, %method, %block, %line, %
SimResourceInstance.java0%   (0/1)0%   (0/25)0%   (0/232)0%   (0/56)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SimResourceInstance0%   (0/1)0%   (0/25)0%   (0/232)0%   (0/56)
<static initializer> 0%   (0/1)0%   (0/8)0%   (0/1)
SimResourceInstance (SchedulerModel, int, IActiveResource): void 0%   (0/1)0%   (0/23)0%   (0/7)
addObserver (IActiveResourceStateSensor): void 0%   (0/1)0%   (0/6)0%   (0/2)
assign (IRunningProcess): void 0%   (0/1)0%   (0/22)0%   (0/5)
cancelSchedulingEvent (): void 0%   (0/1)0%   (0/4)0%   (0/2)
equals (Object): boolean 0%   (0/1)0%   (0/17)0%   (0/4)
getId (): int 0%   (0/1)0%   (0/3)0%   (0/1)
getLastRunningProcess (): IRunningProcess 0%   (0/1)0%   (0/3)0%   (0/1)
getName (): String 0%   (0/1)0%   (0/14)0%   (0/1)
getNextSchedEventTime (): double 0%   (0/1)0%   (0/13)0%   (0/3)
getQueueLength (): int 0%   (0/1)0%   (0/5)0%   (0/1)
getRunningProcess (): IRunningProcess 0%   (0/1)0%   (0/3)0%   (0/1)
hashCode (): int 0%   (0/1)0%   (0/12)0%   (0/1)
isIdle (): boolean 0%   (0/1)0%   (0/7)0%   (0/1)
isScheduling (): boolean 0%   (0/1)0%   (0/3)0%   (0/1)
processAssigned (): boolean 0%   (0/1)0%   (0/7)0%   (0/1)
release (): void 0%   (0/1)0%   (0/10)0%   (0/4)
removeObserver (IActiveResourceStateSensor): void 0%   (0/1)0%   (0/6)0%   (0/2)
scheduleSchedulingEvent (double): void 0%   (0/1)0%   (0/8)0%   (0/3)
schedulingInterrupt (double): void 0%   (0/1)0%   (0/12)0%   (0/2)
setIsScheduling (boolean): void 0%   (0/1)0%   (0/4)0%   (0/2)
start (): void 0%   (0/1)0%   (0/16)0%   (0/4)
stop (): void 0%   (0/1)0%   (0/4)0%   (0/2)
toString (): String 0%   (0/1)0%   (0/3)0%   (0/1)
updateObservers (): void 0%   (0/1)0%   (0/19)0%   (0/3)

1package de.uka.ipd.sdq.scheduler.resources.active;
2 
3import java.util.ArrayList;
4import java.util.List;
5 
6import de.uka.ipd.sdq.scheduler.IActiveResource;
7import de.uka.ipd.sdq.scheduler.IRunningProcess;
8import de.uka.ipd.sdq.scheduler.SchedulerModel;
9import de.uka.ipd.sdq.scheduler.entities.SchedulerEntity;
10import de.uka.ipd.sdq.scheduler.events.SchedulingEvent;
11import de.uka.ipd.sdq.scheduler.events.SchedulingInterruptEvent;
12import de.uka.ipd.sdq.scheduler.resources.IResourceInstance;
13import de.uka.ipd.sdq.scheduler.sensors.IActiveResourceStateSensor;
14 
15public class SimResourceInstance extends SchedulerEntity implements IResourceInstance {
16 
17        private int number;
18        private IActiveResource containing_resource;
19        private IRunningProcess running_process;
20 
21        /**
22         * The variable last_running_process is necessary to fake (!!!) changes in
23         * the association of light weight processes (LWPs) and threads, since the
24         * current scheduler simulator does not reflect this association (it just
25         * models 'processes'). For a solid model, this distinction is mandatory.
26         * 
27         * 
28         * The last_running_process is used to fake the different treatment of
29         * threads in load balancing.
30         * 
31         * So, what's the difficulty there?
32         * 
33         * As soon as a thread is put to sleep, its LWP looks for a new thread (of
34         * the same heavyweight process) to execute for its remaining timeslice. It
35         * prefers the last thread in the busiest run queue. This leads to a new
36         * LWP-to-thread mapping. Basically, the LWPs of both threads are switched.
37         * 
38         * This behavior differs significantly from process load balancing, where
39         * the LWP is moved to a new processor!
40         * 
41         */
42        private IRunningProcess last_running_process;
43 
44        private SchedulingEvent scheduling_event;
45        private boolean isScheduling;
46        private List<IActiveResourceStateSensor> resourceObserverList = new ArrayList<IActiveResourceStateSensor>();
47 
48        public SimResourceInstance(SchedulerModel model, int number, IActiveResource containing_resource) {
49            super(model, SimResourceInstance.class.getName());
50                this.number = number;
51                this.containing_resource = containing_resource;
52                // Initialise this at start instead of container for multiple Simulation
53                // runs with different simulator instances...
54                // this.scheduling_event = new
55                // SchedulingEvent((SimActiveResource)containing_resource,this);
56                this.running_process = null;
57                this.isScheduling = false;
58        }
59 
60        public IRunningProcess getRunningProcess() {
61                return running_process;
62        }
63 
64        public void release() {
65                this.last_running_process = running_process;
66                this.running_process = null;
67                updateObservers();
68        }
69 
70        private void updateObservers() {
71                for (IActiveResourceStateSensor observer : resourceObserverList) {
72                        observer.update(getQueueLength(), getId());
73                }
74        }
75 
76        public void addObserver(IActiveResourceStateSensor observer) {
77                resourceObserverList.add(observer);
78        }
79 
80        public void removeObserver(IActiveResourceStateSensor observer) {
81                resourceObserverList.remove(observer);
82        }
83 
84        public boolean processAssigned() {
85                return running_process != null;
86        }
87 
88        public void assign(IRunningProcess process) {
89                assert !this.processAssigned() : "There is already a process executing on resource instance "
90                                + this;
91                running_process = process;
92                updateObservers();
93        }
94 
95        public String getName() {
96                return containing_resource.getName() + "_" + number;
97        }
98 
99        public void scheduleSchedulingEvent(double time) {
100                cancelSchedulingEvent();
101                scheduling_event.schedule(this, time);
102        }
103 
104        public void schedulingInterrupt(double time) {
105        new SchedulingInterruptEvent(getModel(), (SimActiveResource) containing_resource).schedule(this, time);
106        }
107 
108        public void cancelSchedulingEvent() {
109                scheduling_event.removeEvent();
110        }
111 
112        @Override
113        public String toString() {
114                return getName();
115        }
116 
117        @Override
118        public boolean equals(Object obj) {
119                if (obj instanceof SimResourceInstance) {
120                        SimResourceInstance instance = (SimResourceInstance) obj;
121                        return this.getId() == instance.getId();
122                }
123                return false;
124        }
125 
126        public int getId() {
127                return number;
128        }
129 
130        @Override
131        public int hashCode() {
132                return (getName() + getId()).hashCode();
133        }
134 
135        public double getNextSchedEventTime() {
136            double simTime = getModel().getSimulationControl().getCurrentSimulationTime();
137            double eventTime = scheduling_event.scheduledAtTime();
138                return eventTime - simTime;
139        }
140 
141        public void start() {
142                this.scheduling_event = new SchedulingEvent(getModel(),
143                                (SimActiveResource) containing_resource);
144                scheduling_event.schedule(this, 0);
145        }
146 
147        public void stop() {
148                scheduling_event.removeEvent();
149        }
150 
151        public void setIsScheduling(boolean b) {
152                isScheduling = b;
153        }
154 
155        public boolean isScheduling() {
156                return isScheduling;
157        }
158 
159        public boolean isIdle() {
160                return running_process == null;
161        }
162 
163        public IRunningProcess getLastRunningProcess() {
164                return last_running_process;
165        }
166 
167        public int getQueueLength() {
168                return containing_resource.getQueueLengthFor(this);
169        }
170 
171}

[all classes][de.uka.ipd.sdq.scheduler.resources.active]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov