DosSetPriority: Difference between revisions
Appearance
m Ak120 moved page OS2 API:CPI:DosSetPriority to DosSetPriority |
No edit summary |
||
Line 1: | Line 1: | ||
Changes the base priority of a child process or thread in the current process. | Changes the base priority of a child process or thread in the current process. | ||
Line 7: | Line 6: | ||
#include <os2.h> | #include <os2.h> | ||
ULONG scope; | ULONG scope; | ||
ULONG ulClass; | ULONG ulClass; | ||
LONG delta; | LONG delta; | ||
ULONG PorTid; | ULONG PorTid; | ||
APIRET ulrc; | APIRET ulrc; | ||
ulrc = DosSetPriority(scope, ulClass, delta, PorTid); | ulrc = DosSetPriority(scope, ulClass, delta, PorTid); | ||
</PRE> | |||
==Parameters== | ==Parameters== | ||
; | ;scope (ULONG) - input: The extent of the priority change. | ||
:The values of this field are shown in the following list: | |||
The values of this field are shown in the following list: | ::0 PRTYS_PROCESS All the threads of any process. | ||
::1 PRTYS_PROCESSTREE All the threads of a process and any descendants. The indicated process must be the current process or a process created by the current process. Detached processes may not be specified. The indicated process may have terminated. | |||
::2 PRTYS_THREAD A single thread of the current process. | |||
;ulClass (ULONG) - input : Priority class of a process. | |||
:The values of this field are shown in the following list: | |||
::0 PRTYC_NOCHANGE No change, leave as is | |||
::1 PRTYC_IDLETIME Idle-time | |||
::2 PRTYC_REGULAR Regular | |||
::3 PRTYC_TIMECRITICAL Time-critical | |||
::4 PRTYC_FOREGROUNDSERVER Fixed high | |||
;delta (LONG) - input : Change to apply to the current base priority level of the process. | |||
; ulClass (ULONG) - input : Priority class of a process. | :This value must range from -31 (PRTYD_MINIMUM) to +31 (PRTYD_MAXIMUM). | ||
;PorTid (ULONG) - input : A process identifier (scope == PRTYS_PROCESS or PRTYS_PROCESSTREE) or a thread identifier (scope == PRTYS_THREAD). | |||
The values of this field are shown in the following list: | :If this operand is equal to zero, the current process or thread is assumed. | ||
==Return Code== | ==Return Code== | ||
ulrc (APIRET) - returns | ulrc (APIRET) - returns | ||
DosSetPriority returns one of the following values: | DosSetPriority returns one of the following values: | ||
* 0 NO_ERROR | * 0 NO_ERROR | ||
* 303 ERROR_INVALID_PROCID | * 303 ERROR_INVALID_PROCID | ||
Line 68: | Line 43: | ||
* 308 ERROR_INVALID_SCOPE | * 308 ERROR_INVALID_SCOPE | ||
* 309 ERROR_INVALID_THREADID | * 309 ERROR_INVALID_THREADID | ||
==Remarks== | ==Remarks== | ||
DosSetPriority allows a process to change the priority of the current process or a child process, as well as any descendants. It also allows a process to change the priority of a single thread within the current process. | DosSetPriority allows a process to change the priority of the current process or a child process, as well as any descendants. It also allows a process to change the priority of a single thread within the current process. | ||
Line 75: | Line 51: | ||
==Example Code== | ==Example Code== | ||
This sample sets the current thread priority to Time Critical level 15. It then uses DosGetInfoBlocks to retrieve the priority. | This sample sets the current thread priority to Time Critical level 15. It then uses DosGetInfoBlocks to retrieve the priority. | ||
<PRE> | <PRE> | ||
#define INCL_DOSPROCESS | #define INCL_DOSPROCESS | ||
Line 111: | Line 86: | ||
return NO_ERROR; | return NO_ERROR; | ||
} | } | ||
</PRE> | |||
==Related Functions== | ==Related Functions== | ||
* [[ | * [[DosEnterCritSec]] | ||
* [[ | * [[DosGetInfoBlocks]] | ||
[[Category: | [[Category:Dos]] |
Revision as of 04:15, 9 January 2017
Changes the base priority of a child process or thread in the current process.
Syntax
#define INCL_DOSPROCESS #include <os2.h> ULONG scope; ULONG ulClass; LONG delta; ULONG PorTid; APIRET ulrc; ulrc = DosSetPriority(scope, ulClass, delta, PorTid);
Parameters
- scope (ULONG) - input
- The extent of the priority change.
- The values of this field are shown in the following list:
- 0 PRTYS_PROCESS All the threads of any process.
- 1 PRTYS_PROCESSTREE All the threads of a process and any descendants. The indicated process must be the current process or a process created by the current process. Detached processes may not be specified. The indicated process may have terminated.
- 2 PRTYS_THREAD A single thread of the current process.
- ulClass (ULONG) - input
- Priority class of a process.
- The values of this field are shown in the following list:
- 0 PRTYC_NOCHANGE No change, leave as is
- 1 PRTYC_IDLETIME Idle-time
- 2 PRTYC_REGULAR Regular
- 3 PRTYC_TIMECRITICAL Time-critical
- 4 PRTYC_FOREGROUNDSERVER Fixed high
- delta (LONG) - input
- Change to apply to the current base priority level of the process.
- This value must range from -31 (PRTYD_MINIMUM) to +31 (PRTYD_MAXIMUM).
- PorTid (ULONG) - input
- A process identifier (scope == PRTYS_PROCESS or PRTYS_PROCESSTREE) or a thread identifier (scope == PRTYS_THREAD).
- If this operand is equal to zero, the current process or thread is assumed.
Return Code
ulrc (APIRET) - returns
DosSetPriority returns one of the following values:
- 0 NO_ERROR
- 303 ERROR_INVALID_PROCID
- 304 ERROR_INVALID_PDELTA
- 305 ERROR_NOT_DESCENDANT
- 307 ERROR_INVALID_PCLASS
- 308 ERROR_INVALID_SCOPE
- 309 ERROR_INVALID_THREADID
Remarks
DosSetPriority allows a process to change the priority of the current process or a child process, as well as any descendants. It also allows a process to change the priority of a single thread within the current process.
When a process changes the priority of current or descendant processes, only default priorities are changed.
Example Code
This sample sets the current thread priority to Time Critical level 15. It then uses DosGetInfoBlocks to retrieve the priority.
#define INCL_DOSPROCESS #define INCL_DOSERRORS #include <os2.h> #include <stdio.h> int main(VOID) { PTIB ptib = NULL; /* Thread information block structure */ PPIB ppib = NULL; /* Process information block structure */ APIRET rc = NO_ERROR; /* Return code */ rc = DosSetPriority (PRTYS_THREAD, /* Change a single thread */ PRTYC_TIMECRITICAL, /* Time critical class */ 15L, /* Increase by 15 */ 0L); /* Assume current thread */ if (rc != NO_ERROR) { printf ("DosSetPriority error : rc = %u\n", rc); return 1; } else { rc = DosGetInfoBlocks(&ptib, &ppib); if (rc != NO_ERROR) { printf ("DosGetInfoBlocks error : rc = %u\n", rc); return 1; } else { printf("Priority Class = %d\n", ((ptib->tib_ptib2->tib2_ulpri) >> 8) & 0x00FF); printf("Priority Level = %d\n", ((ptib->tib_ptib2->tib2_ulpri) & 0x001F) ); } /* endif */ } return NO_ERROR; }