void
CVMmemEnableWriteNotify(CVMMemHandle *h, CVMUint32* start, CVMUint32* end)
{
    CVMMemPrivateData *r = h2d(h);
    CVMAddr alignedStart = ALIGNED(start);
    CVMAddr alignedEnd = ALIGNEDNEXT(end);

    if (wnlLock == NULL) {
        wnlLock = malloc(sizeof(CVMMutex));
        CVMmutexInit(wnlLock);
    }
    CVMmutexLock(wnlLock);

    /* Add to the write notify list. */
    if (writeNotifyList == NULL) {
        r->nextWriteNotify = NULL;
    } else {
        r->nextWriteNotify = writeNotifyList;
    }
    writeNotifyList = r;

    CVMmutexUnlock(wnlLock);

    /* Protect the aligned region that contains the start and end to
     * enable write notify.
     */
    CVMmprotect((void*)alignedStart, (void*)alignedEnd, CVM_TRUE);
}
void jsr120_sms_pool_init() {
    /**
     * Impl note.
     * Theoretically, mutex could be created twice. 
     * But it is not a big problem if one mutex will be lost.
     */
    if (!is_mutex_inited) {
        is_mutex_inited = 1;
        CVMmutexInit(&_mutex);
    }
}
Example #3
0
CVMBool
CVMreentrantMutexInit(CVMReentrantMutex * rm, CVMExecEnv *owner,
    CVMUint32 count)
{
    rm->count = count;
    rm->owner = owner;
    if (CVMmutexInit(&rm->mutex)) {
	if (count > 0) {
	    CVMBool success = CVMmutexTryLock(&rm->mutex);
	    CVMassert(success); (void) success;
	}
	return CVM_TRUE;
    }
    return CVM_FALSE;
}