Presentation is loading. Please wait.

Presentation is loading. Please wait.

写真提供 : Bryan Thomas Alper Sarikaya に感謝の意を表します。

Similar presentations


Presentation on theme: "写真提供 : Bryan Thomas Alper Sarikaya に感謝の意を表します。"— Presentation transcript:

1

2

3

4

5

6

7

8 写真提供 : Bryan Thomas Alper Sarikaya に感謝の意を表します。

9

10 1. 『 Laptop Shipments Exceed Desktops For The First Time 』 (Antone Gonsalves 著、 InformationWeek)

11

12

13

14

15

16

17

18 出典 : Intel のホワイトペーパー『 Energy Efficient Applications 』

19 電力消費 (W)

20 18.35 15.97

21

22 実行頻度の 減少 タイマー ア クティビテ ィの結合 リソース 配分状況の 最適化 PC の状態 遷移への 反応 システムのアイドル状態の考慮

23

24 void EatBatteryLife() { HANDLE sharedResource = NULL; //spawn multiple threads, one of which does this: while (sharedResource == NULL) { waitTime++; } 不適切な例

25 //thread 1's code void UpdateSharedResource() { //set sharedResource sharedResource = UpdateResource(); // Set sharedResourceIsReadyEvent to // signaled SetEvent(sharedResourceIsReadyEvent); } //thread 2's code void ConsumeSharedResource() { DWORD dwWaitResult; dwWaitResult = WaitForSingleObjectEx( sharedResourceIsReadyEvent, INFINITE, FALSE); // indefinite wait switch (dwWaitResult) { case WAIT_OBJECT_0: // // TODO: use sharedResource // break; default: return 0; }

26

27 void InitBatteryLifeEaterApp() { timeBeginPeriod(1); //run your whole app } void CleanupBatteryLifeEaterApp() { timeEndPeriod(1); } 不適切な例

28 タイマー 刻み 15.6 ms Windows 7 Windows Vista

29 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 );

30 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! }

31

32 void MyApp::OnInit() { hACDCSource = RegisterPowerSettingNotification(m_hWnd, &GUID_ACDC_POWER_SOURCE, DEVICE_NOTIFY_WINDOW_HANDLE); } void MyApp::OnDestroy() { if (hACDCSource != 0) UnregisterPowerSettingNotification(hACDCSource); }

33

34

35 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); }

36

37

38

39

40

41

42 実行頻度の減 少 タイマー アクティビ ティの結合 リソース 配分状況の最 適化 PC の状態の 切り替えへの 反応 システムのアイドル状態の考慮

43

44

45

46

47


Download ppt "写真提供 : Bryan Thomas Alper Sarikaya に感謝の意を表します。"

Similar presentations


Ads by Google