示例#1
0
/*
 * Retourne l'adresse de base de la memoire partagee 
 * dans l'espace d'adressage local 
 */
unsigned long
smMemBase(void)
{
    if (smMemFreeList == NULL) {
	if (smMemAttach() == ERROR) {
	    return 0;
	}
    }
    return (unsigned long)(smMemFreeList - 1);
}
示例#2
0
/**
 ** Allocation d'une zone dans le segment de memoire partagee
 **/
void *
smMemMalloc(size_t nBytes)
{
    void *result;
    
    if (smMemFreeList == NULL) {
	if (smMemAttach() == ERROR) {
	    return NULL;
	}
    }
    result = internal_malloc(nBytes);

    LOGDBG(("comLib:smMemLib: alloc %u -> 0x%lx\n", 
	    nBytes, (unsigned long)result));
    return result;
}
示例#3
0
STATUS
h2initGlob(int ticksPerSec)
{

#ifdef __XENO__
    /* Lock process in RAM */
    mlockall(MCL_CURRENT | MCL_FUTURE);
#endif
    /* init error msgs for sub-libraries without specific init functions */
    h2evnRecordH2ErrMsgs();
    h2semRecordH2ErrMsgs();
    smObjRecordH2ErrMsgs();

    /* OS level initialization */
    if (osInit(ticksPerSec) == ERROR) {
	return ERROR;
    }
    setvbuf(stdout, (char *)NULL, _IOLBF, 0);
    setvbuf(stderr, (char *)NULL, _IOLBF, 0);

    /* attach to h2 devices */
    if (h2devAttach() == ERROR) {
	printf("Error: could not find h2 devices\n"
		"Did you execute `h2 init' ?\n");
	return ERROR;
    }
    /* attach to shared memory */
    if (smMemAttach() == ERROR) {
	printf("Error: could not attach shared memory\n");
	return ERROR;
    }

    /* Start h2 timers if a clock is available */
    if (ticksPerSec != 0) {
	if (h2timerInit() == ERROR) {
	    return ERROR;
	}
    }
    h2timeInit();
    printf("%s execution environment version %s\n"
	"Copyright (c) 1999-2011 CNRS-LAAS\n",
	PACKAGE_NAME, PACKAGE_VERSION);

    return OK;
}
示例#4
0
/**
 ** Affichage de statistiques sur l'allocateur 
 **/
void
smMemShow(BOOL option)
{
    unsigned long bytes = 0, blocks = 0, maxb = 0;
    SM_MALLOC_CHUNK *c;

    if (smMemFreeList == NULL) {
	if (smMemAttach() == ERROR) {
	    return;
	}
    }

    if (option) {
	logMsg("\nFREE LIST:\n");
	logMsg(" num   addr        size\n");
	logMsg(" --- ---------- ----------\n");
    }
    /* Parcours de la liste des blocs libres */
    for (c = smMemFreeList; c != NULL; c = smObjGlobalToLocal(c->next)) {
	assert(c->signature == SIGNATURE);
	blocks++;
	bytes += c->length;
	if (c->length > maxb) {
	    maxb = c->length;
	}
	if (option) {
	    logMsg("%4ld 0x%08lx %10lu\n", blocks, (unsigned long)c, 
		   (unsigned long)c->length);
	}
    }
    if (option) {
	logMsg("\nSUMMARY:\n");
    }
    logMsg(" status    bytes    blocks   ave block  max block\n");
    logMsg(" ------ ---------- -------- ---------- ----------\n");
    logMsg("current\n");
    logMsg("   free %10lu %9lu %10lu %10lu\n", bytes, blocks, 
	   bytes/blocks, maxb);
#ifdef notyet
    logMsg("  alloc %10d %9d %10d %10s\n", allocBytes, allocBlocks, 
	   allocBytes/allocBlocks, "-");
#endif
}