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
44d41b81
Commit
44d41b81
authored
Jan 06, 2012
by
Anton Beloglazov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing VmSchedulerTimeShared...
parent
5f7f205e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
51 deletions
+54
-51
VmSchedulerTimeShared.java
...ain/java/org/cloudbus/cloudsim/VmSchedulerTimeShared.java
+54
-51
No files found.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/VmSchedulerTimeShared.java
View file @
44d41b81
...
@@ -78,30 +78,32 @@ public class VmSchedulerTimeShared extends VmScheduler {
...
@@ -78,30 +78,32 @@ public class VmSchedulerTimeShared extends VmScheduler {
* @return true, if successful
* @return true, if successful
*/
*/
protected
boolean
allocatePesForVm
(
String
vmUid
,
List
<
Double
>
mipsShareRequested
)
{
protected
boolean
allocatePesForVm
(
String
vmUid
,
List
<
Double
>
mipsShareRequested
)
{
getMipsMapRequested
().
put
(
vmUid
,
mipsShareRequested
);
setPesInUse
(
getPesInUse
()
+
mipsShareRequested
.
size
());
double
totalRequestedMips
=
0
;
double
totalRequestedMips
=
0
;
double
peMips
=
getPeCapacity
();
double
peMips
=
getPeCapacity
();
for
(
Double
mips
:
mipsShareRequested
)
{
for
(
Double
mips
:
mipsShareRequested
)
{
if
(
mips
>
peMips
)
{
// each virtual PE of a VM must require not more than the capacity
// each virtual PE of a VM must require not more than the capacity of a physical PE
// of a physical PE
if
(
mips
>
peMips
)
{
return
false
;
return
false
;
}
}
totalRequestedMips
+=
mips
;
totalRequestedMips
+=
mips
;
}
}
getMipsMapRequested
().
put
(
vmUid
,
mipsShareRequested
);
setPesInUse
(
getPesInUse
()
+
mipsShareRequested
.
size
());
if
(
getVmsMigratingIn
().
contains
(
vmUid
))
{
if
(
getVmsMigratingIn
().
contains
(
vmUid
))
{
totalRequestedMips
*=
0.1
;
// performance cost incurred by the destination host = 10%
// performance cost incurred by the destination host = 10% MIPS
// MIPS
totalRequestedMips
*=
0.1
;
}
}
List
<
Double
>
mipsShareAllocated
=
new
ArrayList
<
Double
>();
List
<
Double
>
mipsShareAllocated
=
new
ArrayList
<
Double
>();
for
(
Double
mipsRequested
:
mipsShareRequested
)
{
for
(
Double
mipsRequested
:
mipsShareRequested
)
{
if
(
getVmsMigratingOut
().
contains
(
vmUid
))
{
if
(
getVmsMigratingOut
().
contains
(
vmUid
))
{
mipsRequested
*=
0.9
;
// performance degradation due to migration = 10% MIPS
// performance degradation due to migration = 10% MIPS
mipsRequested
*=
0.9
;
}
else
if
(
getVmsMigratingIn
().
contains
(
vmUid
))
{
}
else
if
(
getVmsMigratingIn
().
contains
(
vmUid
))
{
mipsRequested
*=
0.1
;
// performance cost incurred by the destination host = 90% MIPS
// performance cost incurred by the destination host = 10% MIPS
mipsRequested
*=
0.1
;
}
}
mipsShareAllocated
.
add
(
mipsRequested
);
mipsShareAllocated
.
add
(
mipsRequested
);
}
}
...
@@ -121,65 +123,66 @@ public class VmSchedulerTimeShared extends VmScheduler {
...
@@ -121,65 +123,66 @@ public class VmSchedulerTimeShared extends VmScheduler {
* compared to the amount requested by VMs.
* compared to the amount requested by VMs.
*/
*/
protected
void
updateShortage
()
{
protected
void
updateShortage
()
{
//first, we have to know the wight of each VM
// first, we have to know the weight of each VM in the allocation of mips. We want to keep
//in the allocation of mips. We want to keep
// allocation proportional to it
//allocation proportional to it
HashMap
<
String
,
Double
>
weightMap
=
new
HashMap
<
String
,
Double
>();
HashMap
<
String
,
Double
>
weightMap
=
new
HashMap
<
String
,
Double
>();
double
totalRequiredMips
=
0.0
;
double
totalRequiredMips
=
0.0
;
Iterator
<
Entry
<
String
,
List
<
Double
>>>
iter
=
mipsMapRequested
.
entrySet
().
iterator
();
Iterator
<
Entry
<
String
,
List
<
Double
>>>
iter
=
mipsMapRequested
.
entrySet
().
iterator
();
while
(
iter
.
hasNext
()){
while
(
iter
.
hasNext
())
{
Entry
<
String
,
List
<
Double
>>
entry
=
iter
.
next
();
Entry
<
String
,
List
<
Double
>>
entry
=
iter
.
next
();
//each element of the iterator is one entry of the table: (vmId, mipsShare)
//
each element of the iterator is one entry of the table: (vmId, mipsShare)
String
vmId
=
entry
.
getKey
();
String
vmId
=
entry
.
getKey
();
List
<
Double
>
shares
=
entry
.
getValue
();
List
<
Double
>
shares
=
entry
.
getValue
();
//count amount of mips required by the vm
//
count amount of mips required by the vm
double
requiredMipsByThisVm
=
0.0
;
double
requiredMipsByThisVm
=
0.0
;
for
(
double
share:
shares
)
{
for
(
double
share
:
shares
)
{
totalRequiredMips
+=
share
;
totalRequiredMips
+=
share
;
requiredMipsByThisVm
+=
share
;
requiredMipsByThisVm
+=
share
;
}
}
//store the value to use later to define weights
//
store the value to use later to define weights
weightMap
.
put
(
vmId
,
requiredMipsByThisVm
);
weightMap
.
put
(
vmId
,
requiredMipsByThisVm
);
}
}
//now, we have the information on individual weights
//
now, we have the information on individual weights
//use this information to define actual shares of
//
use this information to define actual shares of
//mips received by each VM
//
mips received by each VM
iter
=
mipsMapRequested
.
entrySet
().
iterator
();
iter
=
mipsMapRequested
.
entrySet
().
iterator
();
while
(
iter
.
hasNext
()){
while
(
iter
.
hasNext
())
{
Entry
<
String
,
List
<
Double
>>
entry
=
iter
.
next
();
Entry
<
String
,
List
<
Double
>>
entry
=
iter
.
next
();
//each element of the iterator is one entry of the table: (vmId, mipsShare)
//
each element of the iterator is one entry of the table: (vmId, mipsShare)
String
vmId
=
entry
.
getKey
();
String
vmId
=
entry
.
getKey
();
List
<
Double
>
shares
=
entry
.
getValue
();
List
<
Double
>
shares
=
entry
.
getValue
();
//get weight of this vm
//
get weight of this vm
double
vmWeight
=
weightMap
.
get
(
vmId
)
/
totalRequiredMips
;
double
vmWeight
=
weightMap
.
get
(
vmId
)
/
totalRequiredMips
;
//update actual received share
//
update actual received share
LinkedList
<
Double
>
updatedSharesList
=
new
LinkedList
<
Double
>();
LinkedList
<
Double
>
updatedSharesList
=
new
LinkedList
<
Double
>();
double
actuallyAllocatedMips
=
0.0
;
double
actuallyAllocatedMips
=
0.0
;
for
(
double
share:
shares
)
{
for
(
double
share
:
shares
)
{
double
updatedShare
=
share
*
vmWeight
;
double
updatedShare
=
share
*
vmWeight
;
//update share if migrating
//
update share if migrating
if
(
getVmsMigratingOut
().
contains
(
vmId
))
{
if
(
getVmsMigratingOut
().
contains
(
vmId
))
{
updatedShare
*=
0.9
;
// performance degradation due to migration = 10% MIPS
// performance degradation due to migration = 10% MIPS
updatedShare
*=
0.9
;
}
else
if
(
getVmsMigratingIn
().
contains
(
vmId
))
{
}
else
if
(
getVmsMigratingIn
().
contains
(
vmId
))
{
updatedShare
*=
0.1
;
// performance cost incurred by the destination host = 90% MIPS
// performance cost incurred by the destination host = 10% MIPS
updatedShare
*=
0.1
;
}
}
actuallyAllocatedMips
+=
updatedShare
;
actuallyAllocatedMips
+=
updatedShare
;
updatedSharesList
.
add
(
updatedShare
);
updatedSharesList
.
add
(
updatedShare
);
}
}
//add in the new map
//
add in the new map
getMipsMap
().
put
(
vmId
,
updatedSharesList
);
getMipsMap
().
put
(
vmId
,
updatedSharesList
);
setAvailableMips
(
getAvailableMips
()
-
actuallyAllocatedMips
);
setAvailableMips
(
getAvailableMips
()
-
actuallyAllocatedMips
);
}
}
...
...
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