예제 #1
0
ocrGuid_t mainEdt(u32 paramc, u64* paramv, u32 depc, ocrEdtDep_t depv[]) {
    // Current thread is '0' and goes on with user code.
    ocrGuid_t latchGuid;
    ocrEventCreate(&latchGuid, OCR_EVENT_LATCH_T, false);

    // Creates the EDT
    ocrGuid_t edtGuid;
    ocrGuid_t taskForEdtTemplateGuid;
    ocrEdtTemplateCreate(&taskForEdtTemplateGuid, taskForEdt, 0 /*paramc*/, 1 /*depc*/);
    ocrEdtCreate(&edtGuid, taskForEdtTemplateGuid, EDT_PARAM_DEF, /*paramv=*/NULL, EDT_PARAM_DEF, /*depv=*/NULL,
                    /*properties=*/0, NULL_GUID, /*outEvent=*/NULL);

    // Register a dependence between an event and an edt
    ocrAddDependence(latchGuid, edtGuid, 0, DB_MODE_RO);

    // decr first and then incr (reaching zero from negative)
    ocrEventSatisfySlot(latchGuid, NULL_GUID, OCR_EVENT_LATCH_DECR_SLOT);
    ocrEventSatisfySlot(latchGuid, NULL_GUID, OCR_EVENT_LATCH_INCR_SLOT);

    return NULL_GUID;
}
예제 #2
0
// The kernel to invoke
void domainKernel(ocrGuid_t userKernelDoneEvt, domainSetup_t * setupDbPtr, timestamp_t * timer) {
    // Setup: DB to use to satisfy the domain kernel's done event
    ocrGuid_t curAffGuid;
    ocrAffinityGetCurrent(&curAffGuid);
    ocrHint_t dbHint;
    ocrHintInit(&dbHint, OCR_HINT_DB_T);
    ocrSetHintValue(&dbHint, OCR_HINT_DB_AFFINITY, ocrAffinityToHintValue(curAffGuid));
    //TODO why is this not created by the caller as for domainSetup ?
    ocrGuid_t kernelDbGuid;
    domainKernel_t * kernelDbPtr;
    ocrDbCreate(&kernelDbGuid, (void**) &kernelDbPtr, sizeof(domainKernel_t), 0, &dbHint, NO_ALLOC);
    kernelDbPtr->self = kernelDbGuid;

    // Kernel's core

    // Create callback EDT to depend on stop timer event triggered by remote
    ocrHint_t edtHint;
    ocrHintInit(&edtHint, OCR_HINT_EDT_T);
    ocrSetHintValue(&edtHint, OCR_HINT_EDT_AFFINITY, ocrAffinityToHintValue(curAffGuid));
    ocrGuid_t stopTpl;
    ocrEdtTemplateCreate(&stopTpl, stopTimerEdt, 0, 2);
    ocrGuid_t stopEdt;
    ocrGuid_t stopEdtDone;
    ocrEdtCreate(&stopEdt, stopTpl,
                 0, NULL, 2, NULL, EDT_PROP_NONE, &edtHint, &stopEdtDone);
    // Stop timer will satisfy the user kernel done event
    ocrAddDependence(stopEdtDone, userKernelDoneEvt, 0, DB_MODE_NULL);
    ocrAddDependence(setupDbPtr->stopTimerEvt, stopEdt, 0, DB_MODE_NULL);
    ocrAddDependence(kernelDbPtr->self, stopEdt, 1, DB_MODE_EW);

    // Start timer
    ocrGuid_t remoteEvt = setupDbPtr->remoteLatchEvent;
    get_time(&kernelDbPtr->startTimer);
    u64 i;
    for(i=0; i<NB_SATISFY; i++) {
        ocrEventSatisfySlot(remoteEvt, NULL_GUID, OCR_EVENT_LATCH_DECR_SLOT);
    }
    // Note: Timer stops when the remote latch event got all the satisfy
    ocrDbRelease(kernelDbGuid);
}