Changes between Version 12 and Version 13 of library_mwmr


Ignore:
Timestamp:
Dec 2, 2014, 6:44:56 PM (10 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • library_mwmr

    v12 v13  
    66
    77It supports channelized communications , when the communication scheme can be statically described by a Task and Communication Graph.
    8 Each MWMR (Multi-Writer Multi-Reader) channel can be accessed concurently by one or several writer(s) and by one or several reader(s). It is implemented as a software FIFO, protected by a build-in lock.
     8Each MWMR (Multi-Writer Multi-Reader) channel can be accessed concurently by one or several writer(s) and by one or several reader(s). It is implemented as a software FIFO, protected by a build-in, user-level spin_lock.
    99
    1010This software FIFO can be directly accessed by an hardware coprocessor, thanks to the vc_mwmr_controller, but we only describe here the software API that can be used by a software applications.
    1111
    12 An MWMR transaction transfer an integer number of ''items'' between a task private buffer and the MWMR  channel. An ''item'' is an integer number of unsigned int (32 bits words). The channel "width" parameter define the number of words contained in an atomic ''item''.
     12An MWMR transaction transfer an integer number of items between a task private buffer and the MWMR communication channel. An item is the smallest quantity of data that can be atomically transfered. It is an integer number of 32 bits words (unsigned int).
    1313
    14 WARNING (i) The max number of words that can be stored in a MWMR channel is 1018 words (4072 bytes), because  the mwmr_channel_t object has a fixed size (4Kbytes in the present implementation).
     14An MWMR channel is therefore defined by two parameters:
     15 * The '''width''' parameter define the number of words contained in an item (can be 1).
     16 * The '''nitems''' parameter define the max number of items that can be stored in the FIFO.
    1517
    16 WARNING (ii) The MWMR channel, can be accessed by several tasks, but it must be initialized by one single task.
     18In the user code, an MWMR channel must be defined by two global variables:
     19 * a '''channel descriptor''' is a variable of type '''mwmr_channel_t'''.
     20 * a '''data buffer''' that is an array of (width * items) unsigned int entries.
    1721
    18 WARNING (iii) The channel must be declared in a non cacheable segment, if the platform does not provide hardware cache coherence.
     22WARNING (i) The MWMR channel, can be accessed by several tasks, but it must be initialized by one single task.
     23
     24WARNING (ii) The channel must be declared in a non cacheable segment, if the platform does not provide hardware cache coherence.
    1925
    2026== Initialisation Function ==
    2127
    22 === void '''mwmr_init'''( mwmr_channel_t* mwmr, unsigned int width, unsigned int    items ) ===
    23 This function initializes the MWMR channel descriptor (including the lock).
    24  * '''mwmr''' : MWMR channel virtual base address.
     28=== void '''mwmr_init'''( mwmr_channel_t* mwmr, unsigned int* buffer, unsigned int  width, unsigned int  items ) ===
     29This function initializes the MWMR channel descriptor (including the lock protecting exclusive access).
     30 * '''mwmr''' : MWMR channel descriptor base address.
     31 * '''buffer''' : data buffer (unsigned int) base address.
    2532 * '''width''' : number of 32 bits words contained in an item.
    26  * '''items''' : max number of items in the channel.
     33 * '''nitems''' : max number of items in the channel.
    2734It must be called by one single task.
    2835
     
    3138The ''mwmr_read()'' and ''mwmr_write()'' functions are blocking functions, that return only when the requested transfer is completed.
    3239
    33 === void '''mwmr_write'''( mwmr_channel_t* mwmr, unsigned int* buffer, unsigned int    nitems ) ===
     40=== void '''mwmr_write'''( mwmr_channel_t* mwmr, unsigned int* buffer, unsigned int  items ) ===
    3441This function transfer (nitems * width) 32 bits words from a task private buffer to the MWMR channel.
    3542 * '''mwmr''' : MWMR channel virtual base address.
    3643 * '''buffer''' : virtual base address of local buffer.
    37  * '''nitems''' : number of items to be transfered.
    38 It takes the lock for exclusive access before testing the channel state. If there is not enough space in mwmr channel to write nitems, it writes as many items as possible, releases the lock, and retry  after a random delay.
     44 * '''items''' : number of items to be transfered.
     45It takes the lock for exclusive access before testing the channel state. If there is not enough space in mwmr channel to write nitems, it writes as many items as possible, releases the lock, does not return, but retry to take the lock to transfer the rest of the data... up to completion.
    3946
    40 === void '''mwmr_read'''( mwmr_channel_t* mwmr, unsigned int* buffer, unsigned int nitems ) ===
     47=== void '''mwmr_read'''( mwmr_channel_t* mwmr, unsigned int* buffer, unsigned int items ) ===
    4148This function transfer (nitems * width) 32 bits words from the MWMR channel to a task private buffer.
    4249 * '''mwmr''' : MWMR channel virtual base address.
    4350 * '''buffer''' : virtual base address of local buffer.
    44  * '''nitems''' : number of items to be transfered.
    45 It takes the lock for exclusive access before testing the channel state. If there is not enough space in mwmr channel to write nitems, it writes as many items as possible, releases the lock, and retry  after a random delay.
     51 * '''items''' : number of items to be transfered.
     52It takes the lock for exclusive access before testing the channel state. If there is not enough space in mwmr channel to write nitems, it writes as many items as possible, releases the lock, does not return, but retry to take the lock to transfer the rest of the data... up to completion.
    4653
    4754
     
    5057The ''nb_mwmr_read()'' and ''nb_mwmr_write()'' functions are non-blocking functions.
    5158
    52 === unsigned int '''nb_mwmr_write'''( mwmr_channel_t* mwmr, unsigned int* buffer, unsigned int nitems ) ===
     59=== unsigned int '''nb_mwmr_write'''( mwmr_channel_t* mwmr, unsigned int* buffer, unsigned int items ) ===
    5360This function request to transfer (nitems * width) 32 bits words from a task private buffer tot he MWMR channel.
    5461 * '''mwmr''' : MWMR channel virtual base address.
    5562 * '''buffer''' : virtual base address of local buffer.
    56  * '''nitems''' : number of items to be transfered.
     63 * '''items''' : number of items to be transfered.
    5764It takes the lock for exclusive access before testing the channel state. If there is not enough free space in the channel, it transfer as many items as possible, releases the lock, and returns the number of actually transfered items (it can be 0).
    5865
    59 === unsigned int '''nb_mwmr_write'''( mwmr_channel_t* mwmr, unsigned int* buffer, unsigned int nitems ) ===
     66=== unsigned int '''nb_mwmr_write'''( mwmr_channel_t* mwmr, unsigned int* buffer, unsigned int items ) ===
    6067This function request to transfer (nitems * width) 32 bits words from the MWMR channel to a task private buffer.
    6168 * '''mwmr''' : MWMR channel virtual base address.
    6269 * '''buffer''' : virtual base address of local buffer.
    63  * '''nitems''' : number of items to be transfered.
     70 * '''items''' : number of items to be transfered.
    6471It takes the lock for exclusive access before testing the channel state. If there is not enough data in the channel, it transfer as many items as possible, releases the lock, and returns the number of actually transfered items (it can be 0).
    6572