Jump to content

DosGetInfoBlocks: Difference between revisions

From EDM2
Ak120 (talk | contribs)
No edit summary
Ak120 (talk | contribs)
mNo edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
==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>
  DosGetInfoBlocks(pptib, pppib)
#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);
</PRE>


==Parameters==
==Parameters==
;pptib (PTIB *) - output : A pointer to the address of the TIB in which the current thread is returned.
;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.


==Return Code==
==Return Code==
ulrc (APIRET) - returns
;ulrc (APIRET) - returns:DosGetInfoBlocks returns no values.
 
DosGetInfoBlocks returns no values.  


==Remarks==
==Remarks==
Line 35: Line 20:
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.
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.
[[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.  
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.  
Line 41: Line 26:
==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 79: Line 64:
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);
  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.);
  rc = DosGetInfoBlocks(NULL, &ppib.);


==Related Functions==
==Related Functions==
* [[OS2 API:CPI:DosCreateThread|DosCreateThread]]
* [[DosCreateThread]]


[[Category:The OS/2 API Project]]
[[Category:Dos]]

Latest revision as of 04:12, 26 January 2020

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