diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:16:21 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:16:21 +0200 |
commit | 88a2d0007db222c339f0b6a17794a2014a241892 (patch) | |
tree | 75105ef49b3a52b7ee176a1ad480e7652e49825f /zen/process_status.h | |
parent | 4.2 (diff) | |
download | FreeFileSync-88a2d0007db222c339f0b6a17794a2014a241892.tar.gz FreeFileSync-88a2d0007db222c339f0b6a17794a2014a241892.tar.bz2 FreeFileSync-88a2d0007db222c339f0b6a17794a2014a241892.zip |
4.3
Diffstat (limited to 'zen/process_status.h')
-rw-r--r-- | zen/process_status.h | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/zen/process_status.h b/zen/process_status.h index cc5825aa..15266b28 100644 --- a/zen/process_status.h +++ b/zen/process_status.h @@ -3,29 +3,55 @@ #ifdef FFS_WIN #include "win.h" //includes "windows.h" + +#elif defined FFS_LINUX #endif namespace zen { -struct DisableStandby //signal a "busy" state to the operating system +struct PreventStandby //signal a "busy" state to the operating system { #ifdef FFS_WIN - DisableStandby() { ::SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED /* | ES_AWAYMODE_REQUIRED*/ ); } - ~DisableStandby() { ::SetThreadExecutionState(ES_CONTINUOUS); } + PreventStandby() { ::SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED /* | ES_AWAYMODE_REQUIRED*/ ); } + ~PreventStandby() { ::SetThreadExecutionState(ES_CONTINUOUS); } #endif }; +struct ScheduleForBackgroundProcessing //lower CPU and file I/O priorities +{ +#ifdef FFS_WIN #ifndef PROCESS_MODE_BACKGROUND_BEGIN #define PROCESS_MODE_BACKGROUND_BEGIN 0x00100000 // Windows Server 2003 and Windows XP/2000: This value is not supported! #define PROCESS_MODE_BACKGROUND_END 0x00200000 // #endif -struct ScheduleForBackgroundProcessing //lower CPU and file I/O priorities -{ -#ifdef FFS_WIN - ScheduleForBackgroundProcessing() { ::SetPriorityClass(::GetCurrentProcess(), PROCESS_MODE_BACKGROUND_BEGIN); } + ScheduleForBackgroundProcessing() { ::SetPriorityClass(::GetCurrentProcess(), PROCESS_MODE_BACKGROUND_BEGIN); } //this call lowers CPU priority, too!! ~ScheduleForBackgroundProcessing() { ::SetPriorityClass(::GetCurrentProcess(), PROCESS_MODE_BACKGROUND_END); } + +#elif defined FFS_LINUX + /* + CPU prio: + int getpriority(PRIO_PROCESS, 0); - errno caveat! + int ::setpriority(PRIO_PROCESS, 0, int prio); //a zero value for "who" denotes the calling process + + priority can be decreased, but NOT increased :( + + file I/O prio: + ScheduleForBackgroundProcessing() : oldIoPrio(::ioprio_get(IOPRIO_WHO_PROCESS, ::getpid())) + { + if (oldIoPrio != -1) + ::ioprio_set(IOPRIO_WHO_PROCESS, ::getpid(), IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0)); + } + ~ScheduleForBackgroundProcessing() + { + if (oldIoPrio != -1) + ::ioprio_set(IOPRIO_WHO_PROCESS, ::getpid(), oldIoPrio); + } + + private: + const int oldIoPrio; + */ #endif }; } |