The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/servers/is/dmp_pm.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* This file contains procedures to dump to PM' data structures.
    2  *
    3  * The entry points into this file are
    4  *   mproc_dmp:         display PM process table          
    5  *
    6  * Created:
    7  *   May 11, 2005:      by Jorrit N. Herder
    8  */
    9 
   10 #include "inc.h"
   11 #include "../pm/mproc.h"
   12 #include <timers.h> 
   13 #include <minix/config.h> 
   14 #include <minix/type.h> 
   15 
   16 PUBLIC struct mproc mproc[NR_PROCS];
   17 
   18 /*===========================================================================*
   19  *                              mproc_dmp                                    *
   20  *===========================================================================*/
   21 PRIVATE char *flags_str(int flags)
   22 {
   23         static char str[10];
   24         str[0] = (flags & WAITING) ? 'W' : '-';
   25         str[1] = (flags & ZOMBIE)  ? 'Z' : '-';
   26         str[2] = (flags & PAUSED)  ? 'P' : '-';
   27         str[3] = (flags & ALARM_ON)  ? 'A' : '-';
   28         str[4] = (flags & TRACED)  ? 'T' : '-';
   29         str[5] = (flags & STOPPED)  ? 'S' : '-';
   30         str[6] = (flags & SIGSUSPENDED)  ? 'U' : '-';
   31         str[7] = (flags & REPLY)  ? 'R' : '-';
   32         str[8] = (flags & ONSWAP)  ? 'O' : '-';
   33         str[9] = (flags & SWAPIN)  ? 'I' : '-';
   34         str[10] = (flags & DONT_SWAP)  ? 'D' : '-';
   35         str[11] = (flags & PRIV_PROC)  ? 'P' : '-';
   36         str[12] = '\0';
   37 
   38         return str;
   39 }
   40 
   41 PUBLIC void mproc_dmp()
   42 {
   43   struct mproc *mp;
   44   int i, n=0;
   45   static int prev_i = 0;
   46 
   47   printf("Process manager (PM) process table dump\n");
   48 
   49   getsysinfo(PM_PROC_NR, SI_PROC_TAB, mproc);
   50 
   51   printf("-process- -nr-prnt- -pid/ppid/grp- -uid--gid- -nice- -flags------\n");
   52   for (i=prev_i; i<NR_PROCS; i++) {
   53         mp = &mproc[i];
   54         if (mp->mp_pid == 0 && i != PM_PROC_NR) continue;
   55         if (++n > 22) break;
   56         printf("%8.8s %4d%4d  %4d%4d%4d    ", 
   57                 mp->mp_name, i, mp->mp_parent, mp->mp_pid, mproc[mp->mp_parent].mp_pid, mp->mp_procgrp);
   58         printf("%d(%d)  %d(%d)  ",
   59                 mp->mp_realuid, mp->mp_effuid, mp->mp_realgid, mp->mp_effgid);
   60         printf(" %3d  %s  ", 
   61                 mp->mp_nice, flags_str(mp->mp_flags)); 
   62         printf("\n");
   63   }
   64   if (i >= NR_PROCS) i = 0;
   65   else printf("--more--\r");
   66   prev_i = i;
   67 }
   68 
   69 /*===========================================================================*
   70  *                              sigaction_dmp                                *
   71  *===========================================================================*/
   72 PUBLIC void sigaction_dmp()
   73 {
   74   struct mproc *mp;
   75   int i, n=0;
   76   static int prev_i = 0;
   77   clock_t uptime;
   78 
   79   printf("Process manager (PM) signal action dump\n");
   80 
   81   getsysinfo(PM_PROC_NR, SI_PROC_TAB, mproc);
   82   getuptime(&uptime);
   83 
   84   printf("-process- -nr- --ignore- --catch- --block- -tomess-- -pending-- -alarm---\n");
   85   for (i=prev_i; i<NR_PROCS; i++) {
   86         mp = &mproc[i];
   87         if (mp->mp_pid == 0 && i != PM_PROC_NR) continue;
   88         if (++n > 22) break;
   89         printf("%8.8s  %3d  ", mp->mp_name, i);
   90         printf(" 0x%06x 0x%06x 0x%06x 0x%06x   ", 
   91                 mp->mp_ignore, mp->mp_catch, mp->mp_sigmask, mp->mp_sig2mess); 
   92         printf("0x%06x  ", mp->mp_sigpending);
   93         if (mp->mp_flags & ALARM_ON) printf("%8u", mp->mp_timer.tmr_exp_time-uptime);
   94         else printf("       -");
   95         printf("\n");
   96   }
   97   if (i >= NR_PROCS) i = 0;
   98   else printf("--more--\r");
   99   prev_i = i;
  100 }
  101 
  102 /*===========================================================================*
  103  *                              holes_dmp                                    *
  104  *===========================================================================*/
  105 PUBLIC void holes_dmp(void)
  106 {
  107         static struct pm_mem_info pmi;
  108         int h;
  109         int largest_bytes = 0, total_bytes = 0;
  110 
  111         if(getsysinfo(PM_PROC_NR, SI_MEM_ALLOC, &pmi) != OK) {
  112                 printf("Obtaining memory hole list failed.\n");
  113                 return;
  114         }
  115         printf("Available memory stats\n");
  116 
  117         for(h = 0; h < _NR_HOLES; h++) {
  118                 if(pmi.pmi_holes[h].h_base && pmi.pmi_holes[h].h_len) {
  119                         int bytes;
  120                         bytes = (pmi.pmi_holes[h].h_len << CLICK_SHIFT);
  121                         printf("%08lx: %6d kB\n",
  122                                 pmi.pmi_holes[h].h_base << CLICK_SHIFT, bytes / 1024);
  123                         if(bytes > largest_bytes) largest_bytes = bytes;
  124                         total_bytes += bytes;
  125                 }
  126         }
  127         printf("\n"
  128                 "Total memory free:     %7d kB\n"
  129                 "Largest chunk:         %7d kB\n"
  130                 "Uncontiguous rest:     %7d kB (%d%% of total free)\n"
  131                 "Memory high watermark: %7d kB\n",
  132                 total_bytes/1024,
  133                 largest_bytes/1024,
  134                 (total_bytes-largest_bytes)/1024,
  135                 100*(total_bytes/100-largest_bytes/100)/total_bytes,
  136                 (pmi.pmi_hi_watermark/1024 << CLICK_SHIFT));
  137 
  138         return;
  139 }
  140 

Cache object: e94306601be831e608f1986231c38d0a


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.