コード例 #1
0
ファイル: any-proc-null.c プロジェクト: multics69/danbi
/* Initialize hardware counters and get hardware information, this
 * routine is called when the PAPI process is initialized
 * (IE PAPI_library_init)
 */
int
_papi_hwd_init_global( void )
{
	int retval;

	/* Fill in what we can of the papi_system_info.
	 * This doesn't need to be called but sometimes
	 * it is nice to seperate it out.
	 */
	retval = _internal_get_system_info(  );
	if ( retval )
		return ( retval );

	/* This is usually implemented in an OS specific file
	 * but can be implemented here if need be
	 */
	retval = get_memory_info( &_papi_system_info.mem_info );
	if ( retval )
		return ( retval );

	DBG( ( stderr, "Found %d %s %s CPUs at %f Mhz.\n",
		   _papi_system_info.hw_info.totalcpus,
		   _papi_system_info.hw_info.vendor_string,
		   _papi_system_info.hw_info.model_string,
		   _papi_system_info.hw_info.mhz ) );

	return ( PAPI_OK );
}
コード例 #2
0
double
vm_now()
{
    size_t	memory_usage=0;
    size_t	faults=0;

    get_memory_info(memory_usage, faults);

    return static_cast<double>(memory_usage);
}
コード例 #3
0
ファイル: Platform.cpp プロジェクト: 00liujj/trilinos
double
vm_now()
{
  size_t	memory_usage;
  size_t	faults;

  get_memory_info(memory_usage, faults);

  return (double) memory_usage;
}
コード例 #4
0
ファイル: memquery_emulate.c プロジェクト: djmott/dynamorio
/* helper for find_vm_areas_via_probe() and get_memory_info_from_os()
 * returns the passed-in pc if the probe was successful; else, returns
 * where the next probe should be (to skip DR memory).
 * if the probe was successful, returns in prot the results.
 */
static app_pc
probe_address(dcontext_t *dcontext, app_pc pc_in, byte *our_heap_start,
              byte *our_heap_end, OUT uint *prot)
{
    app_pc base;
    size_t size;
    app_pc pc = (app_pc)ALIGN_BACKWARD(pc_in, PAGE_SIZE);
    ASSERT(ALIGNED(pc, PAGE_SIZE));
    ASSERT(prot != NULL);
    *prot = MEMPROT_NONE;

    /* skip our own vmheap */
    if (pc >= our_heap_start && pc < our_heap_end)
        return our_heap_end;
    /* if no vmheap and we probe our own stack, the SIGSEGV handler will
     * report stack overflow as it checks that prior to handling TRY
     */
    if (is_stack_overflow(dcontext, pc))
        return pc + PAGE_SIZE;
#ifdef VMX86_SERVER
    /* Workaround for PR 380621 */
    if (is_vmkernel_addr_in_user_space(pc, &base)) {
        LOG(GLOBAL, LOG_VMAREAS, 4, "%s: skipping vmkernel region " PFX "-" PFX "\n",
            __func__, pc, base);
        return base;
    }
#endif
    /* Only for find_vm_areas_via_probe(), skip modules added by
     * dl_iterate_get_areas_cb.  Subsequent probes are about gettting
     * info from OS, so do the actual probe.  See PR 410907.
     */
    if (!dynamo_initialized && get_memory_info(pc, &base, &size, prot))
        return base + size;

    TRY_EXCEPT(dcontext, /* try */
               {
                   PROBE_READ_PC(pc);
                   *prot |= MEMPROT_READ;
               },
               /* except */
               {
                   /* nothing: just continue */
               });
コード例 #5
0
ファイル: kmalloc.c プロジェクト: Siriuscoder/nanokernel
void
k_print_memory_usage_info()
{
	memInfo_t memInfo;
	int i;
	get_memory_info(&memInfo);

	k_print("Memory usage:\n");
	k_print("Heap address: 0x%08x\n", memInfo.heapAddress);
	k_print("Memory cached: %u/%u bytes\n", memInfo.heapCached, memInfo.totalSize);
	k_print("Memory used: %u bytes\n", memInfo.memoryUsed);
	k_print("Allocated blocks:\n");
	for(i = 0; i < MEMORY_SLICES_MAX_COUNT; i++)
	{
		if(memPool.numAllocatedBlocks[i] != 0)
		k_print("|%dx(%u)|", memPool.numAllocatedBlocks[i], (1<<i));
	}

	k_print("\n");
}
コード例 #6
0
ファイル: unit-rct.c プロジェクト: DynamoRIO/drk
static void
test_self_direct(dcontext_t *dcontext)
{
    app_pc base_pc;
    size_t size;
    uint found;
    uint newfound;

#ifdef WINDOWS
    /* this will get both code and data FIXME: data2data reference
     * will be the majority
     */
    size = get_allocation_size((app_pc)test_self_direct, &base_pc);
#else
    /* platform agnostic but only looks for current CODE section, and
     * on windows is not quite what we want - since base_pc will just
     * be just page aligned
     */
    get_memory_info((app_pc)test_self_direct, &base_pc, &size, NULL);
#endif

    mutex_lock(&rct_module_lock);
    found = find_address_references(dcontext,
                                    base_pc, base_pc+size,
                                    base_pc, base_pc+size);
    mutex_unlock(&rct_module_lock);

    /* guesstimate */
    EXPECT_RELATION(found, >, 140);
#ifdef WINDOWS
    /* FIXME: note data2data have a huge part here */
    EXPECT_RELATION(found, <, 20000);
#else
    EXPECT_RELATION(found, <, 1000);
#endif
    EXPECT(is_address_taken(dcontext, (app_pc)f3), true);
    EXPECT(is_address_taken(dcontext, (app_pc)f2), true);
    EXPECT(is_address_taken(dcontext, (app_pc)f7), true); /* array reference only */


    /* it is pretty hard to produce the address of a static
     * (e.g. test_self) without making it address taken ;) so we just
     * add a number to known to be good one's */
    EXPECT(is_address_taken(dcontext, (app_pc)f3 + 1), false);
    EXPECT(is_address_taken(dcontext, (app_pc)f3 + 2), false);
    EXPECT(is_address_taken(dcontext, (app_pc)f2 + 1), false);
    EXPECT(is_address_taken(dcontext, (app_pc)f7 + 1), false);

    mutex_lock(&rct_module_lock);
    EXPECT(invalidate_ind_branch_target_range(dcontext, 0, (app_pc)-1),
           found);
    EXPECT_RELATION(invalidate_ind_branch_target_range(dcontext, 0, (app_pc)-1)
                    , == , 0);  /* nothing missed */
    mutex_unlock(&rct_module_lock);

    /* now try manually rct_analyze_module_at_violation */

    mutex_lock(&rct_module_lock);
    EXPECT(rct_analyze_module_at_violation(dcontext, (app_pc)test_self_direct), true);

    /* should be all found */
    /* FIXME: with the data2data in fact a few noisy entries show up
     * since second lookup in data may differ from original
     */
    newfound = find_address_references(dcontext,
                                       base_pc, base_pc+size,
                                       base_pc, base_pc+size);
    EXPECT_RELATION(newfound, <, 4);
    EXPECT_RELATION(invalidate_ind_branch_target_range(dcontext, 0, (app_pc)-1)
                    , > , found + newfound - 5); /* FIXME: data references uncomparable */

    EXPECT_RELATION(invalidate_ind_branch_target_range(dcontext, 0, (app_pc)-1)
                    , == , 0);  /* nothing missed */
    mutex_unlock(&rct_module_lock);
}
コード例 #7
0
ファイル: rtkgps.c プロジェクト: DuQiFa/rtkgps-1
/*****************************************************************************
 Perform rtkgps status command.
 *****************************************************************************/
void cmd_status(cmdlnopts_t *cmdopt) {
  int fd;
  unsigned int mu = 0;
  status_t status;
  logfile_t lgfl;
  log_bndry_t lgbd;
  memory_t mem;
  firmware_t frm;

  fd = coms_open(cmdopt);

  if (cmdopt->vflg)
    printf("Requesting logger status information\n");

  status_read(fd, &status, cmdopt);

  if (cmdopt->eflg) {
    if (cmdopt->vflg)
      printf("Requesting extended logger information\n");

    gpsmouse_disable(fd, status.gpsms, cmdopt);

    if (get_log_bndry(fd, &lgbd) < 0) {
      fprintf(stderr,"rtkgps: Failed to read log start/end details [%s]\n",
	      gcstrerror(rcerrno));
      gpsmouse_enable(fd, status.gpsms, cmdopt);
      coms_close(fd, cmdopt);
      exit(5);
    }
    if (get_memory_info(fd, &mem) < 0) {
      fprintf(stderr,"rtkgps: Failed to read logger memory details [%s]\n",
	      gcstrerror(rcerrno));
      gpsmouse_enable(fd, status.gpsms, cmdopt);
      coms_close(fd, cmdopt);
      exit(5);
    }
    if (get_firmware_info(fd, &frm) < 0) {
      fprintf(stderr,"rtkgps: Failed to read logger firmware details [%s]\n",
	      gcstrerror(rcerrno));
      gpsmouse_enable(fd, status.gpsms, cmdopt);
      coms_close(fd, cmdopt);
      exit(5);
    }
     /* Get info for first logfile */
    if (get_file_info(fd, 0, &lgfl) < 0) {
      fprintf(stderr,"rtkgps: Error reading information for file %d [%s]\n",
	      0, gcstrerror(rcerrno));
      gpsmouse_enable(fd, status.gpsms, cmdopt);
      coms_close(fd, cmdopt);
      exit(5);
    } 
    if (lgfl.memp == 0) { /* Memory has not wrapped around in overwrite mode */
      /* Get info for last logfile */
      if (get_file_info(fd, status.nfile-1, &lgfl) < 0) {
	fprintf(stderr,"rtkgps: Error reading information for file %d [%s]\n",
		status.nfile-1, gcstrerror(rcerrno));
	gpsmouse_enable(fd, status.gpsms, cmdopt);
	coms_close(fd, cmdopt);
	exit(5);
      }
      /* Memory used computed from last logfile pointer plus number of 
	 fixes in active logfile */
      mu = lgfl.memp + status.nfix*fix_size(status.fxtyp);
    } else { /* Memory has wrapped around in overwrite mode */
      int n;
      /* Need to compute memory used by adding up number of fixes in each 
	 log file */
      mu = lgfl.nfix*fix_size(lgfl.fxtyp);
      for (n = 1; n < status.nfile; n++) {
	if (get_file_info(fd, n, &lgfl) < 0) {
	  fprintf(stderr,"rtkgps: Error reading information for file "
                 "%d [%s]\n", n, gcstrerror(rcerrno));
	  gpsmouse_enable(fd, status.gpsms, cmdopt);
	  coms_close(fd, cmdopt);
	  exit(5);
	}
	mu += lgfl.nfix*fix_size(lgfl.fxtyp);
      }
    }

    gpsmouse_enable(fd, status.gpsms, cmdopt);
  }

  printf("GPS Fix:            %s\nGPS mouse mode:     %s\n"
	 "Record type:        %s\nMemory full:        %s\n"
	 "Sampling interval:  %hds\nNumber of files:    %hd\n"
	 "Fixes in last file: %d\n", gpsrx_string(status.gpsrx),
	 gpsms_string(status.gpsms), fxtyp_string(status.fxtyp),
	 mfowm_string(status.mfowm), status.sntvl, status.nfile,
	 status.nfix
	 );

  if (cmdopt->eflg) {
    printf("First log fix:      %.4s-%.2s-%.2s %.2s:%.2s:%.2s\n"
	   "Last log fix:       %.4s-%.2s-%.2s %.2s:%.2s:%.2s\n",
	   lgbd.first.date,lgbd.first.date+4,lgbd.first.date+6,
	   lgbd.first.time, lgbd.first.time+2, lgbd.first.time+4,
	   lgbd.last.date,lgbd.last.date+4,lgbd.last.date+6,
	   lgbd.last.time, lgbd.last.time+2, lgbd.last.time+4);
    printf("Device memory:      %7.2fkb\n"
	   "Memory used:        %7.2fkb (%.2f%%)\n",
	   mem.nbytes / 1024.0, mu / 1024.4, ((float)mu / mem.nbytes)*100.0);
    printf("Version:            %s\n"
	   "Firmware:           %s\n", frm.vrsnr, frm.frmwr);
  }

  coms_close(fd, cmdopt);
}
コード例 #8
0
ファイル: backend.c プロジェクト: Cynede/hexchat
char *
sysinfo_backend_get_memory (void)
{
	/* Memory information is always loaded dynamically since it includes the current amount of free memory */
	return get_memory_info ();
}
コード例 #9
0
void sngisdn_rcv_q931_ind(InMngmt *status)
{	
	if (status->t.usta.alarm.cause == 287) {
		get_memory_info();
		return;
	}

	switch (status->t.usta.alarm.event) {
		case LCM_EVENT_UP:
		case LCM_EVENT_DOWN:
		{
			ftdm_span_t *ftdmspan;
			sngisdn_span_data_t	*signal_data = g_sngisdn_data.dchans[status->t.usta.suId].spans[1];
			if (!signal_data) {
				ftdm_log(FTDM_LOG_INFO, "Received q931 status on unconfigured span (lnkNmb:%d)\n", status->t.usta.suId);
				return;
			}
			ftdmspan = signal_data->ftdm_span;
			
			if (status->t.usta.alarm.event == LCM_EVENT_UP) {
				uint32_t chan_no = status->t.usta.evntParm[2];
				ftdm_log(FTDM_LOG_INFO, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n",
						 status->t.usta.suId,
								DECODE_LCM_CATEGORY(status->t.usta.alarm.category),
								DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event,
								DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause);

				if (chan_no) {
					ftdm_channel_t *ftdmchan = ftdm_span_get_channel(ftdmspan, chan_no);
					if (ftdmchan) {
						sngisdn_set_chan_sig_status(ftdmchan, FTDM_SIG_STATE_UP);
						sngisdn_set_chan_avail_rate(ftdmchan, SNGISDN_AVAIL_UP);
					} else {
						ftdm_log(FTDM_LOG_CRIT, "stack alarm event on invalid channel :%d\n", chan_no);
					}
				} else {
					sngisdn_set_span_sig_status(ftdmspan, FTDM_SIG_STATE_UP);
					sngisdn_set_span_avail_rate(ftdmspan, SNGISDN_AVAIL_UP);
				}
			} else {
				ftdm_log(FTDM_LOG_WARNING, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n",
						 		status->t.usta.suId,
								DECODE_LCM_CATEGORY(status->t.usta.alarm.category),
								DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event,
								DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause);
				
				sngisdn_set_span_sig_status(ftdmspan, FTDM_SIG_STATE_DOWN);
				sngisdn_set_span_avail_rate(ftdmspan, SNGISDN_AVAIL_PWR_SAVING);
			}
		}
		break;
		default:
			ftdm_log(FTDM_LOG_WARNING, "[SNGISDN Q931] s%d: %s: %s(%d): %s(%d)\n",
					 						status->t.usta.suId,
	  										DECODE_LCM_CATEGORY(status->t.usta.alarm.category),
						  					DECODE_LCM_EVENT(status->t.usta.alarm.event), status->t.usta.alarm.event,
											DECODE_LCM_CAUSE(status->t.usta.alarm.cause), status->t.usta.alarm.cause);
	}
	
	ISDN_FUNC_TRACE_EXIT(__FUNCTION__);
	return;
}