/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* perf720 src/perf/perfagent/usr/samples/perfagent/server/SpmiSupl1.c 1.6 */ /* */ /* */ /* */ /* OBJECT CODE ONLY SOURCE MATERIALS */ /* */ /* COPYRIGHT International Business Machines Corp. 1992,1993 */ /* All Rights Reserved */ /* */ /* The source code for this program is not published or otherwise */ /* divested of its trade secrets, irrespective of what has been */ /* deposited with the U.S. Copyright Office. */ /* */ /* IBM_PROLOG_END_TAG */ static char *Sccs_id = "@(#)20 1.5 src/perf/perfagent/usr/samples/perfagent/server/SpmiSupl1.c, perfagent, perf411, 9430C411a 7/29/94 17:33:02"; /* * COMPONENT_NAME: (PERFAGENT) - Performance Agent * * FUNCTIONS: Sample code * * ORIGINS: 30 * * (C) COPYRIGHT International Business Machines Corp. 1992, 1993 * All Rights Reserved * Licensed Material - Property of IBM * * US Government Users Restricted Rights - Use, duplication or * disclosure restricted by GSA ADP Schedule Contract with IBM Corp. * THE SOURCE CODE EXAMPLES PROVIDED BY IBM ARE ONLY INTENDED TO ASSIST IN THE DEVELOPMENT OF A WORKING SOFTWARE PROGRAM. THE SOURCE CODE EXAMPLES DO NOT FUNCTION AS WRITTEN: ADDITIONAL CODE IS REQUIRED. IN ADDITION, THE SOURCE CODE EXAMPLES MAY NOT COMPILE AND/OR BIND SUCCESSFULLY AS WRITTEN. INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THE SOURCE CODE EXAMPLES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS, "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOURCE CODE EXAMPLES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS, IS WITH YOU. SHOULD ANY PART OF THE SOURCE CODE EXAMPLES PROVE DEFECTIVE, YOU (AND NOT IBM OR AN AUTHORIZED RISC System/6000* WORKSTATION DEALER) ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. IBM does not warrant that the contents of the source code examples, whether individually or as one or more groups, will meet your requirements or that the source code examples are error-free. * RISC System/6000 is a trademark of International Business Machines Corporation. */ #ifdef _AIX #define CONST const #else #define CONST #endif #include #include #include #include #include extern char SpmiErrmsg[]; struct dat { u_long a; u_long b; u_long c; u_long d; }; static CONST struct SpmiRawStat PUStats[] = { { "gadgets", "Fake counter value", 0, 100, SiCounter, SiLong, 1, SZ_OFF(dat, a, SiULong)}, { "widgets", "Another fake counter value", 0, 100, SiCounter, SiLong, 2, SZ_OFF(dat, b, SiULong)}, }; static CONST struct SpmiRawStat FakeMemStats[] = { { "level", "Fake quantity value", 0, 100, SiQuantity, SiLong, 1, SZ_OFF(dat, c, SiULong)}, { "queue", "Another fake quantity value", 0, 100, SiQuantity, SiLong, 2, SZ_OFF(dat, d, SiULong)}, }; static CONST cx_create cx_table[] = { {"DDS/IBM", "IBM-defined Dynamic Data Suppliers", 2, 0, NULL, 0, NULL, 0, NULL, SiNoInst}, {"DDS/IBM/Test", "Bogus Context Number 1", 220, 0, (struct SpmiRawStat *)PUStats, STAT_L(PUStats), NULL, 0, NULL, SiNoInst}, {"DDS/IBM/Moretest", "Bogus Context Number 2", 221, 0, NULL, 0, NULL, 0, NULL, SiNoInst}, {"DDS/IBM/Moretest/SubTest", "Bogus Context Number 3", 222, 0, (struct SpmiRawStat *)FakeMemStats, STAT_L(FakeMemStats), NULL, 0, NULL, SiNoInst}, }; static int CxCount = CX_L(cx_table); /* Count of contexts defined */ static SpmiShare *dataarea = NULL; /* Shared memory pointer */ static struct dat *d = NULL; /* Pointer to stats data area */ void SpmiStopMe() { dataarea = NULL; SpmiExit(); exit(0); } int main() { #ifdef _AIX dataarea = SpmiDdsInit((cx_create *)cx_table, CxCount, NULL, 0, "/etc/SpmiSupl1SHM"); #else dataarea = SpmiDdsInit((cx_create *)cx_table, CxCount, NULL, 0, "/etc/SpmiSupl1SHM", 16*1024); #endif if (!dataarea) { printf("%s", SpmiErrmsg); exit(-1); } d = (struct dat *)&dataarea->SiShArea[0]; #ifdef _NO_PROTO signal(SIGTERM, (void(*)())SpmiStopMe); signal(SIGHUP, (void(*)())SpmiStopMe); signal(SIGINT, (void(*)())SpmiStopMe); signal(SIGSEGV, (void(*)())SpmiStopMe); #else signal(SIGTERM, (void(*)(int))SpmiStopMe); signal(SIGHUP, (void(*)(int))SpmiStopMe); signal(SIGINT, (void(*)(int))SpmiStopMe); signal(SIGSEGV, (void(*)(int))SpmiStopMe); #endif /* _NO_PROTO */ gettimeofday(&dataarea->SiShT, NULL); d->a = 22; d->b = 42; d->c = 28; d->d = 62; while(!dataarea->SiShGoAway) { #ifdef _AIX usleep(499000); #else sleep(5); #endif gettimeofday(&dataarea->SiShT, NULL); d->a += dataarea->SiShT.tv_sec & 0xff; d->b += dataarea->SiShT.tv_sec & 0xf; d->c += (dataarea->SiShT.tv_sec & 0x20f) & 0xffff; d->d += (dataarea->SiShT.tv_sec & 0x7f) & 0xffff; } SpmiStopMe(); }