STATUS sigLibInit( void ) { STATUS status; if (sigLibInstalled == TRUE) { status = OK; } else { /* Add task delete hook for signals */ if (taskDeleteHookAdd((FUNCPTR) sigDeleteHook) != OK) { status = ERROR; } else { /* Setup exception kill hook */ excSigKillHookSet(sigExcKill); /* Mark as installed */ sigLibInstalled = TRUE; status = OK; } } return status; }
/* * 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; }
int main() { int _p[4] = {200, 100, 100, 100}; char * word; DynArray * da = (DynArray *)malloc(sizeof(DynArray)); DynArray * clone1 = (DynArray *)malloc(sizeof(DynArray)); DynArray * clone2 = (DynArray *)malloc(sizeof(DynArray)); DynArray * clone3 = (DynArray *)malloc(sizeof(DynArray)); initDynArray(da, bulk_alloc); for (word = strtok(srcString, " "); word ; word = strtok(NULL, " ")) { addDynArray(da, word); } cloneDynArray(clone1, da); cloneDynArray(clone2, da); cloneDynArray(clone3, da); sysTimestampEnable(); TASK_ID qsTid; TASK_ID bsTid; TASK_ID ssTid; TASK_ID supTid; taskCreateHookAdd(taskCreateCallback); taskDeleteHookAdd(taskDeleteCallback); taskSwitchHookAdd(taskSwitchCallback); supTid = taskSpawn(sup, _p[0], VX_NO_STACK_FILL, 2048*1000, supEntry, \ da, clone1, clone2, clone3, compare,0,0,0,0,0); qsTid = taskSpawn(mqs, _p[1], VX_NO_STACK_FILL, 2048*1000, myqsortEntry, \ clone1, compare, supTid, 0,0,0,0,0,0,0); bsTid = taskSpawn(mbs, _p[2], VX_NO_STACK_FILL, 2048*1000, mybsortEntry, \ clone2, compare, supTid, 0,0,0,0,0,0,0); ssTid = taskSpawn(mns, _p[3], VX_NO_STACK_FILL, 2048*1000, mynsortEntry, \ clone3, compare, supTid, 0,0,0,0,0,0,0); return 0; }
void ini_processes_service(Protocol * proto) { #if defined(_WRS_KERNEL) prs_list_lock = semMCreate(SEM_Q_PRIORITY); if (prs_list_lock == NULL) check_error(errno); if (taskCreateHookAdd((FUNCPTR)task_create_hook) != OK) check_error(errno); if (taskDeleteHookAdd((FUNCPTR)task_delete_hook) != OK) check_error(errno); #endif list_init(&prs_list); add_waitpid_listener(waitpid_listener, NULL); add_command_handler(proto, PROCESSES, "getContext", command_get_context); add_command_handler(proto, PROCESSES, "getChildren", command_get_children); add_command_handler(proto, PROCESSES, "attach", command_attach); add_command_handler(proto, PROCESSES, "detach", command_detach); add_command_handler(proto, PROCESSES, "terminate", command_terminate); add_command_handler(proto, PROCESSES, "signal", command_signal); add_command_handler(proto, PROCESSES, "getSignalList", command_get_signal_list); add_command_handler(proto, PROCESSES, "getSignalMask", command_get_signal_mask); add_command_handler(proto, PROCESSES, "setSignalMask", command_set_signal_mask); add_command_handler(proto, PROCESSES, "getEnvironment", command_get_environment); add_command_handler(proto, PROCESSES, "start", command_start); }
static void init(void) { main_thread = taskIdCurrent; taskDeleteHookAdd((FUNCPTR)task_delete_hook); }