Пример #1
0
/*
 * Global initialization of the reclaim data structures, mainly
 * the max_files variable. This HAS to be called by some task before 
 * the first task that utilizes this exit's, preferrably before any
 * task makes the first use of this library.
 */
STATUS reclaim_init(void)
{
    int *mp;
    SYM_TYPE type;
    struct task_data *tdp;
    int i;

    if (!hook_added) {
	/* race condition */
	++hook_added;
	/* Try to find the maxFiles value */
	if (symFindByNameAndType(sysSymTbl, MAX_FILES_SYM_NAME, (char **)&mp, 
				 &type,
				 N_EXT | N_BSS, N_EXT | N_BSS) == OK ||
	    symFindByNameAndType(sysSymTbl, MAX_FILES_SYM_NAME, (char **)&mp, 
				 &type,
				 N_EXT | N_DATA, N_EXT | N_DATA) == OK) {

#ifdef DEBUG
	    fdprintf(2, "Found maxFiles=%d\n", *mp);
#endif
	    if (*mp <= FD_SETSIZE)
		max_files = *mp;
	    else
		max_files = FD_SETSIZE;
	}
	if (task_data != NULL && task_data->max_files != max_files) {
	    /* fix our own iff we have one */
	    if ((tdp = (struct task_data *)
		 realloc(task_data, sizeof(struct task_data) +
			 max_files*sizeof(FILE *))) != NULL) {
		task_data = tdp;
		for (i = task_data->max_files; i < max_files; i++)
		    task_data->open_fps[i] = NULL;
		task_data->max_files = max_files;
	    }
	}
	/* Make sure taskVariables are deleted AFTER our hook is run. */
	taskVarInit();
	if(taskDeleteHookAdd((FUNCPTR)save_reclaim) != OK) {
	    fprintf(stderr, 
		    "Panic: taskDeleteHook cannot be added for reclaim.\n");
	    return ERROR;
	}
	return OK;
    } else 
	return ERROR;
}
Пример #2
0
void usrKernelExtraInit (void)
    {
    hashLibInit ();                     /* hash library */
    symLibInit ();                      /* Set of routines to manipulate symbols and symbol tables */
    taskVarInit ();                     /* allow global variables to be made private to a task */
    envLibInit (ENV_VAR_USE_HOOKS);     /* unix compatable environment variables */
    sigInit (POSIX_SIGNAL_MODE);        /* signals */
    sigeventLibInit ();                 /* Kernel signal event support.  Required for SIGEV_THREAD support in RTP. */
    mqPxLibInit (MQ_HASH_SIZE);         /* POSIX message queues */
    pthreadLibInit ();	                 /* Support for POSIX threads in the kernel */
    semPxLibInit ();                    /* POSIX semaphores */
    sigqueueInit (NUM_SIGNAL_QUEUES);   /* queued signals */
    clockLibInit ();                    /* POSIX clocks */
    timerLibInit ();                    /* POSIX timers */
    timerOpenInit ();                   /* open/close/unlink timer modules */
    intVecTableWriteProtect ();         /* write-protect vector table */
    syscallHookLibInit ();              /* Add hook routines to be called on system calls. */
    }