Platform SDK: DLLs, Processes, and Threads

JOBOBJECT_BASIC_LIMIT_INFORMATION

The JOBOBJECT_BASIC_LIMIT_INFORMATION structure contains basic limit information for a job object.

typedef struct _JOBOBJECT_BASIC_LIMIT_INFORMATION {
    LARGE_INTEGER PerProcessUserTimeLimit;
    LARGE_INTEGER PerJobUserTimeLimit;
    DWORD LimitFlags;
    SIZE_T MinimumWorkingSetSize;
    SIZE_T MaximumWorkingSetSize;
    DWORD ActiveProcessLimit;
    ULONG_PTR Affinity;
    DWORD PriorityClass;
    DWORD SchedulingClass;
} JOBOBJECT_BASIC_LIMIT_INFORMATION, *PJOBOBJECT_BASIC_LIMIT_INFORMATION;

Members

PerProcessUserTimeLimit
Ignored unless LimitFlags specifies JOB_OBJECT_LIMIT_PROCESS_TIME. Specifies the per-process user-mode execution time limit, in 100-nanosecond ticks.

The system periodically checks to determine whether each process associated with the job has accumulated more user-mode time than the set limit. If it has, the process is terminated.

PerJobUserTimeLimit
Ignored unless LimitFlags specifies JOB_OBJECT_LIMIT_JOB_TIME. Specifies the per-job user-mode execution time limit, in 100-nanosecond ticks. The system adds the current time of the processes associated with the job to this limit. For example, if you set this limit to 1 minute, and the job has a process that has accumulated 5 minutes of user-mode time, the limit actually enforced is 6 minutes.

The system periodically checks to determine whether the sum of the user-mode execution time for all processes is greater than this end-of-job limit. If it is, the action specified in the EndOfJobTimeAction member of the JOBOBJECT_END_OF_JOB_TIME_INFORMATION structure is carried out. By default, all processes are terminated and the status code is set to ERROR_NOT_ENOUGH_QUOTA.

LimitFlags
Specifies the limit flags that are in effect. This member is a bit field that determines whether other structure members are used. Any combination of the following values can be specified.
Value Meaning
JOB_OBJECT_LIMIT_ACTIVE_PROCESS Establishes a maximum number of simultaneously active processes associated with the job.
JOB_OBJECT_LIMIT_AFFINITY Causes all processes associated with the job to use the same processor affinity.
JOB_OBJECT_LIMIT_BREAKAWAY_OK If any process associated with the job creates a child process using the CREATE_BREAKAWAY_FROM_JOB flag while this limit is in effect, the child process is not associated with the job.

This limit requires use of a JOBOBJECT_EXTENDED_LIMIT_INFORMATION structure. The BasicLimitInformation member is a JOBOBJECT_BASIC_LIMIT_INFORMATION structure.

JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION Forces a call to the SetErrorMode function with the SEM_NOGPFAULTERRORBOX flag for each process associated with the job.

If an exception occurs and the system calls the UnhandledExceptionFilter function, the debugger will be given a chance to act. If there is no debugger, the functions returns EXCEPTION_EXECUTE_HANDLER. Normally, this will cause termination of the process with the exception code as the exit status.

JOB_OBJECT_LIMIT_JOB_MEMORY Causes all processes associated with the job to limit the job-wide sum of their committed memory. When a process attempts to commit memory that would exceed the job-wide limit, it fails. If the job object is associated with a completion port, a JOB_OBJECT_MSG_JOB_MEMORY_LIMIT message is sent to the completion port.
JOB_OBJECT_LIMIT_JOB_TIME Establishes a user-mode execution time limit for the job. This flag cannot be used with JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME.
JOB_OBJECT_LIMIT_PRIORITY_CLASS Causes all processes associated with the job to use the same priority class. For more information, see Scheduling Priorities.
JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME Preserves any job time limits you previously set. As long as this flag is set, you can establish a per-job time limit once, then alter other limits in subsequent calls. This flag cannot be used with JOB_OBJECT_LIMIT_JOB_TIME.
JOB_OBJECT_LIMIT_PROCESS_MEMORY Causes all processes associated with the job to limit their committed memory. When a process attempts to commit memory that would exceed the per-process limit, it fails. If the job object is associated with a completion port, a JOB_OBJECT_MSG_PROCESS_MEMORY_LIMIT message is sent to the completion port.
JOB_OBJECT_LIMIT_PROCESS_TIME Establishes a user-mode execution time limit for each currently active process and for all future processes associated with the job.
JOB_OBJECT_LIMIT_SCHEDULING_CLASS Causes all processes in the job to use the same scheduling class.
JOB_OBJECT_LIMIT_WORKINGSET Causes all processes associated with the job to use the same minimum and maximum working set sizes.
JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK Allows any process associated with the job to create child processes that are not associated with the job.

This limit requires use of a JOBOBJECT_EXTENDED_LIMIT_INFORMATION structure. The BasicLimitInformation member is a JOBOBJECT_BASIC_LIMIT_INFORMATION structure.


MinimumWorkingSetSize
Ignored unless the LimitFlags member specifies JOB_OBJECT_LIMIT_WORKINGSET. Specifies the minimum working set size for all processes associated with the job.
MaximumWorkingSetSize
Ignored unless LimitFlags specifies JOB_OBJECT_LIMIT_WORKINGSET. Specifies the maximum working set size for all processes associated with the job.
ActiveProcessLimit
Ignored unless LimitFlags specifies JOB_OBJECT_LIMIT_ACTIVE_PROCESS. Specifies the active process limit for the job. If you try to associate a process with a job, and this causes the active process count to exceed this limit, the process is terminated and the association fails.
Affinity
Ignored unless LimitFlags specifies JOB_OBJECT_LIMIT_AFFINITY. Specifies the processor affinity for all processes associated with the job. The affinity must be a proper subset of the system affinity mask obtained by calling the GetProcessAffinityMask function. The affinity of each thread is set to this value, but threads are free to subsequently set their affinity, as long as it is a subset of the specified affinity mask. Processes cannot set their own affinity mask.
PriorityClass
Ignored unless LimitFlags specifies JOB_OBJECT_LIMIT_PRIORITY_CLASS. Specifies the priority class for all processes associated with the job. Processes and threads cannot modify their priority class. The calling process must enable the SE_INC_BASE_PRIORITY_NAME privilege.
SchedulingClass
Ignored unless LimitFlags specifies JOB_OBJECT_LIMIT_SCHEDULING_CLASS. Specifies the scheduling class for all processes associated with the job.

The valid values are 0 to 9. Use 0 for the least favorable scheduling class relative to other threads, and 9 for the most favorable scheduling class relative to other threads. By default, this value is 5. To use a scheduling class greater than 5, the calling process must enable the SE_INC_BASE_PRIORITY_NAME privilege.

Remarks

Processes can still empty their working sets using the SetProcessWorkingSetSize function, even when JOB_OBJECT_LIMIT_WORKINGSET is used. However, you cannot use SetProcessWorkingSetSize to change the minimum or maximum working set size.

The system increments the active process count when you attempt to associate a process with a job. If the limit is exceeded, the system decrements the active process count only when the process terminates and all handles to the process are closed. Therefore, if you have an open handle to a process that has been terminated in such a manner, you cannot associate any new processes until the handle is closed and the active process count is below the limit.

Requirements

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Unsupported.
  Header: Declared in Winnt.h; include Windows.h.

See Also

Processes and Threads Overview, Process and Thread Structures, GetProcessAffinityMask, JOBOBJECT_END_OF_JOB_TIME_INFORMATION, JOBOBJECT_EXTENDED_LIMIT_INFORMATION QueryInformationJobObject, SetInformationJobObject, SetProcessWorkingSetSize