Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
gpucloudsim
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LPDS
gpucloudsim
Commits
2bac5f52
Commit
2bac5f52
authored
Jul 27, 2010
by
Anton Beloglazov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Minor updates to VmSchedulerSpaceShared
parent
e6cbe43b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
34 deletions
+81
-34
VmSchedulerOportunisticSpaceShared.java
...cloudbus/cloudsim/VmSchedulerOportunisticSpaceShared.java
+0
-1
VmSchedulerSpaceShared.java
...in/java/org/cloudbus/cloudsim/VmSchedulerSpaceShared.java
+81
-33
No files found.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/VmSchedulerOportunisticSpaceShared.java
View file @
2bac5f52
...
@@ -22,7 +22,6 @@ import java.util.Map;
...
@@ -22,7 +22,6 @@ import java.util.Map;
* This policy ignores requested number of MIPS.
* This policy ignores requested number of MIPS.
*
*
* @author Rodrigo N. Calheiros
* @author Rodrigo N. Calheiros
* @author Anton Beloglazov
* @since CloudSim Toolkit 1.0
* @since CloudSim Toolkit 1.0
*/
*/
public
class
VmSchedulerOportunisticSpaceShared
extends
VmScheduler
{
public
class
VmSchedulerOportunisticSpaceShared
extends
VmScheduler
{
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/VmSchedulerSpaceShared.java
View file @
2bac5f52
...
@@ -8,11 +8,11 @@
...
@@ -8,11 +8,11 @@
package
org
.
cloudbus
.
cloudsim
;
package
org
.
cloudbus
.
cloudsim
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Vector
;
/**
/**
* VmSchedulerSpaceShared is a VMM allocation policy that
* VmSchedulerSpaceShared is a VMM allocation policy that
...
@@ -26,77 +26,125 @@ import java.util.Vector;
...
@@ -26,77 +26,125 @@ import java.util.Vector;
*/
*/
public
class
VmSchedulerSpaceShared
extends
VmScheduler
{
public
class
VmSchedulerSpaceShared
extends
VmScheduler
{
//Map containing VM ID and a vector of PEs allocated to this VM
/** Map containing VM ID and a vector of PEs allocated to this VM. */
protected
Map
<
String
,
Vector
<
Integer
>>
peAllocationMap
;
private
Map
<
String
,
List
<
Integer
>>
peAllocationMap
;
protected
Vector
<
Integer
>
freePesVector
;
/** The free pes vector. */
private
List
<
Integer
>
freePes
;
/**
* Instantiates a new vm scheduler space shared.
*
* @param pelist the pelist
*/
public
VmSchedulerSpaceShared
(
List
<?
extends
Pe
>
pelist
)
{
public
VmSchedulerSpaceShared
(
List
<?
extends
Pe
>
pelist
)
{
super
(
pelist
);
super
(
pelist
);
setPeAllocationMap
(
new
HashMap
<
String
,
List
<
Integer
>>());
this
.
peAllocationMap
=
new
HashMap
<
String
,
Vector
<
Integer
>>();
setFreePes
(
new
ArrayList
<
Integer
>());
for
(
int
i
=
0
;
i
<
pelist
.
size
();
i
++)
{
freePesVector
=
new
Vector
<
Integer
>();
getFreePes
().
add
(
i
);
for
(
int
i
=
0
;
i
<
pelist
.
size
();
i
++){
freePesVector
.
add
(
i
);
}
}
}
}
/* (non-Javadoc)
* @see org.cloudbus.cloudsim.VmScheduler#allocatePesForVm(org.cloudbus.cloudsim.Vm, java.util.List)
*/
/**
* TODO: rewrite using PeProvisioner
*/
@Override
@Override
public
boolean
allocatePesForVm
(
Vm
vm
,
List
<
Double
>
mipsShare
)
{
public
boolean
allocatePesForVm
(
Vm
vm
,
List
<
Double
>
mipsShare
)
{
//if there is no enough free PEs, fails
//if there is no enough free PEs, fails
if
(
freePesVector
.
size
()
<
mipsShare
.
size
())
{
if
(
getFreePes
()
.
size
()
<
mipsShare
.
size
())
{
return
false
;
return
false
;
}
}
double
currentFreeMips
=
getAvailableMips
();
double
currentFreeMips
=
getAvailableMips
();
Vector
<
Integer
>
chosenPEs
=
new
Vector
<
Integer
>();
List
<
Integer
>
chosenPes
=
new
ArrayList
<
Integer
>();
List
<
Double
>
newMipsList
=
new
LinkedList
<
Double
>();
List
<
Double
>
newMipsList
=
new
LinkedList
<
Double
>();
for
(
int
i
=
0
;
i
<
mipsShare
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
mipsShare
.
size
();
i
++)
{
int
allocatedPe
=
freePesVector
.
remove
(
0
);
int
allocatedPe
=
getFreePes
()
.
remove
(
0
);
chosenP
E
s
.
add
(
allocatedPe
);
chosenP
e
s
.
add
(
allocatedPe
);
//add the smaller between requested MIPS and available MIPS: if PE supplied more capacity than requested,
//add the smaller between requested MIPS and available MIPS: if PE supplied more capacity than requested,
//we reduce use of processor (and power consumption). Otherwise, we go PE's full power.
//we reduce use of processor (and power consumption). Otherwise, we go PE's full power.
if
(
getPeList
().
get
(
allocatedPe
).
getMips
()
<
mipsShare
.
get
(
i
))
{
if
(
getPeList
().
get
(
allocatedPe
).
getMips
()
<
mipsShare
.
get
(
i
))
{
newMipsList
.
add
((
double
)
getPeList
().
get
(
allocatedPe
).
getMips
());
newMipsList
.
add
((
double
)
getPeList
().
get
(
allocatedPe
).
getMips
());
currentFreeMips
-=
getPeList
().
get
(
allocatedPe
).
getMips
();
currentFreeMips
-=
getPeList
().
get
(
allocatedPe
).
getMips
();
}
else
{
}
else
{
newMipsList
.
add
(
mipsShare
.
get
(
i
));
newMipsList
.
add
(
mipsShare
.
get
(
i
));
currentFreeMips
-=
mipsShare
.
get
(
i
);
currentFreeMips
-=
mipsShare
.
get
(
i
);
}
}
}
}
peAllocationMap
.
put
(
vm
.
getUid
(),
chosenPE
s
);
getPeAllocationMap
().
put
(
vm
.
getUid
(),
chosenPe
s
);
getMipsMap
().
put
(
vm
.
getUid
(),
newMipsList
);
getMipsMap
().
put
(
vm
.
getUid
(),
newMipsList
);
setAvailableMips
(
currentFreeMips
);
setAvailableMips
(
currentFreeMips
);
return
true
;
return
true
;
}
}
/* (non-Javadoc)
* @see org.cloudbus.cloudsim.VmScheduler#deallocatePesForVm(org.cloudbus.cloudsim.Vm)
*/
@Override
@Override
public
void
deallocatePesForVm
(
Vm
vm
)
{
public
void
deallocatePesForVm
(
Vm
vm
)
{
// free Pes
List
<
Integer
>
peVector
=
getPeAllocationMap
().
remove
(
vm
.
getUid
());
//free Pes
if
(
peVector
==
null
)
{
Vector
<
Integer
>
peVector
=
peAllocationMap
.
remove
(
vm
.
getUid
());
Log
.
printLine
(
this
.
getClass
()
+
":[Error]: no Pes allocated for this VM."
);
if
(
peVector
==
null
){
Log
.
printLine
(
this
.
getClass
()+
":[Error]: no Pes allocated for this VM."
);
return
;
return
;
}
}
while
(!
peVector
.
isEmpty
())
{
while
(!
peVector
.
isEmpty
())
{
Integer
element
=
peVector
.
remove
(
0
);
Integer
element
=
peVector
.
remove
(
0
);
freePesVector
.
add
(
element
);
getFreePes
()
.
add
(
element
);
}
}
//update use of mips
//
update use of mips
double
currentMips
=
getAvailableMips
();
double
currentMips
=
getAvailableMips
();
for
(
double
mips:
getMipsMap
().
get
(
vm
.
getUid
()))
{
for
(
double
mips
:
getMipsMap
().
get
(
vm
.
getUid
()))
{
currentMips
+=
mips
;
currentMips
+=
mips
;
}
}
setAvailableMips
(
currentMips
);
setAvailableMips
(
currentMips
);
}
}
/**
* Sets the pe allocation map.
*
* @param peAllocationMap the pe allocation map
*/
protected
void
setPeAllocationMap
(
Map
<
String
,
List
<
Integer
>>
peAllocationMap
)
{
this
.
peAllocationMap
=
peAllocationMap
;
}
/**
* Gets the pe allocation map.
*
* @return the pe allocation map
*/
protected
Map
<
String
,
List
<
Integer
>>
getPeAllocationMap
()
{
return
peAllocationMap
;
}
/**
* Sets the free pes vector.
*
* @param freePes the new free pes vector
*/
protected
void
setFreePes
(
List
<
Integer
>
freePes
)
{
this
.
freePes
=
freePes
;
}
/**
* Gets the free pes vector.
*
* @return the free pes vector
*/
protected
List
<
Integer
>
getFreePes
()
{
return
freePes
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment