/* * ======== CERuntime_init ======== */ Void CERuntime_init(Void) { GT_init(); /* allow user to over-ride via CE_TRACE. */ GT_set(Global_getenv("CE_TRACE")); Global_init(); Sem_init(); SemMP_init(); Memory_init(); Queue_init(); Comm_init(); Thread_init(); Processor_init(); LockMP_init(); /* Must be called before DMAN3_init() */ Algorithm_init(); XdmUtils_init(); Lock_init(); Engine_init(); Server_init(); }
LockFileLock* LFLock_init(LockFileLock *self, Folder *folder, const CharBuf *name, const CharBuf *host, int32_t timeout, int32_t interval) { int pid = PID_getpid(); Lock_init((Lock*)self, folder, name, host, timeout, interval); self->link_path = CB_newf("%o.%o.%i64", self->lock_path, host, pid); return self; }
LockFileLock* LFLock_init(LockFileLock *self, Folder *folder, String *name, String *host, int32_t timeout, int32_t interval) { int pid = PID_getpid(); Lock_init((Lock*)self, folder, name, host, timeout, interval); LockFileLockIVARS *const ivars = LFLock_IVARS(self); ivars->link_path = Str_newf("%o.%o.%i64", ivars->lock_path, host, pid); return self; }
/* --------------------------------------------------------------- simple initializer lockflag = 0 --> mutex lock is not allocated or initialized lockflag = 1 --> mutex lock is allocated and it can synchronize omly threads in this process. lockflag = 2 --> mutex lock is allocated and it can synchronize omly threads in this and other processes. mode = 0 --> free object and storage on release mode = 1 --> recycle object and storage on release created -- 98may02, cca --------------------------------------------------------------- */ void SubMtxManager_init ( SubMtxManager *manager, int lockflag, int mode ) { /* --------------- check the input --------------- */ if ( manager == NULL || lockflag < 0 || lockflag > 2 || mode < 0 || mode > 1 ) { fprintf(stderr, "\n fatal error in SubMtxManager_init(%p,%d,%d)" "\n bad input\n", manager, lockflag, mode) ; exit(-1) ; } /* -------------------------------------------------- clear any previous data and set the default fields -------------------------------------------------- */ SubMtxManager_clearData(manager) ; if ( lockflag != 0 ) { /* --------------------------- initialize the mutex object --------------------------- */ manager->lock = Lock_new() ; Lock_init(manager->lock, lockflag) ; } /* ------------ set the mode ------------ */ manager->mode = mode ; return ; }
/* * ======== CERuntime_init ======== */ Void CERuntime_init(Void) { extern Void IPC_generatedInit(); GT_init(); /* if CE_DEBUG is set, turn on tracing and DSP auto trace collection */ if (Global_getenv("CE_DEBUG") != NULL) { extern Bool Engine_alwaysCollectDspTrace; extern String Engine_ceDebugDspTraceMask; Engine_alwaysCollectDspTrace = TRUE; if (Global_getenv("CE_DEBUG")[0] == '1') { GT_set("*+67,CE-3,GT_time=0,GT_prefix=1235"); Engine_ceDebugDspTraceMask = "*+67,GT_prefix=1235,GT_time=3"; } else if (Global_getenv("CE_DEBUG")[0] == '2') { GT_set( "*+01234567,CE-3,ti.sdo.ce.osal.SemMP=67,OG=467,OM=4567,OC=67,GT_time=0,GT_prefix=1235"); Engine_ceDebugDspTraceMask = "*+01234567,CR=67,ti.sdo.fc.dman3-2,ti.sdo.fc.dskt2-2,GT_prefix=1235,GT_time=3"; } else { GT_set("*+01234567,CE-3,GT_time=0,GT_prefix=12345"); Engine_ceDebugDspTraceMask = "*+01234567,GT_prefix=12345,GT_time=3"; } } if (Global_getenv("CE_CHECK") != NULL) { extern Bool VISA_checked; /* * Currently just change _this_ processor's value... perhaps we should * enable remote processors as well? */ if (Global_getenv("CE_CHECK")[0] == '1') { VISA_checked = TRUE; /* turn on all GT_7CLASS trace (errors) */ GT_set("*+7"); } else if (Global_getenv("CE_CHECK")[0] == '0') { VISA_checked = FALSE; } else { /* leave it whatever it was... maybe we should drop a warning? */ } } /* allow user to over-ride via CE_TRACE. */ GT_set(Global_getenv("CE_TRACE")); IPC_generatedInit(); Global_init(); Sem_init(); SemMP_init(); Memory_init(); Queue_init(); Comm_init(); Thread_init(); Processor_init(); LockMP_init(); /* Must be called before DMAN3_init() */ Algorithm_init(); XdmUtils_init(); Lock_init(); Engine_init(); Server_init(); }
/* ------------------------------------------------------------------ purpose -- basic initializer nlist -- number of lists to be held by this object counts -- vector that contains number of items expected for each list. counts == NULL --> unknown number of items expected counts != NULL --> known number of items expected lockflag -- flag to specify lock status lockflag = 0 --> mutex lock is not allocated or initialized lockflag = 1 --> mutex lock is allocated and it can synchronize only threads in this process. lockflag = 2 --> mutex lock is allocated and it can synchronize only threads in this and other processes. flags -- vector to specify whether to lock individual lists flags == NULL --> none or all lists must be locked, use lockflag to determine flags[ilist] = 'N' --> no need to lock list ilist flags[ilist] = 'Y' --> must lock list ilist created -- 98may02, cca ------------------------------------------------------------------ */ void SubMtxList_init ( SubMtxList *list, int nlist, int counts[], int lockflag, char flags[] ) { int ilist ; /* --------------- check the input --------------- */ if ( list == NULL || nlist <= 0 || lockflag < 0 || lockflag > 2 ) { fprintf(stderr, "\n fatal error in SubMtxList_init(%p,%d,%p,%d,%p)" "\n bad input\n", list, nlist, counts, lockflag, flags) ; exit(-1) ; } /* -------------- clear all data -------------- */ SubMtxList_clearData(list) ; /* ------------------------------------------------------- set the number of lists and allocate the heads[] vector ------------------------------------------------------- */ list->nlist = nlist ; ALLOCATE(list->heads, struct _SubMtx *, nlist) ; for ( ilist = 0 ; ilist < nlist ; ilist++ ) { list->heads[ilist] = NULL ; } if ( counts != NULL ) { /* ------------------------------------- allocate and fill the counts[] vector ------------------------------------- */ list->counts = IVinit(nlist, 0) ; IVcopy(nlist, list->counts, counts) ; } if ( lockflag > 0 ) { /* ----------------- allocate the lock ----------------- */ list->lock = Lock_new() ; Lock_init(list->lock, lockflag) ; } if ( flags != NULL ) { /* ------------------------------------ allocate and fill the flags[] vector ------------------------------------ */ list->flags = CVinit(nlist, 'N') ; CVcopy(nlist, list->flags, flags) ; } return ; }