shared memory question - VxWorks

This is a discussion on shared memory question - VxWorks ; I'm perusing the vxWorks programmers guide. At issue is the need to use shared memory. With regards to allocating a shared memory address, a snippet from the guide is as follows: [start quote] This same technique can be used to ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: shared memory question

  1. shared memory question


    I'm perusing the vxWorks programmers guide. At issue is the need to
    use shared memory. With regards to allocating a shared memory address,
    a snippet from the guide is as follows:

    [start quote]

    This same technique can be used to advertise a shared-memory address.
    For example, task t1 on CPU 0 allocates a chunk of memory and adds the
    address to the database with the name mySharedMem. Task t2 on CPU 1 can
    find the address of this shared memory by looking up the address in the
    name database using mySharedMem.

    Tasks on different processors can use an agreed-upon name to get a
    newly created object's value. See Table 11-1 for a list of name service
    routines. Note that retrieving an ID from the name database need occur
    only one time for each task, and usually occurs during application
    initialization.

    [end quote]

    Couple of questions:
    For the case where the allocated memory size is determined at runtime
    on a continuum. Does this mean I could allocate and de-allocate the
    shared memory on a continuum?

    1/
    In other words, CPU0 allocates shared memory space ON CPU1. Adds
    address to database. Informs CPU1 of address. CPU1 peforms some
    operation at address and completes the operation. CPU1 releases the
    address. The process repeats.

    2/
    With regards to the ID. Does this imply that I just need to re-use the
    ID if I were to allocate/de-allocate on the fly.

    Thanks in advance.


  2. Re: shared memory question

    Hi there,

    I've been using sm on a project for several months now, and I'm a
    little confused by what your questions are actually getting at. We have
    been using two PowerPC boards on a VME rack, and the two communicate
    via a vxWorks shared memory (sm) network. Our BSP is implemented in
    such a way that you can only open a VME slave window on the VME master
    board - so, the only way to configure shared memory has been to
    dual-port the master's physical memory across the VME bus. That is, our
    shared memory is physically located on the master board, and can be
    accessed by both the master and slave boards. This seems to be a pretty
    standard way of doing things from what I've read.

    Once the sm network is configured, the use of it via the smMemLib
    functions is transparent with respect to which board the memory is
    physically located on. So, you don't really have a concept of "CPU0
    allocating shared memory space on CPU1" - you just call smMemMalloc
    (1000) to allocate 1000 bytes of shared memory (you can also create
    discrete sm memory partitions if you so desire).

    If you need to access a sm object on multiple boards, you can use
    smObjLocalToGlobal and smObjGlobalToLocal to facilitate this - and you
    can store the global address using smNameLib functions so every sm
    board can retrieve the address.

    You can allocate/reallocate/free shared memory - but it doesn't really
    have to have anything to do with the shared memory name (ID). For
    example, you would just allocate shared memory on the master board and
    save the global address as a sm name if you wanted non-master boards to
    have direct access to the memory. If you freed the shared memory later
    on, you'd probably want to remove the sm name from the database.

    Not sure if I've really said anything useful there, but I hope it
    helps.

    Ben


+ Reply to Thread