DosGetProcessorStatus: Difference between revisions
Appearance
m Ak120 moved page OS2 API:CPI:DosGetProcessorStatus to DosGetProcessorStatus |
|||
(5 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
DosGetProcessorStatus returns the ONLINE or OFFLINE status of each processor of an SMP system. The processor status may be set using [[DosSetProcessorStatus]]. ONLINE status imples the processor is available for running work. OFFLINE status implies the processor is not available for running work. | |||
DosGetProcessorStatus returns the ONLINE or OFFLINE status of each processor of an SMP system. The processor status may be set using DosSetProcessorStatus. ONLINE status imples the processor is available for running work. OFFLINE status implies the processor is not available for running work. | |||
==Syntax== | ==Syntax== | ||
APIRET DosGetProcessorStatus (ULONG procid, PULONG status) | |||
==Parameters== | ==Parameters== | ||
;procid (ULONG) input : | ;procid (ULONG) input:Processor ID numbered 1 through n, where there are n processors in total | ||
;status (PULONG) output : Status is defined as follows | ;status (PULONG) output:Status is defined as follows | ||
::PROC_OFFLINE 0x00000000 Processor is offline | ::PROC_OFFLINE 0x00000000 Processor is offline | ||
::PROC_ONLINE 0x00000001 Processor is online | ::PROC_ONLINE 0x00000001 Processor is online | ||
==Return Code== | ==Return Code== | ||
;ulrc (APIRET) returns:DosGetProcessorStatus returns one of the following values | |||
DosGetProcessorStatus returns one of the following values | |||
* 0 NO_ERROR | * 0 NO_ERROR | ||
* 87 ERROR_INVALID_PARAMETER | * 87 ERROR_INVALID_PARAMETER | ||
Line 25: | Line 17: | ||
==Example Code== | ==Example Code== | ||
<PRE> | <PRE> | ||
#define INCL_DOS | |||
#define INCL_DOSSPINLOCK | |||
#include <os2.h> | |||
#include <stdio.h> | |||
#include <stdlib.h> | |||
int main(int argc, char *argv[], char *envp[]){ | int main(int argc, char *argv[], char *envp[]){ | ||
APIRET rc=0; | APIRET rc=0; | ||
Line 33: | Line 31: | ||
if (argc == 1) { | if (argc == 1) { | ||
for (procid=1; rc==0 ;++procid) { | for (procid=1; rc==0 ;++procid) { | ||
rc = DosGetProcessorStatus(procid, | rc = DosGetProcessorStatus(procid, &status); | ||
if (rc==0) { | if (rc==0) { | ||
if (status == PROC_OFFLINE) printf("Processor %u offline\n", procid); | if (status == PROC_OFFLINE) printf("Processor %u offline\n", procid); | ||
Line 39: | Line 37: | ||
} /* endif */ | } /* endif */ | ||
} /* endfor */ | } /* endfor */ | ||
} else for (i=1; i<argc ; ++i) { | |||
} else for (i=1; i argc ; ++i) { | |||
procid = atol(argv[i]); | procid = atol(argv[i]); | ||
rc = DosGetProcessorStatus(procid, | rc = DosGetProcessorStatus(procid, &status); | ||
if (rc) printf(" | if (rc) printf("DosGetProcessorStatus returned %u\n",rc); | ||
else { | else { | ||
if (status == PROC_OFFLINE) printf("Processor %u offline\n", procid); | if (status == PROC_OFFLINE) printf("Processor %u offline\n", procid); | ||
Line 49: | Line 46: | ||
} /* endif */ | } /* endif */ | ||
} /* endfor */ | } /* endfor */ | ||
return rc; | return rc; | ||
} | } | ||
Line 55: | Line 51: | ||
==Related Functions== | ==Related Functions== | ||
* [[DosSetProcessorStatus]] | *[[DosGetProcessorCount]] | ||
*[[DosGetProcessorIdleTime]] | |||
*[[DosSetProcessorStatus]] | |||
[[Category:Dos]] | [[Category:Dos]] |
Latest revision as of 00:51, 19 May 2025
DosGetProcessorStatus returns the ONLINE or OFFLINE status of each processor of an SMP system. The processor status may be set using DosSetProcessorStatus. ONLINE status imples the processor is available for running work. OFFLINE status implies the processor is not available for running work.
Syntax
APIRET DosGetProcessorStatus (ULONG procid, PULONG status)
Parameters
- procid (ULONG) input
- Processor ID numbered 1 through n, where there are n processors in total
- status (PULONG) output
- Status is defined as follows
- PROC_OFFLINE 0x00000000 Processor is offline
- PROC_ONLINE 0x00000001 Processor is online
Return Code
- ulrc (APIRET) returns
- DosGetProcessorStatus returns one of the following values
- 0 NO_ERROR
- 87 ERROR_INVALID_PARAMETER
Example Code
#define INCL_DOS #define INCL_DOSSPINLOCK #include <os2.h> #include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[], char *envp[]){ APIRET rc=0; ULONG procid; ULONG status; int i; if (argc == 1) { for (procid=1; rc==0 ;++procid) { rc = DosGetProcessorStatus(procid, &status); if (rc==0) { if (status == PROC_OFFLINE) printf("Processor %u offline\n", procid); else printf("Processor %u online\n", procid); } /* endif */ } /* endfor */ } else for (i=1; i<argc ; ++i) { procid = atol(argv[i]); rc = DosGetProcessorStatus(procid, &status); if (rc) printf("DosGetProcessorStatus returned %u\n",rc); else { if (status == PROC_OFFLINE) printf("Processor %u offline\n", procid); else printf("Processor %u online\n", procid); } /* endif */ } /* endfor */ return rc; }