Changeset 407 for trunk/kernel/libk/remote_fifo.h
- Timestamp:
- Nov 7, 2017, 3:08:12 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/remote_fifo.h
r279 r407 28 28 #include <kernel_config.h> 29 29 #include <hal_types.h> 30 #include <printk.h> 30 31 #include <errno.h> 31 32 #include <hal_remote.h> 32 33 33 34 /************************************************************************************ 34 * This structure defines a generic, single reader, multiple writers 35 * remote FIFO, that is used by the RPCs for inter cluster communications. 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. 39 * In case of FIFO full, the writer deschedule without blocking, to retry later. 40 * 41 * WARNING : the number of slots is statically defined by the global 42 * configuration parameter CONFIG_REMOTE_FIFO_SLOTS for all fifos. requiring 43 * Each FIFO requires 8 + (12 * CONFIG_REMOTE_FIFO_SLOTS) bytes. 35 * This structure defines a generic, single reader, multiple writers FIFO, 36 * that is used for - RPC based - inter cluster communications. 37 * Each FIF0 slot can contain one 64 bits integer (or one extended pointer). 38 * The number of slots is defined by the CONFIG_REMOTE_FIFO_SLOTS parameter. 39 * - The write accesses are implemented using a lock-free algorithm, as it uses 40 * a ticket based mechanism to handle concurrent access between multiple writers. 41 * In case of FIFO full, the writer deschedule without blocking, to retry later. 42 * - The reader must take the try_lock implemented by the "owner" field, using 43 * an atomic_add(). The TRDID is a good owner identifier, because all 44 * RPC threads in a given cluster belong to the same kernel process, 45 * and RPC threads cannot have local index LTID = 0. 46 * 47 * WARNING : Each FIFO requires 12 + (12 * CONFIG_REMOTE_FIFO_SLOTS) bytes. 44 48 ***********************************************************************************/ 45 49 46 50 typedef struct remote_fifo_s 47 51 { 52 uint32_t owner; /*! owner thread trdid */ 48 53 volatile uint32_t wr_id; /*! write slot index */ 49 54 volatile uint32_t rd_id; /*! read slot index */ … … 63 68 /************************************************************************************ 64 69 * This non blocking function tries to get one item from the local fifo. 65 * The reader must get exclusive access before calling this function.70 * The reader must get exclusive access for read before calling this function. 66 71 * The read slot index is incremented. 67 72 ************************************************************************************ … … 75 80 /************************************************************************************ 76 81 * This blocking function puts one item to a remote fifo identified 77 * by an extended pointer. 78 * This function gets a write ticket using a remote_atomic_increment on the 79 * write slot. Then, it waits until the slot is empty, using a descheduling 80 * policy without blocking. 82 * by an extended pointer. It gets a write ticket on the slot to be written, 83 * using a remote_atomic_add() on the write slot index. Then, it waits until 84 * the slot is empty, using a descheduling policy without blocking if required. 85 * It implements a watchdog, returning when the item has been successfully 86 * registered, or after CONFIG_REMOTE_FIFO_MAX_ITERATIONS failures. 81 87 ************************************************************************************ 82 88 * @ fifo : extended pointer to the fifo in remote cluster. 83 89 * @ item : item to be stored. 84 * @ first : [out] true if first item registered in remote fifo.85 90 * @ return 0 on success / EBUSY if a contention has been detected. 86 91 ***********************************************************************************/ 87 92 error_t remote_fifo_put_item( xptr_t fifo, 88 uint64_t item, 89 bool_t * first ); 93 uint64_t item ); 90 94 91 95 /************************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.