DosGetInfoBlocks: Difference between revisions
Created page with "==Description== Gets the address of: * The thread information block (TIB) of the current thread * The process information block (PIB) of the current process ==Syntax== <PR..." |
No edit summary |
||
Line 1: | Line 1: | ||
==Description== | ==Description== | ||
Gets the address of: | Gets the address of: | ||
* The thread information block (TIB) of the current thread | * The thread information block (TIB) of the current thread | ||
* The process information block (PIB) of the current process | * The process information block (PIB) of the current process | ||
==Syntax== | ==Syntax== | ||
<PRE> | <PRE> | ||
#define INCL_DOSPROCESS | #define INCL_DOSPROCESS | ||
#include <os2.h> | #include <os2.h> | ||
PTIB *pptib; /* | PTIB *pptib; /* A pointer to the address of the TIB in which the current thread is returned. */ | ||
PPIB *pppib; /* | PPIB *pppib; /* The address of a pointer to the PIB in which the current process is returned. */ | ||
APIRET ulrc; /* | APIRET ulrc; /* Return Code. */ | ||
ulrc = DosGetInfoBlocks(pptib, pppib); | ulrc = DosGetInfoBlocks(pptib, pppib); | ||
</PRE> | |||
==Parameters== | ==Parameters== | ||
; | ;pptib (PTIB *) - output : A pointer to the address of the TIB in which the current thread is returned. | ||
You can also specify NULL in this field if you do not want the current address of the TIB returned. See Remarks for a description of the TIB. | You can also specify NULL in this field if you do not want the current address of the TIB returned. See Remarks for a description of the TIB. | ||
; pppib (PPIB *) - output : The address of a pointer to the PIB in which the current process is returned. | ;pppib (PPIB *) - output : The address of a pointer to the PIB in which the current process is returned. | ||
You can also specify NULL in this field if you do not want the current address of the PIB returned. See Remarks for a description of the PIB. | You can also specify NULL in this field if you do not want the current address of the PIB returned. See Remarks for a description of the PIB. | ||
Line 33: | Line 29: | ||
DosGetInfoBlocks returns no values. | DosGetInfoBlocks returns no values. | ||
==Remarks== | ==Remarks== | ||
Line 46: | Line 41: | ||
==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 | ||
#define INCL_DOSERRORS | #define INCL_DOSERRORS | ||
Line 83: | Line 76: | ||
return NO_ERROR; | return NO_ERROR; | ||
} | } | ||
</PRE> | |||
If you only want the address of the TIB returned, code the DosGetInfoBlocks call as follows: | If you only want the address of the TIB returned, code the DosGetInfoBlocks call as follows: | ||
rc = DosGetInfoBlocks(&ptib, NULL); | |||
If you only want the address of the PIB returned, code the DosGetInfoBlocks call as follows: | If you only want the address of the PIB returned, code the DosGetInfoBlocks call as follows: | ||
rc = DosGetInfoBlocks(NULL, &ppib.); | |||
==Related Functions== | ==Related Functions== | ||
* [[OS2 API:CPI:DosCreateThread|DosCreateThread]] | * [[OS2 API:CPI:DosCreateThread|DosCreateThread]] | ||
[[Category:The OS/2 API Project]] | [[Category:The OS/2 API Project]] |
Revision as of 14:05, 24 June 2016
Description
Gets the address of:
- The thread information block (TIB) of the current thread
- The process information block (PIB) of the current process
Syntax
#define INCL_DOSPROCESS #include <os2.h> PTIB *pptib; /* A pointer to the address of the TIB in which the current thread is returned. */ PPIB *pppib; /* The address of a pointer to the PIB in which the current process is returned. */ APIRET ulrc; /* Return Code. */ ulrc = DosGetInfoBlocks(pptib, pppib);
Parameters
- pptib (PTIB *) - output
- A pointer to the address of the TIB in which the current thread is returned.
You can also specify NULL in this field if you do not want the current address of the TIB returned. See Remarks for a description of the TIB.
- pppib (PPIB *) - output
- The address of a pointer to the PIB in which the current process is returned.
You can also specify NULL in this field if you do not want the current address of the PIB returned. See Remarks for a description of the PIB.
Return Code
ulrc (APIRET) - returns
DosGetInfoBlocks returns no values.
Remarks
DosGetInfoBlocks returns the address of the TIB of the current thread. This function also returns the address of the PIB of the current process.
Several items of per-thread information are kept in a read/write area of the process address space called the Thread Information Block, or TIB. You can access this information by calling DosGetInfoBlocks.
TIB2 contains system-specific thread information.
Several items of per-process information are kept in a read/write area of the process address space called the Process Information Block, or PIB. You can access this information by calling DosGetInfoBlocks.
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; }
If you only want the address of the TIB returned, code the DosGetInfoBlocks call as follows:
rc = DosGetInfoBlocks(&ptib, NULL);
If you only want the address of the PIB returned, code the DosGetInfoBlocks call as follows:
rc = DosGetInfoBlocks(NULL, &ppib.);