home *** CD-ROM | disk | FTP | other *** search
- /*
- * print.c printing memory usage
- *
- * Copyright 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
-
- #include <stdio.h>
-
- #include "process.h"
- #include "print.h"
-
- /*
- * static void PrintAllUsage(FILE *fp, PROGRAM *usage)
- *
- * Description:
- * Print out info about all programs that are running
- *
- * Parameters:
- * fp stream to print to
- * usage the usage to print
- */
-
- static void PrintAllUsage(FILE *fp, PROGRAM *usage)
- {
- long totSize = 0, totRes = 0, totPhys = 0, totPriv = 0;
-
- fprintf(fp, " All Programs:\n");
- fprintf(fp, " "
- "Name\t Size\t Res\t Phys\t Priv\tCopies\n");
-
- while (usage) {
- if (usage->print) {
- fprintf(fp, "%20s\t%6d\t%6d\t%6d\t%6d\t%6d\n",
- usage->progName, usage->size, usage->resSize,
- usage->weightSize, usage->privSize, usage->nProc);
- totSize += usage->size;
- totRes += usage->resSize;
- totPhys += usage->weightSize;
- totPriv += usage->privSize;
- }
- usage = usage->next;
- }
- fprintf(fp, " Totals:\t%6d\t%6d\t%6d\t%6d\n",
- totSize, totRes, totPhys, totPriv);
- }
-
- /*
- * static void PrintMapUsage(FILE *fp, PROGRAM *usage)
- *
- * Description:
- * Print out info about all resident mappings
- *
- * Parameters:
- * fp stream to print to
- * usage the usage to print
- */
-
- static void PrintMapUsage(FILE *fp, PROGRAM *usage)
- {
- long totPhys = 0, totPriv = 0;
- fprintf(fp, " Resident Mappings:\n");
-
- fprintf(fp, " "
- "Name\t Type\t Phys\t Priv\n");
-
- while (usage) {
- if (usage->print && usage->mapType) {
- fprintf(fp, "%20s\t%15s\t%6d\t%6d\n",
- usage->mapName ? usage->mapName : "none",
- usage->mapType, usage->weightSize,
- usage->privSize);
- totPhys += usage->weightSize;
- totPriv += usage->privSize;
- }
- usage = usage->next;
- }
- fprintf(fp, " Totals:\t \t%6d\t%6d\n",
- totPhys, totPriv);
- }
-
- /*
- * static void PrintProcUsage(FILE *fp, PROGRAM *usage, char *procName)
- *
- * Description:
- * Print info about all the mappings for a particular program
- *
- * Parameters:
- * fp stream to print to
- * usage usage to print
- * procName name of the program whose mappings are bing printed
- */
-
- static void PrintProcUsage(FILE *fp, PROGRAM *usage, char *procName)
- {
- long totSize = 0, totRes = 0, totPhys = 0, totPriv = 0;
-
- fprintf(fp, "%20s:\n", procName);
- fprintf(fp, " "
- "Name\t Type\t Size\t Res\t Phys\t Priv\n");
-
- while (usage) {
- if (usage->print) {
- fprintf(fp, "%20s\t%15s\t%6d\t%6d\t%6d\t%6d\n",
- usage->mapName ? usage->mapName : "none",
- usage->mapType, usage->size,
- usage->resSize, usage->weightSize,
- usage->privSize);
- totSize += usage->size;
- totRes += usage->resSize;
- totPhys += usage->weightSize;
- totPriv += usage->privSize;
- }
- usage = usage->next;
- }
- fprintf(fp, " Totals:\t \t%6d\t%6d\t%6d\t%6d\n",
- totSize, totRes, totPhys, totPriv);
- }
-
- /*
- * void PrintUsage(FILE *fp, PRTYPE type, PROGRAM *usage, char *procName)
- *
- * Description:
- * Print info to fp for permanent storage
- *
- * Parameters:
- * fp stream to print to
- * type the type of print out
- * usage the usage to print
- * procName the name of the program to print mappings for, if
- * type is PRProc
- */
-
- void PrintUsage(FILE *fp, PRTYPE type, PROGRAM *usage, char *procName)
- {
- fprintf(fp, "-----------------------------------"
- "-----------------------------------\n");
-
- switch (type) {
- case PRAll:
- PrintAllUsage(fp, usage);
- break;
- case PRMaps:
- PrintMapUsage(fp, usage);
- break;
- case PRProc:
- PrintProcUsage(fp, usage, procName);
- break;
- }
- }
-