Share via


SetProcessInformation 함수(processthreadsapi.h)

지정된 프로세스에 대한 정보를 설정합니다.

구문

BOOL SetProcessInformation(
  [in] HANDLE                    hProcess,
  [in] PROCESS_INFORMATION_CLASS ProcessInformationClass,
       LPVOID                    ProcessInformation,
  [in] DWORD                     ProcessInformationSize
);

매개 변수

[in] hProcess

프로세스에 대한 핸들입니다. 이 핸들에는 PROCESS_SET_INFORMATION 액세스 권한이 있어야 합니다. 자세한 내용은 프로세스 보안 및 액세스 권한을 참조하세요.

[in] ProcessInformationClass

설정할 정보의 종류를 지정하는 PROCESS_INFORMATION_CLASS 열거형의 멤버입니다.

ProcessInformation

ProcessInformationClass 매개 변수로 지정된 정보 형식을 포함하는 개체에 대한 포인터입니다.

ProcessInformationClass 매개 변수가 ProcessMemoryPriority인 경우 이 매개 변수는 구조체를 MEMORY_PRIORITY_INFORMATION MEMORY_PRIORITY_INFORMATION 구조를 가리킵니다.

ProcessInformationClass 매개 변수가 ProcessPowerThrottling인 경우 이 매개 변수는 PROCESS_POWER_THROTTLING_STATE 구조를 가리킵니다.

ProcessInformationClass 매개 변수가 ProcessLeapSecondInfo인 경우 이 매개 변수는 PROCESS_LEAP_SECOND_INFO 구조를 가리킵니다.

ProcessInformationClass 매개 변수가 ProcessOverrideSubsequentPrefetchParameter인 경우 이 매개 변수는 OVERRIDE_PREFETCH_PARAMETER 구조를 가리킵니다.

[in] ProcessInformationSize

ProcessInformation 매개 변수로 지정된 구조체의 크기(바이트)입니다.

ProcessInformationClass 매개 변수가 ProcessMemoryPriority이면 이 매개 변수는 이어야 sizeof(MEMORY_PRIORITY_INFORMATION)합니다.

ProcessInformationClass 매개 변수가 ProcessPowerThrottling인 경우 이 매개 변수는 이어야 sizeof(PROCESS_POWER_THROTTLING_STATE)합니다.

ProcessInformationClass 매개 변수가 ProcessLeapSecondInfo인 경우 이 매개 변수는 이어야 sizeof(PROCESS_LEAP_SECOND_INFO)합니다.

반환 값

함수가 성공하면 반환 값이 0이 아닙니다.

함수가 실패하면 반환 값은 0입니다. 확장 오류 정보를 가져오려면 GetLastError를 호출합니다.

설명

시스템 성능을 향상시키기 위해 애플리케이션은 ProcessMemoryPriority와 함께 SetProcessInformation 함수를 사용하여 백그라운드 작업을 수행하는 스레드의 기본 메모리 우선 순위를 낮추거나 곧 다시 액세스할 것으로 예상되지 않는 파일 및 데이터에 액세스해야 합니다. 예를 들어 파일 인덱싱 애플리케이션은 인덱싱 작업을 수행하는 프로세스에 대해 낮은 기본 우선 순위를 설정할 수 있습니다.

메모리 우선 순위는 페이지가 잘리기 전에 프로세스의 작업 집합 에 남아 있는 기간을 결정하는 데 도움이 됩니다. 프로세스의 메모리 우선 순위는 해당 프로세스의 스레드에서 설정한 프로세스 작업 집합에 추가되는 물리적 페이지의 기본 우선 순위를 결정합니다. 메모리 관리자는 작업 집합을 트리밍할 때 우선 순위가 높은 페이지보다 우선 순위가 낮은 페이지를 트리밍합니다. 이렇게 하면 우선 순위가 높은 페이지가 작업 집합에서 잘릴 가능성이 적고 다시 액세스할 때 페이지 오류를 트리거할 가능성이 적기 때문에 전반적인 시스템 성능이 향상됩니다.

ProcessPowerThrottling 을 사용하면 최적의 성능이 필요하지 않은 경우 성능과 전력 효율성의 균형을 맞추는 데 사용할 수 있는 프로세스에 대한 제한 정책을 사용할 수 있습니다.

프로세스가 를 사용하도록 PROCESS_POWER_THROTTLING_EXECUTION_SPEED설정하면 프로세스가 EcoQoS로 분류됩니다. 시스템은 CPU 빈도를 줄이거나 더 많은 전력 효율적인 코어를 사용하는 등의 전략을 통해 전력 효율성을 높이려고 합니다. EcoQoS는 작업이 배터리 수명을 연장하고 열 및 팬 소음을 줄이는 전경 사용자 환경에 기여하지 않을 때 사용해야 합니다. 성능에 중요한 또는 전경 사용자 환경에는 EcoQoS를 사용하면 안 됩니다. (Windows 11 이전에는 EcoQoS 수준이 존재하지 않았으며 프로세스는 LowQoS로 레이블이 지정되었습니다. 애플리케이션이 명시적으로 를 사용하도록 설정 PROCESS_POWER_THROTTLING_EXECUTION_SPEED하지 않으면 시스템은 자체 추론을 사용하여 서비스 품질 수준을 자동으로 유추합니다. 자세한 내용은 서비스 품질을 참조하세요.

프로세스가 사용을 옵트인하면 PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION프로세스에서 수행한 현재 타이머 확인 요청은 무시됩니다. 프로세스에 속하는 타이머는 더 이상 더 높은 타이머 해상도로 만료되도록 보장되지 않으며, 이는 전력 효율성을 향상시킬 수 있습니다. 를 명시적으로 사용하지 않도록 설정한 PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION후 시스템은 프로세스의 이전 타이머 확인 요청을 기억하고 적용합니다. 기본적으로 Windows 11 창 소유 프로세스가 최종 사용자에게 완전히 폐색되거나 최소화되거나 보이지 않거나 들리지 않는 경우 Windows는 타이머 확인 요청을 자동으로 무시하므로 기본 시스템 해상도보다 높은 해상도를 보장하지 않습니다.

예제

다음 예제에서는 ProcessMemoryPriority를 사용하여 SetProcessInformation을 호출하여 낮은 메모리 우선 순위를 호출 프로세스의 기본값으로 설정하는 방법을 보여 줍니다.

    DWORD ErrorCode;
    BOOL Success;
    MEMORY_PRIORITY_INFORMATION MemPrio;

    //
    // Set low memory priority on the current process.
    //

    ZeroMemory(&MemPrio, sizeof(MemPrio));
    MemPrio.MemoryPriority = MEMORY_PRIORITY_LOW;

    Success = SetProcessInformation(GetCurrentProcess(),
                                   ProcessMemoryPriority,
                                   &MemPrio,
                                   sizeof(MemPrio));

    if (!Success) {
        ErrorCode = GetLastError();
        fprintf(stderr, "Set process memory priority failed: %d\n", ErrorCode);
        goto cleanup;
    }

다음 예제에서는 ProcessPowerThrottling을 사용하여 SetProcessInformation을 호출하여 프로세스의 서비스 품질을 제어하는 방법을 보여 줍니다.

PROCESS_POWER_THROTTLING_STATE PowerThrottling;
RtlZeroMemory(&PowerThrottling, sizeof(PowerThrottling));
PowerThrottling.Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION;

//
// EcoQoS
// Turn EXECUTION_SPEED throttling on. 
// ControlMask selects the mechanism and StateMask declares which mechanism should be on or off.
//

PowerThrottling.ControlMask = PROCESS_POWER_THROTTLING_EXECUTION_SPEED;
PowerThrottling.StateMask = PROCESS_POWER_THROTTLING_EXECUTION_SPEED;

SetProcessInformation(GetCurrentProcess(), 
                      ProcessPowerThrottling, 
                      &PowerThrottling,
                      sizeof(PowerThrottling));

//
// HighQoS
// Turn EXECUTION_SPEED throttling off. 
// ControlMask selects the mechanism and StateMask is set to zero as mechanisms should be turned off.
//

PowerThrottling.ControlMask = PROCESS_POWER_THROTTLING_EXECUTION_SPEED;
PowerThrottling.StateMask = 0;

SetProcessInformation(GetCurrentProcess(), 
                      ProcessPowerThrottling, 
                      &PowerThrottling,
                      sizeof(PowerThrottling));

다음 예제에서는 ProcessPowerThrottling을 사용하여 SetProcessInformation을 호출하여 프로세스의 타이머 해상도를 제어하는 방법을 보여 줍니다.

PROCESS_POWER_THROTTLING_STATE PowerThrottling;
RtlZeroMemory(&PowerThrottling, sizeof(PowerThrottling));
PowerThrottling.Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION;

//
// Ignore Timer Resolution Requests.
// Turn IGNORE_TIMER_RESOLUTION throttling on. 
// ControlMask selects the mechanism and StateMask declares which mechanism should be on or off.
//

PowerThrottling.ControlMask = PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION;
PowerThrottling.StateMask = PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION;

SetProcessInformation(GetCurrentProcess(), 
                      ProcessPowerThrottling, 
                      &PowerThrottling,
                      sizeof(PowerThrottling));

//
// Always honor Timer Resolution Requests.
// Turn IGNORE_TIMER_RESOLUTION throttling off. 
// ControlMask selects the mechanism and StateMask is set to zero as mechanisms should be turned off.
//

PowerThrottling.ControlMask = PROCESS_POWER_THROTTLING_IGNORE_TIMER_RESOLUTION;
PowerThrottling.StateMask = 0;

SetProcessInformation(GetCurrentProcess(), 
                      ProcessPowerThrottling, 
                      &PowerThrottling,
                      sizeof(PowerThrottling));

다음 예제에서는 ProcessPowerThrottling을 사용하여 SetProcessInformation을 호출하여 기본 시스템 관리 동작으로 다시 설정하는 방법을 보여 줍니다.

PROCESS_POWER_THROTTLING_STATE PowerThrottling;
RtlZeroMemory(&PowerThrottling, sizeof(PowerThrottling));
PowerThrottling.Version = PROCESS_POWER_THROTTLING_CURRENT_VERSION;

//
// Let system manage all power throttling. ControlMask is set to 0 as we don't want 
// to control any mechanisms.
//

PowerThrottling.ControlMask = 0;
PowerThrottling.StateMask = 0;

SetProcessInformation(GetCurrentProcess(), 
                      ProcessPowerThrottling, 
                      &PowerThrottling,
                      sizeof(PowerThrottling));
 

요구 사항

요구 사항
지원되는 최소 클라이언트 Windows 8 [데스크톱 앱 | UWP 앱]
지원되는 최소 서버 Windows Server 2012 [데스크톱 앱 | UWP 앱]
대상 플랫폼 Windows
헤더 processthreadsapi.h(Windows.h 포함)
라이브러리 Kernel32.lib
DLL Kernel32.dll

참고 항목

GetProcessInformation 함수, SetThreadInformation 함수, MEMORY_PRIORITY_INFORMATION 구조체, SetProcessInformation 함수, PROCESS_INFORMATION_CLASS 열거형, OVERRIDE_PREFETCH_PARAMETER 구조