Beispiel #1
0
void
v_participantInit(
    v_participant p,
    const c_char *name,
    v_participantQos qos,
    v_statistics s,
    c_bool enable)
{
    v_kernel kernel;
    c_base base;
    v_message builtinMsg;
    c_type writerProxyType;

    assert(C_TYPECHECK(p,v_participant));
    assert(C_TYPECHECK(qos, v_participantQos));

    kernel = v_objectKernel(p);
    base = c_getBase(p);
    v_observerInit(v_observer(p),name,s,enable);

    p->entities = c_setNew(c_resolve(base,"kernelModule::v_entity"));
    p->qos = c_keep(qos);
    /* Currently default LIVELINESS policy is used: kind=AUTOMATIC,
     * duration=INFINITE This setting implies no lease registration.
    */
    p->lease = NULL;
    p->leaseManager = v_leaseManagerNew(kernel);
    p->resendQuit = FALSE;
    c_mutexInit(&p->resendMutex, SHARED_MUTEX);
    c_condInit(&p->resendCond, &p->resendMutex, SHARED_COND);
    writerProxyType = v_kernelType(kernel,K_PROXY);
    p->resendWriters = c_tableNew(writerProxyType, "source.index,source.serial");

    p->builtinSubscriber = NULL;
    if (!v_observableAddObserver(v_observable(kernel),v_observer(p), NULL)) {
        if (name != NULL) {
            OS_REPORT_1(OS_WARNING,"Kernel Participant",0,
                        "%s: Cannot observe Kernel events",name);
        } else {
            OS_REPORT(OS_WARNING,"Kernel Participant",0,
                      "Cannot observe Kernel events");
        }
    }

    c_mutexInit(&p->newGroupListMutex,SHARED_MUTEX);
    p->newGroupList = c_listNew(c_resolve(base, "kernelModule::v_group"));

    v_observerSetEventMask(v_observer(p), V_EVENT_NEW_GROUP);

    c_lockInit(&p->lock,SHARED_LOCK);
    c_mutexInit(&p->builtinLock,SHARED_MUTEX);

    /* Here the Builtin Topic of the participant is published.
     * This call mabe a noop in case builtin is disabled on kernel level.
     */
    builtinMsg = v_builtinCreateParticipantInfo(kernel->builtin,p);
    v_writeBuiltinTopic(kernel, V_PARTICIPANTINFO_ID, builtinMsg);
    c_free(builtinMsg);
}
Beispiel #2
0
v_listener
v_listenerNew(
    v_participant p,
    c_bool combine)
{
    v_listener _this;
    v_kernel kernel;

    assert(C_TYPECHECK(p,v_participant));

    kernel = v_objectKernel(p);
    _this = v_listener(v_objectNew(kernel,K_LISTENER));
    if (_this != NULL) {
        v_publicInit(v_public(_this));
        (void)c_mutexInit(c_getBase(_this), &_this->mutex);
        c_condInit(c_getBase(_this), &_this->cv, &_this->mutex);
        _this->participant = p;
        _this->eventList = NULL;
        _this->lastEvent = NULL;
        v_participantAdd(p, v_object(_this));
        _this->terminate = FALSE;
        _this->waitCount = 0;
        _this->combine = combine;
    }

    return _this;
}
static void
v_networkReaderEntryInit(
    v_networkReaderEntry entry,
    v_networkReader reader,
    v_group group,
    v_networkId networkId,
    c_ulong channelsToConnect,
    v_networkPartitionId networkPartitionId,
    c_bool isRouting)
{
    v_networkReaderEntry found;

    v_entryInit(v_entry(entry),v_reader(reader));

    entry->group = c_keep(group);
    entry->networkId = networkId;
    entry->channelCountdown = channelsToConnect;
    c_mutexInit(&entry->channelCountdownMutex, SHARED_MUTEX);
    entry->networkPartitionId = networkPartitionId;
    entry->hashValue = v_networkReaderEntryCalculateHashValue(entry);
    entry->isRouting = isRouting;

    found = v_networkReaderEntry(v_readerAddEntry(v_reader(reader), v_entry(entry)));
    assert(found == entry);
    c_free(found);
}
Beispiel #4
0
/**************************************************************
 * constructor/destructor
 **************************************************************/
void
v_readerInit(
    v_reader r,
    const c_char *name,
    v_subscriber s,
    v_readerQos qos,
    v_statistics rs,
    c_bool enable)
{
    v_kernel kernel;

    assert(r != NULL);
    assert(s != NULL);
    assert(C_TYPECHECK(r,v_reader));
    assert(C_TYPECHECK(s,v_subscriber));
    assert(C_TYPECHECK(qos, v_readerQos));
    /* We demand the qos to be allocated in the kernel, by v_readerQosNew().
     * This way we are sure that the qos is consistent!
     */

    kernel = v_objectKernel(r);
    v_collectionInit(v_collection(r),name,rs,enable);

    r->subscriber = s;
    r->qos = c_keep(qos);
    r->subQos = c_keep(s->qos); /* reference is readonly */
    r->entrySet.entries = c_setNew(v_kernelType(kernel,K_ENTRY));
    c_mutexInit(&r->entrySet.mutex, SHARED_MUTEX);

    r->historicalDataRequest  = NULL;
    r->historicalDataComplete = FALSE;
    c_condInit(&r->historicalDataCondition, &(v_observer(r)->mutex), SHARED_COND);

}
Beispiel #5
0
static nw_messageBox
nw_messageBoxNew(
    void)
{
    nw_messageBox result;

    result = (nw_messageBox)os_malloc(sizeof(*result));
    if (result != NULL) {
        c_mutexInit(&result->mutex, PRIVATE_MUTEX);
        result->firstMessage = NULL;
        result->lastMessage = NULL;
    }
    return result;
}
Beispiel #6
0
void
v_leaseManagerInit(
    v_leaseManager _this)
{
    v_kernel k;

    assert(C_TYPECHECK(_this, v_leaseManager));

    k = v_objectKernel(_this);
    c_mutexInit(&_this->mutex, SHARED_MUTEX);
    c_condInit(&_this->cond, &_this->mutex, SHARED_COND);
    _this->quit = FALSE;
    _this->firstLeaseToExpire = NULL;
    _this->leases = c_setNew(v_kernelType(k, K_LEASEACTION));
}
Beispiel #7
0
void
v_leaseInit(
    v_lease _this,
    v_kernel k,
    v_duration leaseDuration)
{
    if (_this != NULL)
    {
        assert(C_TYPECHECK(_this, v_lease));

        c_mutexInit(&_this->mutex,SHARED_MUTEX);
        _this->expiryTime = c_timeAdd(v_timeGet(), leaseDuration);
        _this->duration = leaseDuration;
        _this->observers = c_setNew(v_kernelType(k, K_LEASEMANAGER));
    }
}
Beispiel #8
0
void
v_observerInit(
    v_observer o,
    const c_char *name,
    v_statistics s,
    c_bool enable)
{
    assert(o != NULL);
    assert(C_TYPECHECK(o,v_observer));

    c_mutexInit(&o->mutex,SHARED_MUTEX);  /* mutex to protect attributes */
    c_condInit(&o->cv, &o->mutex, SHARED_COND); /* condition variable */
    o->waitCount = 0;                     /* number of waiting threads */
    o->eventMask = 0;                     /* specifies, interested events */
    o->eventFlags = 0;                    /* ocurred events */
    o->eventData = NULL;                  /* general post box for derived classes */
    v_observableInit(v_observable(o),name, s, enable);
}
Beispiel #9
0
/**************************************************************
 * Protected functions
 **************************************************************/
v_partitionAdmin
v_partitionAdminNew(
    v_kernel kernel)
{
    v_partitionAdmin da;

    assert(C_TYPECHECK(kernel,v_kernel));

    da = v_partitionAdmin(v_objectNew(kernel, K_DOMAINADMIN));
    if (da != NULL) {
        da->partitions         = c_tableNew(v_kernelType(kernel, K_DOMAIN),"name");
        da->partitionInterests = c_tableNew(v_kernelType(kernel, K_DOMAININTEREST), "expression");
        c_mutexInit(&da->mutex,SHARED_MUTEX);

        if ((da->partitions == NULL) || (da->partitionInterests == NULL)) {
            c_free(da);
            da = NULL;
        }
    }
    return da;
}
Beispiel #10
0
v_deliveryWaitList
v_deliveryWaitListNew(
    v_deliveryGuard _this,
    v_message msg)
{
    v_deliveryWaitList waitlist = NULL;
    v_deliveryWaitList found;
    c_type type;

    assert(C_TYPECHECK(_this,v_deliveryGuard));

    if (_this) {
        /* lookup or create a writer specific admin.
         */
        type = c_subType(_this->waitlists);
        waitlist = c_new(type);
        c_free(type);
        if (waitlist) {
            waitlist->sequenceNumber = msg->sequenceNumber;
            waitlist->readerGID = copyReaderGIDsFromPublications(_this);
            waitlist->guard = _this;
            c_mutexInit(&waitlist->mutex, SHARED_MUTEX);
            c_condInit(&waitlist->cv, &waitlist->mutex, SHARED_COND);
        }
        found = c_tableInsert(_this->waitlists, waitlist);
        if (found != waitlist) {
            /* This should not happen! */
            OS_REPORT(OS_ERROR,
                      "v_deliveryWaitListNew",0,
                      "detected inconsistent waitlist admin.");
            c_free(waitlist);
            waitlist = NULL;
        }
    } else {
        OS_REPORT(OS_ERROR,
                  "v_deliveryWaitListNew",0,
                  "Operation failed: illegal parameter (_this == NULL).");
    }
    return waitlist;
}
Beispiel #11
0
v_handleServer
v_handleServerNew (
    c_base base)
{
    v_handleServer server;
    c_type type;

    assert(base != NULL);

    type = c_resolve(base,"kernelModule::v_handleServer");
    server = c_new(type);
    c_free(type);
    if (server) {
        type = c_resolve(base,"kernelModule::v_handleInfoList");
        server->handleInfos = c_arrayNew(type,NROFCOL);
#ifdef DDS_1958_CANNOT_CALL_REGISTERED_FUNC_PTR_FROM_DIFF_PROCESS
        server->lowMemWarningCount = 0;
#endif
        c_free(type);
        if (server->handleInfos) {
            server->firstFree = NOHANDLE;
            server->lastIndex = NOHANDLE;
            server->suspended = FALSE;
            c_mutexInit(&server->mutex,SHARED_MUTEX);
            c_baseOnOutOfMemory(base, disableHandleServer,server);
            c_baseOnLowOnMemory(base, issueLowMemoryWarning, server);
        } else {
            c_free(server);
            server = NULL;
            OS_REPORT(OS_ERROR,"v_handleServerNew",0,
                      "Failed to allocate handle info records");
        }
    } else {
        OS_REPORT(OS_ERROR,"v_handleServerNew",0,
                  "Failed to allocate handle server");
    }
    return server;
}
Beispiel #12
0
v_handle
v_handleServerRegister(
    v_handleServer server,
    c_object o)
{
    c_type type;
    v_handle handle;
    v_handleInfo *info, *block;
    c_long row, idx;

    assert(C_TYPECHECK(server,v_handleServer));
    assert(o != NULL);

    if(server->suspended == TRUE) {
        /* For now the suspended state means that an unrecoverable error has
         * occured. This implies that from now on any access to the kernel is
         * unsafe and the result is undefined.
         * So because of this and that registering new object are useless
         * skip this action and return NULL.
         */
        return V_HANDLE_NIL;
    }

    c_mutexLock(&server->mutex);

    if (server->firstFree != NOHANDLE) {
        idx = server->firstFree;
        block = ((v_handleInfo**)server->handleInfos)[COL(idx)];
        info = &block[ROW(idx)];
        server->firstFree = info->nextFree;
    } else {
        if (server->lastIndex == ((NROFCOL*NROFROW)-1)) {
            OS_REPORT(OS_ERROR,"Kernel v_handle",0,"Out of handle space");
            c_mutexUnlock(&server->mutex);

            exit(-1);
        }
        if (server->lastIndex == NOHANDLE) {
            server->lastIndex = 0;
        } else {
            server->lastIndex++;
        }
        idx = server->lastIndex;
        row = ROW(idx);
        if (row == 0) {
            type = c_resolve(c_getBase(o),"kernelModule::v_handleInfo");
            server->handleInfos[COL(idx)] = c_arrayNew(type,NROFROW);
        }
        block = ((v_handleInfo**)server->handleInfos)[COL(idx)];
        if (block) {
            info = &block[row];
            info->serial = SERIALSTART;
            c_mutexInit(&info->mutex,SHARED_MUTEX);
        } else {
            OS_REPORT(OS_ERROR,"v_handleServerRegister",0,
                      "Failed to allocate a new list of handles");
        }
    }

    if (info) {
        info->object   = c_keep(o);
        info->nextFree = NOHANDLE;
        info->count    = 0;
        info->freed    = FALSE;

        handle.server  = (c_address)server;
        handle.serial  = info->serial;
        handle.index   = idx;
    } else {
        handle  = V_HANDLE_NIL;
    }

    c_mutexUnlock(&server->mutex);

    return handle;
}
Beispiel #13
0
v_networkQueue
v_networkQueueNew(
    c_base base,
    c_ulong queueSize,
    c_ulong priority,
    c_bool reliable,
    c_bool P2P,
    c_time resolution,
    v_networkQueueStatistics statistics)
{
    v_networkQueue result = NULL;
    c_type type;
    c_equality equality;
    c_bool hasChanged;
    c_time now;

    type = c_resolve(base, "kernelModule::v_networkQueue");
    assert(type);
    result = v_networkQueue(c_new(type));
    c_free(type);

    if (result) {
        /* Queue properties */
        result->maxMsgCount = queueSize;
        result->currentMsgCount = 0;
        /* Cached type */
        result->statusMarkerType = c_resolve(base, "kernelModule::v_networkStatusMarker");
        assert(result->statusMarkerType != NULL);
        result->sampleType = c_resolve(base, "kernelModule::v_networkQueueSample");
        assert(result->sampleType != NULL);
        /* Linked list of in-use marker items */
        result->firstStatusMarker = NULL;
        result->lastStatusMarker = NULL;
        /* Linked list of free marker and message items */
        result->freeStatusMarkers = NULL;
        result->freeSamples = NULL;
        /* Init cv stuff */
        c_mutexInit(&result->mutex, SHARED_MUTEX);
        c_condInit(&result->cv, &result->mutex, SHARED_COND);
        /* Currently no differentiation wrt qos */
        result->priority = priority;
        result->reliable = reliable;
        result->P2P = P2P;

        result->statistics = statistics;

        equality = c_timeCompare(C_TIME_ZERO, resolution);
        if (equality == C_EQ) {
            result->periodic = FALSE;
            result->resolution = C_TIME_INFINITE;
            result->msecsResolution = 0xFFFFFFFF;
            result->phaseMilliSeconds = 0;
            result->nextWakeup = C_TIME_INFINITE;
        } else {
            assert(equality == C_LT);
            result->periodic = TRUE;
            result->resolution = resolution;
            TIME_TO_MSEC(resolution, result->msecsResolution);        
            /* A semi-random phase to avoid wake-ups at the same time */
            now = v_timeGet();
            result->phaseMilliSeconds = ((c_ulong)(now.nanoseconds/1000000 * 1.618)) %
                result->msecsResolution;
            v_networkQueueUpdateNextWakeup(result, &hasChanged);
            assert(hasChanged);
        }
        result->threadWaiting = FALSE;
    } else {
        OS_REPORT(OS_ERROR,
                  "v_networkQueueNew",0,
                  "Failed to allocate network queue.");
    }
    return result;
}    
Beispiel #14
0
v_subscriber
v_subscriberNew(
    v_participant p,
    const c_char *name,
    v_subscriberQos qos,
    c_bool enable)
{
    v_kernel kernel;
    v_subscriber s;
    v_subscriberQos q;
    v_entity found;
    v_accessMode access;

    kernel = v_objectKernel(p);
    /* ES, dds1576: If a partition policy was provided then we need to verify
     * if the partition policy does not contain any partition expressions for
     * which read access is not allowed.
     * If read access is not allowed for one of the partitions listed in the
     * partition policy of the qos, then the subscriber will not be created at
     * all.
     */
    if(qos && qos->partition)
    {
        access = v_kernelPartitionAccessMode(kernel, qos->partition);
    } else
    {
        access = V_ACCESS_MODE_READ_WRITE;/* default */
    }
    if(access == V_ACCESS_MODE_READ_WRITE || access == V_ACCESS_MODE_READ)
    {
        q = v_subscriberQosNew(kernel,qos);
        if (q != NULL) {
            s = v_subscriber(v_objectNew(kernel,K_SUBSCRIBER));
            v_observerInit(v_observer(s),name, NULL, enable);
            s->qos = q;
            c_mutexInit(&s->sharesMutex, SHARED_MUTEX);
            if (q->share.enable) {
                v_lockShares(kernel);
                found = v_addShareUnsafe(kernel,v_entity(s));
                if (found != v_entity(s)) {
                    /* Make sure to set the partition list to NULL, because
                     * v_publicFree will cause a crash in the v_subscriberDeinit
                     * otherwise.
                     */
                    s->partitions = NULL;
                    /*v_publicFree to free reference held by the handle server.*/
                    v_publicFree(v_public(s));
                    /*Now free the local reference as well.*/
                    c_free(s);
                    pa_increment(&(v_subscriber(found)->shareCount));
                    v_unlockShares(kernel);
                    return c_keep(found);
                }
                s->shares = c_tableNew(v_kernelType(kernel,K_READER),
                                       "qos.share.name");
            } else {
                s->shares = NULL;
            }
            s->shareCount  = 1;
            s->partitions  = v_partitionAdminNew(kernel);
            s->readers     = c_setNew(v_kernelType(kernel,K_READER));

            if (q->share.enable) {
                s->participant = kernel->builtin->participant;
            } else {
                s->participant = p;
            }

            c_lockInit(&s->lock,SHARED_LOCK);
            v_participantAdd(v_participant(s->participant),v_entity(s));

            if (q->share.enable) {
                v_unlockShares(kernel);
            }
            if (enable) {
                v_subscriberEnable(s);
            }
        } else {
            OS_REPORT(OS_ERROR,
                      "v_subscriberNew", 0,
                      "Subscriber not created: inconsistent qos");
            s = NULL;
        }
    } else
    {
        OS_REPORT(OS_ERROR,
              "v_subscriberNew", 0,
              "Subscriber not created: Access rights for one of the partitions listed in the partition list was not sufficient (i.e. read or readwrite).");
        s = NULL;
    }
    return s;
}
Beispiel #15
0
v_kernel
v_kernelNew(
    c_base base,
    const c_char *name,
    v_kernelQos qos)
{
    v_kernel kernel;
    v_kernelStatistics kernelStatistics;
    v_spliced sd;

    kernel = c_lookup(base,name);
    if (kernel != NULL) {
        assert(C_TYPECHECK(kernel,v_kernel));
        kernel->userCount++;
        return kernel;
    }

    loadkernelModule(base);

    kernel = (v_kernel)c_new(c_resolve(base,"kernelModule::v_kernel"));
    if (!kernel) {
        OS_REPORT(OS_ERROR,
                  "v_kernelNew",0,
                  "Failed to allocate kernel.");
        return NULL;
    }
    v_objectKind(kernel) = K_KERNEL;
    v_object(kernel)->kernel = (c_voidp)kernel;
    kernel->handleServer = v_handleServerNew(base);

#define INITTYPE(k,t,l) k->type[l] = c_resolve(base,#t)

    INITTYPE(kernel,kernelModule::v_kernel,             K_KERNEL);
    INITTYPE(kernel,kernelModule::v_participant,        K_PARTICIPANT);
    INITTYPE(kernel,kernelModule::v_waitset,            K_WAITSET);
    INITTYPE(kernel,kernelModule::v_condition,          K_CONDITION);
    INITTYPE(kernel,kernelModule::v_query,              K_QUERY);
    INITTYPE(kernel,kernelModule::v_dataReaderQuery,    K_DATAREADERQUERY);
    INITTYPE(kernel,kernelModule::v_dataViewQuery,      K_DATAVIEWQUERY);
    INITTYPE(kernel,kernelModule::v_dataView,           K_DATAVIEW);
    INITTYPE(kernel,kernelModule::v_dataViewSample,     K_DATAVIEWSAMPLE);
    INITTYPE(kernel,kernelModule::v_dataViewInstance,   K_DATAVIEWINSTANCE);
    INITTYPE(kernel,kernelModule::v_projection,         K_PROJECTION);
    INITTYPE(kernel,kernelModule::v_mapping,            K_MAPPING);
    INITTYPE(kernel,kernelModule::v_topic,              K_TOPIC);
    INITTYPE(kernel,kernelModule::v_message,            K_MESSAGE);
    INITTYPE(kernel,kernelModule::v_transaction,        K_TRANSACTION);
    INITTYPE(kernel,kernelModule::v_dataReaderInstance, K_DATAREADERINSTANCE);
    INITTYPE(kernel,kernelModule::v_purgeListItem,      K_PURGELISTITEM);
    INITTYPE(kernel,kernelModule::v_groupPurgeItem,     K_GROUPPURGEITEM);
    INITTYPE(kernel,kernelModule::v_dataReaderSample,   K_READERSAMPLE);
    INITTYPE(kernel,kernelModule::v_publisher,          K_PUBLISHER);
    INITTYPE(kernel,kernelModule::v_subscriber,         K_SUBSCRIBER);
    INITTYPE(kernel,kernelModule::v_partition,             K_DOMAIN);
    INITTYPE(kernel,kernelModule::v_partitionInterest,     K_DOMAININTEREST);
    INITTYPE(kernel,kernelModule::v_partitionAdmin,        K_DOMAINADMIN);
    INITTYPE(kernel,kernelModule::v_reader,             K_READER);
    INITTYPE(kernel,kernelModule::v_writer,             K_WRITER);
    INITTYPE(kernel,kernelModule::v_writerGroup,        K_WRITERGROUP);
    INITTYPE(kernel,kernelModule::v_group,              K_GROUP);
    INITTYPE(kernel,kernelModule::v_groupInstance,      K_GROUPINSTANCE);
    INITTYPE(kernel,kernelModule::v_groupSample,        K_GROUPSAMPLE);
    INITTYPE(kernel,kernelModule::v_groupCacheItem,     K_GROUPCACHEITEM);
    INITTYPE(kernel,kernelModule::v_cache,              K_CACHE);
    INITTYPE(kernel,kernelModule::v_entry,              K_ENTRY);
    INITTYPE(kernel,kernelModule::v_dataReaderEntry,    K_DATAREADERENTRY);
    INITTYPE(kernel,kernelModule::v_groupAction,        K_GROUPACTION);
    INITTYPE(kernel,kernelModule::v_groupStream,        K_GROUPSTREAM);
    INITTYPE(kernel,kernelModule::v_groupQueue,         K_GROUPQUEUE);
    INITTYPE(kernel,kernelModule::v_groupQueueSample,   K_GROUPQUEUESAMPLE);
    INITTYPE(kernel,kernelModule::v_dataReader,         K_DATAREADER);
    INITTYPE(kernel,kernelModule::v_deliveryService,    K_DELIVERYSERVICE);
    INITTYPE(kernel,kernelModule::v_deliveryServiceEntry, K_DELIVERYSERVICEENTRY);
    INITTYPE(kernel,kernelModule::v_index,              K_INDEX);
    INITTYPE(kernel,kernelModule::v_filter,             K_FILTER);
    INITTYPE(kernel,kernelModule::v_readerStatus,       K_READERSTATUS);
    INITTYPE(kernel,kernelModule::v_writerStatus,       K_WRITERSTATUS);
    INITTYPE(kernel,kernelModule::v_partitionStatus,    K_DOMAINSTATUS);
    INITTYPE(kernel,kernelModule::v_topicStatus,        K_TOPICSTATUS);
    INITTYPE(kernel,kernelModule::v_subscriberStatus,   K_SUBSCRIBERSTATUS);
    INITTYPE(kernel,kernelModule::v_status,             K_PUBLISHERSTATUS);
    INITTYPE(kernel,kernelModule::v_status,             K_PARTICIPANTSTATUS);
    INITTYPE(kernel,kernelModule::v_kernelStatus,       K_KERNELSTATUS);
    INITTYPE(kernel,kernelModule::v_readerStatistics,   K_READERSTATISTICS);
    INITTYPE(kernel,kernelModule::v_writerStatistics,   K_WRITERSTATISTICS);
    INITTYPE(kernel,kernelModule::v_queryStatistics,    K_QUERYSTATISTICS);
    INITTYPE(kernel,kernelModule::v_lease,              K_LEASE);
    INITTYPE(kernel,kernelModule::v_leaseAction,        K_LEASEACTION);
    INITTYPE(kernel,kernelModule::v_serviceManager,     K_SERVICEMANAGER);
    INITTYPE(kernel,kernelModule::v_service,            K_SERVICE);
    INITTYPE(kernel,kernelModule::v_serviceState,       K_SERVICESTATE);
    INITTYPE(kernel,kernelModule::v_networking,         K_NETWORKING);
    INITTYPE(kernel,kernelModule::v_durability,         K_DURABILITY);
    INITTYPE(kernel,kernelModule::v_cmsoap,             K_CMSOAP);
    INITTYPE(kernel,kernelModule::v_leaseManager,       K_LEASEMANAGER);
    INITTYPE(kernel,kernelModule::v_groupSet,           K_GROUPSET);
    INITTYPE(kernel,kernelModule::v_proxy,              K_PROXY);
    INITTYPE(kernel,kernelModule::v_waitsetEvent,       K_WAITSETEVENT);
    INITTYPE(kernel,kernelModule::v_waitsetEventHistoryDelete,  K_WAITSETEVENTHISTORYDELETE);
    INITTYPE(kernel,kernelModule::v_waitsetEventHistoryRequest, K_WAITSETEVENTHISTORYREQUEST);
    INITTYPE(kernel,kernelModule::v_waitsetEventPersistentSnapshot, K_WAITSETEVENTPERSISTENTSNAPSHOT);
    INITTYPE(kernel,kernelModule::v_writerSample,       K_WRITERSAMPLE);
    INITTYPE(kernel,kernelModule::v_writerInstance,     K_WRITERINSTANCE);
    INITTYPE(kernel,kernelModule::v_writerInstanceTemplate, K_WRITERINSTANCETEMPLATE);
    INITTYPE(kernel,kernelModule::v_writerCacheItem,    K_WRITERCACHEITEM);
    /* Networking types */
    INITTYPE(kernel,kernelModule::v_networkReader,      K_NETWORKREADER);
    INITTYPE(kernel,kernelModule::v_networkReaderEntry, K_NETWORKREADERENTRY);
    INITTYPE(kernel,kernelModule::v_networkMessage,     K_NETWORKMESSAGE);
    INITTYPE(kernel,kernelModule::v_networkMapEntry,    K_NETWORKMAPENTRY);

    INITTYPE(kernel,kernelModule::v_spliced,            K_SPLICED);
    INITTYPE(kernel,kernelModule::v_configuration,      K_CONFIGURATION);
    INITTYPE(kernel,kernelModule::v_registration,       K_REGISTRATION);

    INITTYPE(kernel,kernelModule::v_historicalDataRequest,K_HISTORICALDATAREQUEST);
    INITTYPE(kernel,kernelModule::v_persistentSnapshotRequest,K_PERSISTENTSNAPSHOTREQUEST);
    INITTYPE(kernel,kernelModule::v_pendingDisposeElement,K_PENDINGDISPOSEELEMENT);

#undef INITTYPE


    kernel->pendingDisposeList =
       c_listNew(v_kernelType(kernel, K_PENDINGDISPOSEELEMENT ));
    c_mutexInit(&kernel->pendingDisposeListMutex, SHARED_MUTEX);

    kernelStatistics = v_kernelStatisticsNew(kernel);
    v_observableInit(v_observable(kernel),
                     V_KERNEL_VERSION,
                     v_statistics(kernelStatistics),
                     TRUE);
    c_lockInit(&kernel->lock,SHARED_LOCK);
    kernel->qos = v_kernelQosNew(kernel, qos);
    {
        os_time time;
        /* Fill GID with 'random' value */
        memset(&kernel->GID, 0, sizeof(kernel->GID));
        time = os_timeGet();
        kernel->GID.systemId = time.tv_nsec;
    }
    kernel->participants = c_setNew(v_kernelType(kernel,K_PARTICIPANT));
    kernel->partitions = c_tableNew(v_kernelType(kernel,K_DOMAIN),"name");
    kernel->topics = c_tableNew(v_kernelType(kernel,K_TOPIC),"name");
    kernel->groupSet = v_groupSetNew(kernel);
    kernel->serviceManager = v_serviceManagerNew(kernel);
    kernel->livelinessLM = v_leaseManagerNew(kernel);
    kernel->configuration = NULL;
    kernel->userCount = 1;
    kernel->transactionCount = 0;
    kernel->splicedRunning = TRUE;
    kernel->maxSamplesWarnLevel = V_KERNEL_MAX_SAMPLES_WARN_LEVEL_DEF;
    kernel->maxSamplesWarnShown = FALSE;
    kernel->maxSamplesPerInstanceWarnLevel = V_KERNEL_MAX_SAMPLES_PER_INSTANCES_WARN_LEVEL_DEF;
    kernel->maxSamplesPerInstanceWarnShown = FALSE;
    kernel->maxInstancesWarnLevel = V_KERNEL_MAX_INSTANCES_WARN_LEVEL_DEF;
    kernel->maxInstancesWarnShown = FALSE;
    kernel->enabledStatisticsCategories =
        c_listNew(c_resolve(base, "kernelModule::v_statisticsCategory"));

    c_mutexInit(&kernel->sharesMutex, SHARED_MUTEX);
    kernel->shares = c_tableNew(v_kernelType(kernel,K_SUBSCRIBER),
                                "qos.share.name");

    kernel->crc = v_crcNew(kernel, V_CRC_KEY);
    kernel->builtin = v_builtinNew(kernel);

    kernel->deliveryService = NULL;

    sd = v_splicedNew(kernel);
    c_free(sd);


    c_bind(kernel,name);

    return kernel;
}