DosGetInfoBlocks

From EDM2
Jump to: navigation, search

Gets the address of:

  • The thread information block (TIB) of the current thread
  • The process information block (PIB) of the current process

Syntax

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.);

Related Functions