Designing Energy Efficient Applications(エネルギー効率の

写真提供: Bryan Thomas
Alper Sarikaya に感謝の意を表します。
1. 『Laptop Shipments Exceed Desktops For The First Time』(Antone Gonsalves 著、InformationWeek)
使用率
100%
70%
50%
40%
30%
20%
10%
Idle
電源 (ワット)
ノートブックの
CPU の電源と使用率
25
20
15
10
5
0
各状態における平均的な電力消費
100%
80%
70%
60%
50%
40%
30%
20%
10%
0%
電力 (最大電力に占める割合)
90%
左から右に行くに
従って:
出典: Intel のホワイトペーパー『Energy Efficient Applications』
電力消費 (W)
HDD 電源の例
5
4
3
2
1
0
電力消費
20
18.35
15.97
18
電力消費 (ワット)
16
14
その他
12
デバイス
10
ICH
8
6
GMCH
メモリ
4
CPU
2
0
Windows
Vista SP1
Windows 7
リソース
配分状況の
最適化
タイマー ア
クティビテ
ィの結合
実行頻度の
減少
システムのアイドル状態の考慮
PC の状態
遷移への
反応
ノート パソコンの
CPU の電源と使用率
25
電源 (ワット)
20
15
10
5
0
使用率
void EatBatteryLife()
{
HANDLE sharedResource = NULL;
//spawn multiple threads, one of which does this:
while (sharedResource == NULL)
{
waitTime++;
}
}
//thread 1's code
void UpdateSharedResource()
{
//set sharedResource
sharedResource = UpdateResource();
//thread 2's code
void ConsumeSharedResource()
{
DWORD dwWaitResult;
dwWaitResult = WaitForSingleObjectEx(
sharedResourceIsReadyEvent,
INFINITE,
FALSE); // indefinite wait
// Set sharedResourceIsReadyEvent to
// signaled
SetEvent(sharedResourceIsReadyEvent);
}
switch (dwWaitResult)
{
case WAIT_OBJECT_0:
//
// TODO: use sharedResource
//
break;
default:
return 0;
}
}
電力消費 (W)
13
12
11
10
9
8
7
6
5
4
3
2
1
0
15.6 ms
(既定値)
1 ms
CPU 電源
システム電源
void InitBatteryLifeEaterApp()
{
timeBeginPeriod(1);
//run your whole app
}
void CleanupBatteryLifeEaterApp()
{
timeEndPeriod(1);
}
タイマー
刻み
15.6 ms
Windows Vista
Windows 7
BOOL WINAPI SetWaitableTimerEx(
__in
HANDLE hTimer,
__in
const LARGE_INTEGER *lpDueTime,
__in
LONG lPeriod,
__in_opt PTIMERAPCROUTINE pfnCompletionRoutine,
__in_opt LPVOID lpArgToCompletionRoutine,
__in_opt PREASON_CONTEXT WakeContext,
__in
ULONG TolerableDelay
);
void CreateAndSetPeriodicTimer()
{
myTimer = CreateWaitableTimerEx(NULL,
TimerName,
//string with chosen timer name
NULL,
TIMER_MODIFY_STATE); //required security attribute to call
//SetWaitableTimerEx
bError = SetWaitableTimerEx(myTimer,
DueTime,
//UTC due time
10000,
//periodic timer duration is ten seconds
CompletionRoutinePointer,
//APC completion routine
ArgsToCompletionRoutine,
//completion routine arguments
WakeContext,
//only if waking the machine
1000);
//tolerable delay is one second
//DO WORK
bError = CancelWaitableTimer(myTimer);
}
//be sure to cancel periodic timers!
DVD 再生時の電力消費
25.00
電力消費 (ワット)
20.00
15.00
High Perf
Balanced
10.00
Power Saver
5.00
0.00
DVD
void MyApp::OnInit()
{
hACDCSource = RegisterPowerSettingNotification(m_hWnd,
&GUID_ACDC_POWER_SOURCE,
DEVICE_NOTIFY_WINDOW_HANDLE);
}
void MyApp::OnDestroy()
{
if (hACDCSource != 0)
UnregisterPowerSettingNotification(hACDCSource);
}
void KeepSystemAwake()
{
// This example uses a simple, non-localized availablity request diagnostic string
POWER_REQUEST_CONTEXT SimpleRqContext;
SimpleRqContext.Version = POWER_REQUEST_CONTEXT_VERSION;
SimpleRqContext.Flags = POWER_REQUEST_CONTEXT_SIMPLE_STRING;
SimpleRqContext.Reason.SimpleReasonString = L“System needed to burn a CD.";
HANDLE SimplePowerRequest = PowerCreateRequest(&SimpleRqContext);
// Set a system request to prevent automatic sleep
PowerSetRequest(SimplePowerRequest,PowerRequestSystemRequired);
//
// Do work here...
//
// Clear the request
PowerClearRequest(SimplePowerRequest,PowerRequestSystemRequired);
}
アイドル状態のシステムに
おける CPU 使用率
8%
7%
CPU 使用率 (%)
6%
5%
4%
3%
2%
1%
0%
Clean Install
IT Image
Measurement Points
Measurement System
System Under Test
リソース
配分状況の最
適化
タイマー
アクティビ
ティの結合
実行頻度の減
少
システムのアイドル状態の考慮
PC の状態の
切り替えへの
反応
http://www.microsoft.com/japan/whdc/system/pnppwr/powermgmt/backg
roundprocs.mspx
http://www.microsoft.com/japan/whdc/system/pnppwr/mobile_bat_win7.
mspx
http://www.microsoft.com/japan/whdc/system/pnppwr/powermgmt/availa
bilityrequests.mspx
http://www.microsoft.com/japan/whdc/system/pnppwr/powermgmt/optimi
ze_power.mspx
http://www.microsoft.com/japan/whdc/system/pnppwr/powermgm
t/timercoal.mspx
http://www.microsoft.com/japan/whdc/system/pnppwr/powermgm
t/pm_apps.mspx
http://216.55.183.13/pdc2005/slides/fun319_stemen_miller.ppt
http://download.microsoft.com/download/f/0/5/f05a42ce-575b4c60-82d6-208d3754b2d6/integrating-withwindowspowermgmt.ppt
http://www.microsoft.com/japan/whdc/system/pnppwr/powermgmt
/pm-apps_samp.mspx
http://www.microsoft.com/downloads/details.aspx?familyid=c6f14
0ce-3dfb-49c4-b3652a79e799817a&mg_id=10095&displaylang=en