Changeset 68 for trunk/kernel/libk


Ignore:
Timestamp:
Jun 27, 2017, 10:24:13 AM (7 years ago)
Author:
alain
Message:

Fix bug in kernel_init, and reduce size of remote_fifo.

Location:
trunk/kernel/libk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/libk/remote_fifo.c

    r60 r68  
    11/*
    2  * remote_fifo.c  Implement a lock-less FIFO,
    3                   multiple-remote-writers / single-local-reader
     2 * remote_fifo.c  Implement a lock-less FIFO, multiple-remote-writers / single-local-reader
    43 *
    54 * Authors : Mohamed Lamine Karaoui (2015)
    6  *           Alain Greiner          (2016)
     5 *           Alain Greiner          (2016,2017)
    76 *
    87 * Copyright (c) UPMC Sorbonne Universites
     
    4443    for( slot = 0 ; slot < CONFIG_REMOTE_FIFO_SLOTS ; slot++ )
    4544    {
    46         fifo->valid[slot] = false;
     45        fifo->valid[slot] = 0;
    4746    }
    4847}
    4948
    50 ////////////////////////////////////////////
    51 error_t remote_fifo_put_item( xptr_t   fifo,
    52                               void   * item,
    53                               uint32_t size,
    54                               bool_t * first )
     49//////////////////////////////////////////////
     50error_t remote_fifo_put_item( xptr_t     fifo,
     51                              uint64_t * item,
     52                              bool_t   * first )
    5553{
    5654    uint32_t        wr_id;
     
    7169        hal_disable_irq( &save_sr );
    7270       
    73     // get write slot index and increment
     71    // get write slot index and atomic increment
    7472        wr_id = hal_remote_atomic_add( XPTR( cxy , &ptr->wr_id ) , 1 );
    7573
     
    114112
    115113    // copy item to fifo
    116         hal_remote_memcpy( XPTR( cxy       , &ptr->data[ptw] ),
    117                        XPTR( local_cxy , item ) , size );
     114        hal_remote_swd( XPTR( cxy , &ptr->data[ptw] ), *item );
    118115        hal_wbflush();
    119116
    120117    // set the slot valid flag
    121118        hal_remote_sw( XPTR( cxy , &ptr->valid[ptw] ) , 1 );
    122 
    123119        hal_wbflush();
    124120
     
    135131//////////////////////////////////////////////////
    136132error_t local_fifo_get_item( remote_fifo_t * fifo,
    137                              void          * item,
    138                              uint32_t        size )
     133                             uint64_t      * item )
    139134{
    140135    // get fifo state
     
    152147       
    153148    // copy item from FIFO to local buffer
    154     memcpy( item , &fifo->data[ptr] , size );
     149    *item = fifo->data[ptr];
    155150
    156151    // reset valid slot flag
  • trunk/kernel/libk/remote_fifo.h

    r14 r68  
    11/*
    2  * remote_fifo.h - kernel generic SRMW FIFO
     2 * remote_fifo.h - Lock-less Single-Reader Multiple-Writers FIFO
    33 *
    4  * Authors : Mohamed Lamine Karaoui / Alain Greiner (2016)
     4 * Authors : Mohamed Lamine Karaoui (2015)
     5 *           Alain Greiner (2016,2017)
    56 *
    67 * Copyright (c) UPMC Sorbonne Universites
     
    3334 * This structure defines a generic, single reader, multiple writers
    3435 * remote FIFO, that is used by the RPCs for inter cluster communications.
    35  * The accesses are implemented using a lock-free algorithm, as it
    36  * uses a ticket based mechanism to handle concurrent access between
    37  * the multiple writers.
    38  * Each FIF0 slot can contain one full cache line, even if RPCs store only
    39  * an extended pointer on the RPC descriptor in each slot.
     36 * The accesses are implemented using a lock-free algorithm, as it uses a ticket
     37 * based mechanism to handle concurrent access between multiple writers.
     38 * Each FIF0 slot can contain one 64 bits integer.
    4039 * In case of FIFO full, the writer deschedule without blocking, to retry later.
    4140 *
    4241 * WARNING : the number of slots is statically defined by the global
    4342 * configuration parameter CONFIG_REMOTE_FIFO_SLOTS for all fifos, requiring
    44  * CACHE_LINE_SIZE * CONFIG_REMOTE_FIFO_SLOTS bytes for each FIFO...
     43 * 12 * CONFIG_REMOTE_FIFO_SLOTS bytes for each FIFO.
    4544 ***********************************************************************************/
     45
    4646typedef struct remote_fifo_s
    4747{
    4848        volatile uint32_t  wr_id;                            /*! write slot index      */
    4949        volatile uint32_t  rd_id;                            /*! read  slot index      */
    50     volatile bool_t    valid[CONFIG_REMOTE_FIFO_SLOTS];  /*! empty slot if false   */
    51         cacheline_t        data[CONFIG_REMOTE_FIFO_SLOTS];   /*! fifo slot content     */
     50    volatile uint32_t  valid[CONFIG_REMOTE_FIFO_SLOTS];  /*! empty slot if 0       */
     51        uint64_t           data[CONFIG_REMOTE_FIFO_SLOTS];   /*! fifo slot content     */
    5252}
    5353remote_fifo_t;
     
    7272 ***********************************************************************************/
    7373error_t local_fifo_get_item( remote_fifo_t * fifo,
    74                              void          * item,
    75                              uint32_t        size );
     74                             uint64_t      * item );
    7675
    7776/************************************************************************************
     
    8483 * @ fifo    : extended pointer to the fifo in remote cluster.
    8584 * @ item    : pointer on a local buffer containing the item to be stored.
    86  * @ size    : actual number of bytes in one item.
    87  * @ first   : return value (true if first item registered in remote fifo)
     85 * @ first   : [out] true if first item registered in remote fifo.
    8886 * @ return  0 on success / EBUSY if a contention has been detected.
    8987 ***********************************************************************************/
    9088error_t remote_fifo_put_item( xptr_t     fifo,
    91                               void     * item,
    92                               uint32_t   size,
     89                              uint64_t * item,
    9390                              bool_t   * first );
    9491
Note: See TracChangeset for help on using the changeset viewer.