mapmem - patch 1

Mark Dapoz mdapoz at hybrid.uucp
Mon May 7 12:49:29 AEST 1990


This patch fixes a problem with the page device allocation display, it
erroneously displayed allocated pages as free pages and free pages as
allocated pages.  Thanks go to Richard Gumpertz (rhg at CPS.COM) for locating 
and fixing the problems addressed by this patch.

To apply this patch, feed the contents of this article through the following 
command:  "patch -p0 < thisfile"  


*** mapmem.c~	Mon Apr 23 23:52:06 1990
--- mapmem.c	Sun May  6 22:35:49 1990
***************
*** 1,4
! static char sccsid[] = "@(#)$Id: mapmem.c, V1.2.0.0 90/04/23 20:28:32 $";
  
  /*
   * map.c - display kernel allocation map information

--- 1,4 -----
! static char sccsid[] = "@(#)$Id: mapmem.c, V1.2.0.1 90/05/06 22:26:02 $";
  
  /*
   * map.c - display kernel allocation map information
***************
*** 2,8
  
  /*
   * map.c - display kernel allocation map information
!  * Version : 1.2.0.0 - 90/04/23 20:38:32
   * Authors  : Michael J. Young
   * 	      Mark Dapoz (unix-pc version)
   * USmail   : Software Development Technologies, Inc.

--- 2,8 -----
  
  /*
   * map.c - display kernel allocation map information
!  * Version : 1.2.0.1 - 90/05/06 22:26:02
   * Authors  : Michael J. Young
   * 	      Mark Dapoz (unix-pc version)
   * USmail   : Software Development Technologies, Inc.
***************
*** 32,37
   *    Originated.
   * Tue Apr 23 23:27:23 EDT 1990 - M. Dapoz (mdapoz%hybrid at cs.toronto.edu)
   *    Hacked to work with unix-pc (aka 3b1) kernel
   */
  
  #define patch_level 0

--- 32,39 -----
   *    Originated.
   * Tue Apr 23 23:27:23 EDT 1990 - M. Dapoz (mdapoz%hybrid at cs.toronto.edu)
   *    Hacked to work with unix-pc (aka 3b1) kernel
+  * Sun May 06 22:26:02 EDT 1990 - R. Gumpertz (rhg at CPS.COM)
+  *    Fixed problem with display map when displaying page device allocations
   */
  
  #define patch_level 1
***************
*** 34,40
   *    Hacked to work with unix-pc (aka 3b1) kernel
   */
  
! #define patch_level 0
  
  #include <nlist.h>
  #include <stdio.h>

--- 36,42 -----
   *    Fixed problem with display map when displaying page device allocations
   */
  
! #define patch_level 1
  
  #include <nlist.h>
  #include <stdio.h>
***************
*** 148,154
  
  void version (){
  	printf ("\nKernel Allocation Map Display\n");
! 	printf ("Version : 1.2 (unix-pc) - 90/04/23 20:28:32, Patch Level %d\n", patch_level);
  	printf ("%s\n", sccsid);
  }
  

--- 150,156 -----
  
  void version (){
  	printf ("\nKernel Allocation Map Display\n");
! 	printf ("Version : 1.2 (unix-pc) - 90/05/06 22:26:02, Patch Level %d\n", patch_level);
  	printf ("%s\n", sccsid);
  }
  
***************
*** 249,255
  #ifdef UDEBUG
  	printf("updating map page addr=%x symbol=%c\n", addr, symbol);
  #endif
! 	dmap[addr/NBPC] = symbol;
  }
  
  /*

--- 251,258 -----
  #ifdef UDEBUG
  	printf("updating map page addr=%x symbol=%c\n", addr, symbol);
  #endif
! 	if ((addr /= NBPC) < MAX_ENTRIES)
! 	    dmap[addr] = symbol;
  }
  
  /*
***************
*** 254,260
  
  /*
   * interpret_smap : scans through the copy of the swap allocation map and
!  * updates the display map accordingly.  The total number of used blocks in 
   * the map are returned.
   */
  int interpret_smap(dmap, smap)

--- 257,263 -----
  
  /*
   * interpret_smap : scans through the copy of the swap allocation map and
!  * updates the display map accordingly.  The total number of free blocks in 
   * the map are returned.
   */
  int interpret_smap(dmap, smap)
***************
*** 261,267
  char dmap[];
  struct mapent *smap;
  {
! 	int total_used = 0;
  	int raddr;
  	struct mapent *next_smap;
  	struct mapent sentry;

--- 264,270 -----
  char dmap[];
  struct mapent *smap;
  {
! 	int total_free = 0;
  	int raddr;
  	struct mapent *next_smap;
  	struct mapent sentry;
***************
*** 279,285
  	printf("dmap = %x\n", dmap);
  	printf("m_limit = %x\n", sheader.m_limit);
  #endif
! 	memset (dmap, 0, MAX_ENTRIES);
  	for (next_smap=smap+1; next_smap != sheader.m_limit; next_smap++){
  #ifdef DEBUG
  	    printf("smap= %x\n", next_smap);

--- 282,294 -----
  	printf("dmap = %x\n", dmap);
  	printf("m_limit = %x\n", sheader.m_limit);
  #endif
! 	if (knswap < MAX_ENTRIES) {
! 	    memset (dmap, '*', knswap);
! 	    memset (dmap+knswap, 0, MAX_ENTRIES-knswap);
! 	}
! 	else
! 	    memset (dmap, '*', MAX_ENTRIES);
! 
  	for (next_smap=smap+1; next_smap != sheader.m_limit; next_smap++){
  #ifdef DEBUG
  	    printf("smap= %x\n", next_smap);
***************
*** 296,302
  	    printf("m_size = %x\n", sentry.m_size);
  	    printf("m_addr = %x\n", sentry.m_addr);
  #endif
! 	    total_used+=sentry.m_size;
  	    for (raddr=sentry.m_addr*NBPC; sentry.m_size; sentry.m_size--, raddr+=NBPC)
  		update_map_page(dmap, raddr, '*');
  	}

--- 305,311 -----
  	    printf("m_size = %x\n", sentry.m_size);
  	    printf("m_addr = %x\n", sentry.m_addr);
  #endif
! 	    total_free+=sentry.m_size;
  	    for (raddr=sentry.m_addr*NBPC; sentry.m_size; sentry.m_size--, raddr+=NBPC)
  		update_map_page(dmap, raddr, '.');
  	}
***************
*** 298,304
  #endif
  	    total_used+=sentry.m_size;
  	    for (raddr=sentry.m_addr*NBPC; sentry.m_size; sentry.m_size--, raddr+=NBPC)
! 		update_map_page(dmap, raddr, '*');
  	}
  	return total_used;
  }

--- 307,313 -----
  #endif
  	    total_free+=sentry.m_size;
  	    for (raddr=sentry.m_addr*NBPC; sentry.m_size; sentry.m_size--, raddr+=NBPC)
! 		update_map_page(dmap, raddr, '.');
  	}
  	return total_free;
  }
***************
*** 300,306
  	    for (raddr=sentry.m_addr*NBPC; sentry.m_size; sentry.m_size--, raddr+=NBPC)
  		update_map_page(dmap, raddr, '*');
  	}
! 	return total_used;
  }
  
  /*

--- 309,315 -----
  	    for (raddr=sentry.m_addr*NBPC; sentry.m_size; sentry.m_size--, raddr+=NBPC)
  		update_map_page(dmap, raddr, '.');
  	}
! 	return total_free;
  }
  
  /*
***************
*** 377,383
  	    printf("c_page = %x\n", mentry.c_page);
  	    printf("c_free = %x\n", mentry.c_free);
  #endif
! 	    if (mentry.c_free)
  	    	total_free++;
  	    else
  	    	update_map_page(dmap, raddr, symbol[mentry.c_type]);

--- 386,392 -----
  	    printf("c_page = %x\n", mentry.c_page);
  	    printf("c_free = %x\n", mentry.c_free);
  #endif
! 	    if (mentry.c_free) {
  	    	total_free++;
  		update_map_page(dmap, raddr, '.');
  	    }
***************
*** 379,384
  #endif
  	    if (mentry.c_free)
  	    	total_free++;
  	    else
  	    	update_map_page(dmap, raddr, symbol[mentry.c_type]);
  	}

--- 388,395 -----
  #endif
  	    if (mentry.c_free) {
  	    	total_free++;
+ 		update_map_page(dmap, raddr, '.');
+ 	    }
  	    else
  	    	update_map_page(dmap, raddr, symbol[mentry.c_type]);
  	}
***************
*** 525,532
  	time_t tm;
  	boolean done = FALSE;		/* will be nonzero when ready to quit */
  	int mem_or_swap = 0;		/* 0 = display core map, 1 = swap map */
! 	int free = 0;			/* free items in core allocation map */
! 	int used = 0;			/* used items in swap allocation map */
  	char highlight=-1;		/* char to highlight */
  	char chr;
  	int disp_addr=0;

--- 536,542 -----
  	time_t tm;
  	boolean done = FALSE;		/* will be nonzero when ready to quit */
  	int mem_or_swap = 0;		/* 0 = display core map, 1 = swap map */
! 	int free = 0;			/* free items in allocation map */
  	char highlight=-1;		/* char to highlight */
  	char chr;
  	int disp_addr=0;
***************
*** 581,587
  			/*
  			 * update and display swap map
  			 */
! 			used = interpret_smap(dmap, namelist[SWAP_MAP].n_value);
  			standout();
  			mvaddstr (0, 29, "Page Device Allocation");
  			standend();

--- 591,597 -----
  			/*
  			 * update and display swap map
  			 */
! 			free = interpret_smap(dmap, namelist[SWAP_MAP].n_value);
  			standout();
  			mvaddstr (0, 29, "Page Device Allocation");
  			standend();
***************
*** 587,593
  			standend();
  			move (1,0);
  			clrtoeol();
! 			mvprintw (1,  0, "Total page space = %d Blocks (4K), %d Free (%2.1f%%)", knswap, knswap-used, (float)(knswap-used)/knswap*100);
  			move (DISP_ROWS+2,0);
  			clrtoeol();
  			move (DISP_ROWS+3,0);

--- 597,603 -----
  			standend();
  			move (1,0);
  			clrtoeol();
! 			mvprintw (1,  0, "Total page space = %d Blocks (4K), %d Free (%2.1f%%)", knswap, free, (float)free/knswap*100);
  			move (DISP_ROWS+2,0);
  			clrtoeol();
  			move (DISP_ROWS+3,0);
***************
*** 598,604
  			clrtoeol();
  			move (DISP_ROWS+6,0);
  			clrtoeol();
! 			print_map(dmap, '*', disp_addr);
  		}
  
  		/*

--- 608,614 -----
  			clrtoeol();
  			move (DISP_ROWS+6,0);
  			clrtoeol();
! 			print_map(dmap, -1, disp_addr);
  		}
  
  		/*
***************
*** 622,627
  			highlight=chr;
  			break;
  
  		case ' ':	/* display all pages */
  			highlight=-1;
  			break;

--- 632,638 -----
  			highlight=chr;
  			break;
  
+ 		case '*':
  		case ' ':	/* display all pages */
  			highlight=-1;
  			break;
-- 
Managing a software development team 	|   Mark Dapoz  
is a lot like being on the psychiatric	|   mdapoz%hybrid at cs.toronto.edu
ward.  -Mitch Kapor, San Jose Mercury	|   ...uunet!mnetor!hybrid!mdapoz



More information about the Comp.sys.att mailing list