Help on simple memory sharing. - VxWorks

This is a discussion on Help on simple memory sharing. - VxWorks ; Hello group! I guess most of you will think this is a pretty silly question, but I must say in my defense that I am new to RTOS and to VxWorks 6.2. Thing is, I have two RTPs running at ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Help on simple memory sharing.

  1. Help on simple memory sharing.

    Hello group!

    I guess most of you will think this is a pretty silly question, but I must
    say in my defense that I am new to RTOS and to VxWorks 6.2.

    Thing is, I have two RTPs running at the same time on the same PPC
    processor. I need to share some information between them, so, reading the
    manual, I've found out that I should use the library sdLib. The API says I
    should create a named shared memory region with sdCreate(name,...) and
    access it from another RTP with sdOpen(name,...). That's clear for me.

    My question is: how do I create variables in that region? I mean, I need to
    share a boolean and a buffer, but I have no idea how to do it. I guess just
    declaring the variables after creating the shared memory region won't make
    it.

    Any help will be deeply appreciated.

    Best regards from Spain
    Ainda

  2. Lightbulb Re: Help on simple memory sharing.

    Hi Ainda,

    This may be a late reply , but may help to maintain the knowledge database

    The physical address passed to sdCreate/sdOpen can be used for storing the shared variable.

    for example

    struct sampleSharedFirstData
    {
    int i;
    float f;
    }

    first RTP
    -----------------------
    void * pVirtAddress = (char*)malloc(512);;
    sharedDataMemId = sdOpen("sharedDataMem", 0, OM_CREATE, 512,0, (SD_ATTR_RWX |SD_CACHE_OFF),VirtAddress);
    struct sampleSharedFirstData * sd = pVirtAddress;
    sd->i = 100;
    sd->f = 10.23;
    bool b* = pVirtAddress + sizeof(struct sampleSharedFirstData );

    second RTP
    ---------------------------------
    SD_ID sharedDataMemId;
    void * pVirtAddress = NULL;

    sharedDataMemId = sdOpen("sharedDataMem", 0,OM_CREATE , 512,0, (SD_ATTR_RWX |SD_CACHE_OFF), &pVirtAddress);

    sampleSharedFirstData * st = pVirtAddress;
    printf("\nst->i = %d",st->i);
    printf("\nst->f = %f",st->f);
    int *bl = pVirtAddress + sizeof(sampleSharedFirstData);
    printf("\nbool %d",*bl);

+ Reply to Thread