US20160004478A1 - Wait-free algorithm for inter-core, inter-process, or inter-task communication - Google Patents
Wait-free algorithm for inter-core, inter-process, or inter-task communication Download PDFInfo
- Publication number
- US20160004478A1 US20160004478A1 US14/770,463 US201414770463A US2016004478A1 US 20160004478 A1 US20160004478 A1 US 20160004478A1 US 201414770463 A US201414770463 A US 201414770463A US 2016004478 A1 US2016004478 A1 US 2016004478A1
- Authority
- US
- United States
- Prior art keywords
- double buffer
- buffer
- selected double
- reader
- data
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Abandoned
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0628—Interfaces specially adapted for storage systems making use of a particular technique
- G06F3/0655—Vertical data movement, i.e. input-output transfer; data movement between one or more hosts and one or more storage devices
- G06F3/0656—Data buffering arrangements
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/0223—User address space allocation, e.g. contiguous or non contiguous base addressing
- G06F12/0284—Multiple user address space allocation, e.g. using different base addresses
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0602—Interfaces specially adapted for storage systems specifically adapted to achieve a particular effect
- G06F3/061—Improving I/O performance
- G06F3/0613—Improving I/O performance in relation to throughput
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F3/00—Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
- G06F3/06—Digital input from, or digital output to, record carriers, e.g. RAID, emulated record carriers or networked record carriers
- G06F3/0601—Interfaces specially adapted for storage systems
- G06F3/0668—Interfaces specially adapted for storage systems adopting a particular infrastructure
- G06F3/0671—In-line storage system
- G06F3/0683—Plurality of storage devices
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/544—Buffers; Shared memory; Pipes
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
Definitions
- the present invention relates generally to multi-core computer systems, and particularly to methods for communicating and sharing data between cores, processes, or threads.
- testing should be performed to ensure that the operation of each multi-core device complies with required regulations. For example, it may be a requirement that a display is updated every 50 ms. Before a multi-core device can be utilized, it should be shown to comply with this requirement.
- multi-core devices In order to ensure that a multi-core device complies with required regulations, multi-core devices should be able to pass data between cores, processes and threads in a wait-free manner. There should also be no interference between applications running on the multi-core device. That is, each application should be partitioned in memory and time space, such that memory and timing are not affected by the execution of other applications.
- Blocking algorithms are non-ideal, as threads/cores compete for shared resources and, due to mutual exclusion, can have their execution postponed indefinitely.
- Current, conventional non-blocking algorithms predominately use atomic read-modify-write primitives that should be provided by the underlying hardware components.
- non-blocking algorithms may require a writer to wait for a reader to complete reading data from a shared resource before the writer is permitted to write data to the shared resource. That is, current non-blocking algorithms may not allow a reader to simultaneously read data from a shared resource as a writer writes data to the shared resource.
- a system and method is proposed for providing deterministic inter-core, inter-process, and inter-thread communication between a reader and a writer by passing data through shared memory using double buffering of double buffers.
- a system and method according to the invention enables one or more advantages to be obtained, including allowing, in a deterministic manner, a reader to simultaneously read data from a shared resource as a writer writes data to the shared resource.
- a method for providing deterministic inter-core, inter-process, and inter-thread communication between a reader and a writer by passing data through shared memory using double buffering of double buffers includes the reader or writer selecting one of a first double buffer or a second double buffer as a selected double buffer.
- the writer writes data to the selected double buffer, each double buffer is stored in the shared memory, and each double buffer includes a first low level buffer and a second low level buffer.
- the method additionally includes the reader reading data. Reading data includes the reader determining if new data has been written to the selected double buffer. New data corresponds to data that has not been read by the reader.
- the reader selects the non-selected double buffer as the selected double buffer such that the writer writes data to the newly selected double buffer. If new data has been written to the selected double buffer the reader also determines if new data has been written to the previously selected double buffer in the time since the previous check to determine if new data had been written to the previously selected double buffer. If new data has been written to the selected double buffer, the reader accesses and outputs the last data written to the previously selected double buffer. If new data has not been written to the selected double buffer, the reader determines if old data or new data was written to the non-selected double buffer. Old data corresponds to data that the reader has previously read.
- the writer writing data to the selected double buffer may include the writer storing data in the low level buffer of the selected double buffer that is most convenient.
- the reader may read data at the same time as the writer writes data to the selected double buffer.
- the reader may output a state.
- the reader may output a new data state when new data has been written to the selected double buffer.
- the reader may output the new data state when new data has not been written to the selected double buffer and new data has been written to the non-selected double buffer.
- the reader may output an old data state when new data has not been written to both the selected double buffer and the non-selected double buffer and the non-selected double buffer contains old data.
- the reader may output a no data state when new data has not been written to both the selected double buffer and the non-selected double buffer and the non-selected double buffer does not contain old data.
- the reader or writer selecting one of the first double buffer or the second double buffer as the selected double buffer may include the reader setting a transmit index in the shared memory to identify the first double buffer or the second double buffer.
- the double buffer identified by the transmit index may correspond to the selected double buffer and the double buffer not identified by the transmit index may correspond to an non-selected double buffer.
- the reader or writer may initialize both double buffers to an initial state prior to the reader reading data.
- initializing both double buffers to an initial state may include the reader or writer setting a shared index in the shared memory to an initial value for the first double buffer and the second double buffer.
- the shared index may identify one of the first low level buffer, the second low level buffer, or the initial value for each double buffer.
- the reader determining if new data has been written to the selected double buffer may include the reader reading the transmit index to identify the selected double buffer and the reader reading the shared index for the selected double buffer. New data may have been written to the selected double buffer if the shared index for the selected double buffer does not correspond to the initial value.
- the reader determining if new data has been written to the selected double buffer may include the reader reading the transmit index to identify the selected double buffer, the reader reading the shared index for the selected double buffer, and the reader reading a read index for the selected double buffer.
- the read index for a given double buffer may indicate the low level buffer identified by the shared index for the given double buffer from which the reader last accessed data.
- New data may have been written to the selected double buffer if the shared index for the selected double buffer does not correspond to the read index for the selected double buffer and the shared index for the selected double buffer does not correspond to the initial value.
- the reader may initialize the non-selected double buffer before the reader selects the non-selected double buffer as the selected double buffer.
- the reader initializing the non-selected double buffer may include the reader setting the shared index for the non-selected double buffer to the initial value.
- the reader selecting the non-selected double buffer as the selected double buffer may include the reader updating the transmit index to identify the non-selected double buffer such that the non-selected double buffer is now the selected double buffer and the selected double buffer is now the non-selected double buffer.
- the reader determining if new data has been written to the previously selected double buffer in the time since the previous check may include the reader reading the shared index for the previously selected double buffer and the reader setting a read index for the previously selected double buffer in the shared memory to identify the low level buffer identified by the shared index for the non-selected double buffer.
- the reader accessing and outputting the last data written to the previously selected double buffer may include the reader accessing the data stored in the low level buffer identified by the shared index of the previously selected double buffer and the reader outputting the data.
- determining if old data or new data was written to the non-selected double buffer may include the reader reading the shared index for the non-selected double buffer.
- the non-selected double buffer may not contain old data or new data if the shared index for the non-selected double buffer corresponds to the initial value.
- determining if old data or new data was written to the non-selected double buffer may include, if the shared index for the non-selected double buffer does not correspond to the initial value, the reader comparing the shared index for the non-selected double buffer and the read index for the non-selected double buffer.
- the non-selected double buffer may contain old data if the shared index for the non-selected double buffer and the read index for the non-selected double buffer correspond to the same low level buffer.
- the shared index for the non-selected double buffer and the read index for the non-selected double buffer do not correspond to the same low level buffer, new data may have been written to the non-selected double buffer and the reader setting the read index for the non-selected double buffer may identify the low level buffer identified by the shared index for the non-selected double buffer.
- the reader accessing and outputting the last data written to the non-selected double buffer may include the reader accessing the data stored in the low level buffer identified by the shared index of the non-selected double buffer and the reader outputting the data.
- the writer writing data to the selected double buffer may include the writer reading the shared index for the selected double buffer, the writer storing data in a next low level buffer for the selected double buffer, and the writer setting the shared index for the selected double buffer to correspond to the next low level buffer.
- the next low level buffer may corresponds to the low level buffer for the selected double buffer not indicated by the shared index for the selected double buffer if the shared index corresponds to the first low level buffer or the second low level buffer.
- the next low level buffer may correspond to the first low level buffer for the selected double buffer if the shared index for the selected double buffer corresponds to the initial value.
- the writer setting the shared index for the selected double buffer to correspond to the next low level buffer may include reading a value of the transmit index (Tx) and determining a corrected transmit index.
- the transmit index value may be an integer between zero and three.
- a value of the corrected transmit index may be equal to Tx mod 2.
- the corrected transmit index having a value of zero may correspond to the selected double buffer being the first double buffer.
- the corrected transmit index having a value of one may correspond to the selected double buffer being the second double buffer.
- the writer setting the shared index for the selected double buffer to correspond to the next low level buffer may additionally include reading a value of the shared index (Sx) and determining a corrected shared index.
- the shared index value may be an integer between zero and four.
- a value of the corrected shared index may be equal to ((Sx ⁇ 1)mod 2)+1.
- the corrected shared index having a value of zero may correspond to the initial value.
- the corrected shared index having a value of one may correspond to the first low level buffer.
- the corrected shared index having a value of two may correspond to the second low level buffer.
- the writer setting the shared index for the selected double buffer to correspond to the next low level buffer may also include determining a value of the next low level buffer and setting the value of the shared index equal to the value of the next low level buffer.
- the value of the next low level buffer may equal (Sx mod 2)+1 if the transmit index equal zero or one.
- the value of the next low level buffer may equal (Sx mod 2)+3 if the transmit index equal two or three.
- a computational device may include a multicore processor and a shared memory.
- the multicore processor may carry out the method for providing deterministic inter-core, inter-process, and inter-thread communication between a reader and a writer by passing data through shared memory using double buffering of double buffers.
- a non-transitory computer-readable storage medium may store logical instructions thereon that when executed by a processor perform the steps of the method for providing deterministic inter-core, inter-process, and inter-thread communication between a reader and a writer by passing data through shared memory using double buffering of double buffers.
- FIG. 1 is a block diagram illustrating an exemplary multi-core computational device.
- FIG. 2 is a block diagram illustrating a method for providing deterministic inter-core, inter-process, and inter-thread communication between a reader and a writer;
- FIGS. 3 a - 3 c are block diagrams illustrating steps for reading data by the reader
- FIG. 4 is a block diagram illustrating steps for writing data by the writer
- FIG. 5 is a block diagram of another embodiment of the method for providing deterministic inter-core, inter-process, and inter-thread communication between a reader and a writer;
- FIGS. 6 a - 6 c are block diagrams illustrating steps for reading data by the reader
- FIG. 7 is a block diagram illustrating steps for writing data by the writer
- FIGS. 8 a - 8 b are block diagrams illustrating steps for reading data by the reader.
- FIG. 9 is a block diagram illustrating steps for writing data by the writer.
- the present invention provides a system and method for providing deterministic inter-core, inter-process, and inter-thread communication between a reader and a writer.
- the reader and writer communicate by passing data through a shared memory using double buffering of double buffers.
- the shared memory includes a first double buffer and a second double buffer. Both double buffers include a first low level buffer and a second low level buffer.
- double buffering of the double buffers both the reader and the writer may simultaneously access (i.e., read and/or write data to) the shared memory.
- the multi-core computational device 10 includes a multi-core processor 12 and a non-transitory computer-readable storage medium 18 .
- the multi-core processor 12 includes a first core 14 having a reader 15 and a second core 16 having a writer 17 .
- the reader 15 and writer 17 may have read-write access to a shared memory 20 included in the storage medium 18 .
- the shared memory 20 includes a read index 22 , a transmit index 24 , a shared index 26 , a first double buffer 28 , and a second double buffer 30 .
- the first double buffer 28 has a first low level buffer 32 and a second low level buffer 34 .
- the second double buffer 30 has a first low level buffer 36 and a second low level buffer 38 .
- the processor 12 may have various implementations.
- the processor 12 may include a central processing unit (CPU) or any other suitable multi-core device, such as a programmable circuit, integrated circuit, memory and I/O circuits, an application specific integrated circuit, microcontroller, complex programmable logic device, other programmable circuits, or the like.
- the processor 12 may also include a non-transitory computer readable memory, such as a CPU cache, computational random access memory (RAM), RAM, or any other suitable memory. Instructions for performing the method described below may be stored in the non-transitory computer readable memory and executed by the processor.
- the reader 15 and writer 17 may communicate by passing data through the shared memory 20 .
- Data may be passed through the shared memory 20 by the writer 17 storing (i.e., writing) data in and the reader 15 accessing (i.e., reading) the data stored in the first double buffer 28 and/or the second double buffer 30 . That is, the writer 17 writes data to the first low level buffer 32 of the first double buffer 28 , the second low level buffer 34 of the first double buffer 28 , the first low level buffer 36 of the second double buffer 30 , and/or the second low level buffer 38 of the second double buffer 30 .
- the reader 15 may read the last data written by the writer 17 .
- the writer 17 may write data three times prior to the reader 15 reading data. When the reader 15 reads data, the reader 15 will only read the last data written by the writer 17 (i.e., the reader 15 will not read the data written in the previous two write operations performed by the writer 17 ).
- the writer 17 In order to determine which double buffer 28 , 30 to write data to, the writer 17 reads the transmit index 24 to determine a selected double buffer. That is, the selected double buffer may identify either the first double buffers 28 or the second double buffer 30 . In order to determine which low level buffer 32 , 34 , 36 , 38 of the selected double buffer to write data, the writer 17 reads the shared index 26 . That is, the shared index 26 may identify the first low level buffer 32 , 36 or the second low level buffer 34 , 38 of the selected double buffer. The shared index 26 may identify, for a given double buffer 32 , 34 , the low level buffer to which data was last written. Similarly, the reader 15 also reads the transmit index 24 to determine the selected double buffer for reading data and the shared index 26 to determine which low level buffer 32 , 34 , 36 , 38 of the selected double buffer to read data from.
- the reader 15 may have read-write access to the read index 22 and the transmit index 24 .
- the reader 15 may have read only access to the first double buffer 32 and the second double buffer 34 .
- the reader 15 may also have read-write access or read only access to the shared index 26 .
- the writer 17 may have read-write access to the shared index 26 , the first double buffer 32 , and the second double buffer 34 .
- the writer 17 may have read only access to the transmit index 24 .
- the read and write operations should be atomic, i.e. performed without interrupt. That is, as implemented, the processor 12 and the shared memory 20 should be configured such that access to the transmit index 24 and the shared index 26 occurs atomically.
- the storage medium 18 may include a non-transitory computer readable medium, such as random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), or any other suitable medium. Instructions for performing the method described below may be stored in the non-transitory computer readable medium and executed by the processor.
- RAM random access memory
- ROM read-only memory
- EPROM erasable programmable read-only memory
- Flash memory any other suitable medium.
- a block diagram depicting a method for providing deterministic inter-core, inter-process, and inter-thread communication between a reader 15 and a writer 17 is shown.
- a double buffer is selected for storing data. That is, the reader 15 or writer 17 , e.g., may select either the first double buffer 28 or the second double buffer 30 as the selected double buffer.
- both the first double buffer 28 and the second double buffer 30 are initialized.
- the reader 15 prior to reading data, may perform initialization of the double buffers 28 , 30 .
- decision blocks 54 and 58 may occur simultaneously. That is, the reader 15 may read data at the same time as the writer 17 writes data.
- decision block 54 a check is performed to determine if data is to be written. If data is to be written, then, in process block 56 , the writer 17 writes data. For example, the writer 17 may store data in the low level buffer of the selected double buffer that is most convenient.
- decision block 58 a check is performed to determine if there data is to be read. If data is to be read, then, in process block 60 , the reader 15 reads data.
- reading data by the reader 15 is further described.
- decision block 62 a check is performed to determine if new data has been written to the selected double buffer. New data is data that has not previously been read by the reader 15 .
- the reader 15 may, e.g., initialize the non-selected double buffer. Initializing a double buffer 28 , 30 , e.g., is further described in process block 103 of FIG. 5 .
- the reader 15 e.g., selects the non-selected double buffer as the selected double buffer, such that the writer 17 will now write data to the newly selected double buffer.
- the reader 15 determines if new data has been written to the previously selected double buffer in the time since the previous check (i.e., process block 62 ). In process block 70 , the reader 15 reads and outputs the last data written to the previously selected double buffer. In process block 72 , the reader 15 optionally outputs a status of new data (i.e., when new data has been written to the selected double buffer).
- the reader 15 has received an instruction to read the last data written to the shared memory 20 .
- the selected double buffer is the first double buffer 28 and the writer 17 has previously written data to the first low level buffer 32 of the selected double buffer, but data has not been written to the second low level buffer 34 .
- process block 64 is performed.
- the non-selected double buffer i.e., the second double buffer 30
- the second double buffer 30 i.e., the non-selected double buffer
- the writer 17 will write data to the newly selected double buffer, not the double buffer from which the reader 15 is reading data (i.e., the previously selected double buffer).
- the reader 15 determines if new data has been written to the previously selected double buffer (i.e., the first double buffer 28 ) since process block 62 .
- the previously selected double buffer i.e., the first double buffer 28
- process block 62 data had been written to the first low level buffer 32 of the first double buffer 28 , but no data had been written to the second low level buffer 34 .
- the writer 17 wrote new data to the second low level buffer 34 of the first double buffer 32 (i.e., the selected double buffer at the time).
- process block 68 is not performed (i.e., the reader 15 does not check if new data has been written to the previously selected double buffer during operation of steps 64 and 66 ), then the reader 15 may incorrectly read old data (in this example the data stored in the first low level buffer 32 ) and miss the new data that was written to the shared memory 20 during operation of blocks 62 and 64 (in this example the data stored in the second low level buffer 34 ). The reading of old data as opposed to the new data may make the method non-deterministic and cause errors.
- decision block 80 of FIG. 3 b is performed.
- the reader 15 determines if old data or new data was written to the non-selected double buffer. Old data corresponds to data that the reader 15 has previously read. If neither old data nor new data was written to the non-selected double buffer, then, in process block 82 , no data is output by the reader 15 . Following process block 82 (i.e., when new data has not been written to both the selected double buffer and the non-selected double buffer does not contain old data), in process block 84 , a status no data may optionally be output.
- process block 86 if old data or new data was written to the non-selected double buffer, the reader 15 accesses and outputs the last data written to the non-selected double buffer. Accessing and outputting the last data written to the non-selected double buffer in process block 86 is further described in FIG. 3 c.
- decision block 87 determines if new data been written to the shared memory 20 since data was last read from the non-selected double buffer. If new data has been written, then, in process block 88 , the reader 15 reads and outputs the new data. In process block 90 (i.e., when new data has not been written to the selected double buffer and new data has been written to the non-selected double buffer), the reader 15 optionally outputs the status new data. If new data has not been written, then, in process block 92 , the reader 15 outputs the old data that was last written to the non-selected double buffer. In process block 94 (i.e., when new data has not been written to both the selected double buffer and the non-selected double buffer and the non-selected double buffer contains old data), the reader 15 may optional output the status old data.
- the writer 17 writing data in process block 56 of FIG. 2 is further described.
- decision block 95 the writer 17 determines if data has been written to the selected double buffer. If data has not been written to the selected double buffer, then, in process block 96 the writer 17 writes data to either of the low level buffers of the selected double buffer. For example, the writer 17 may write data to the low level buffer of the selected double buffer that is most convenient. The most convenient low level buffer may comprise the first low level buffer, the second low level buffer, the last low level buffer to which data was written, the low level buffer that data was not written to last, the low level buffer with the shortest access time, or any other suitable criteria for selecting the most convenient low level buffer. If data has been written to the selected double buffer, then, in process block 98 , the writer 17 writes data to the low level buffer of the selected double buffer that does not contain data or that contains the oldest data.
- the reader 15 sets the transmit index 24 to identify either the first double buffer 28 or the second double buffer 30 .
- the double buffer 28 , 30 identified by the transmit index 24 corresponds to the selected double buffer.
- the double buffer not identified by the transmit index corresponds to an non-selected double buffer. For example, if the transmit index 24 contains the value zero, the first double buffer 28 may be the selected double buffer and the second double buffer 30 may be the non-selected double buffer. Alternatively, if the transmit index 24 contains the value one, the second double buffer 30 may be the selected double buffer and the first double buffer 28 may be the non-selected double buffer.
- the reader 15 or writer 17 sets the shared index 26 to an initial value for the first double buffer 28 and the second double buffer 30 .
- the shared index 26 may identify, for each double buffer, one of the first low level buffer 32 , 36 , the second low level buffer 34 , 38 , or the initial value.
- the shared index 26 may take the form of a two element array, the first element of the array may correspond to the first double buffer 28 and the second element of the array may correspond to the second double buffer 30 (i.e., the shared index 26 may take the form [first double buffer 28 , second double buffer 30 ]).
- the shared index 26 may correspond to [0,0].
- the shared index 26 identifies the second low level buffer 34 for the first double buffer 28 and the first low level buffer 36 for the second double buffer 30 . That is, for the shared index 26 , a value of one may correspond to the first low level buffer 32 , 36 and a value of two may correspond to the second low level buffer 34 , 38 .
- the shared index 26 may identify the low level buffer of the selected double buffer to which data was last written. Both the reader 15 and the writer 17 use the shared index 26 to determine which low level buffer of the selected double buffer to respectively read and write data. As the writer 17 writes data to the selected double buffer, the writer 17 may update the shared index 26 to identify the low level buffer of the selected double buffer to which data was written. Thus, if the shared index 26 has a value of zero (i.e., the initial value), then the writer 17 has not written data to the selected double buffer, because, if the writer 17 had written data to the selected double buffer, the shared index 26 would have been updated to identify the low level buffer of the selected double buffer to which data was written.
- decision blocks 104 and 108 may occur simultaneously. That is, the reader 15 may read data at the same time as the writer 17 writes data.
- decision block 104 a check is performed to determine if data is to be written. If data is to be written, then, in process block 106 , the writer 17 writes data. For example, the writer 17 may store data in the low level buffer of the selected double buffer that is most convenient.
- decision block 108 a check is performed to determine if there data is to be read. If data is to be read, then, in process block 110 , the reader 15 reads data.
- reading data by the reader 15 is further described.
- the reader 15 reads the transmit index 24 to identify the selected double buffer.
- the reader 15 reads the shared index 26 for the selected double buffer.
- decision block 134 new data has been written to the selected double buffer if the shared index 26 for the selected double buffer does not correspond to the initial value. If the shared index 26 for the selected double buffer does not correspond to the initial value, the method progresses to process block 140 of FIG. 6 b.
- the reader 15 initializes the non-selected double buffer, i.e., the reader 15 may set the shared index 26 for the non-selected double buffer to the initial value.
- the reader 15 updates the transmit index 24 to identify the non-selected double buffer such that the non-selected double buffer is now the selected double buffer and the selected double buffer is now the non-selected double buffer (i.e., the previously selected double buffer).
- the writer 17 will now write data to the newly selected double buffer.
- the reader 15 determines if new data has been written to the previously selected double buffer in the time since decision block 132 .
- the reader 15 again reads the shared index 26 for the previously selected double buffer (identifying the low level buffer of the previously selected double buffer to which data was last written).
- the reader 15 would have incorrectly read the old data stored in the low level buffer identified by the shared index 26 in step 132 .
- the reader 15 will correctly read the last data written by the writer 17 to the previously selected double buffer.
- the reader 15 sets the read index 22 for the previously selected double buffer in the shared memory 20 to identify the low level buffer identified by the shared index 26 for the previously selected double buffer.
- the read index 22 indicates the low level buffer identified by the shared index 26 for the given double buffer from which the reader 15 last accessed data.
- the read index 22 may take the form of a two element array, the first element of the array corresponding to the first double buffer 28 and the second element of the array corresponding to the second double buffer 30 (i.e., the read index 22 may take the form [first double buffer 28 , second double buffer 30 ]).
- the read index 22 corresponds to [0,0]. If the reader 15 reads from the second low level buffer 34 of the first double buffer 28 , the read index 22 may be updated to correspond to [2,0], indicating, for the first double buffer 28 , the reader 15 last read data from the second low level buffer 34 .
- the reader 15 accesses and outputs the last data written to the previously selected double buffer.
- the reader 15 accesses (i.e., reads) the data stored in the low level buffer identified by the shared index 26 of the previously selected double buffer.
- the reader 15 outputs the data.
- the reader 15 optionally outputs the status new data.
- the method progresses to process block 160 of FIG. 6 c .
- the reader 15 determines if old data or new data was written to the non-selected double buffer.
- the reader 15 reads the shared index 26 for the non-selected double buffer.
- the reader 15 determines if the shared index of the non-selected double buffer corresponds to the initial value. The non-selected double buffer does not contain old data or new data if the shared index for the non-selected double buffer corresponds to the initial value.
- decision block 162 if the shared index 26 of the non-selected double buffer corresponds to the initial value, then, in process block 164 , the reader 15 outputs no data. In process block 166 , the reader 15 optionally outputs the status no data.
- the reader 15 determines if old data or new data was written to the non-selected double buffer. Determining if old data or new data was written to the non-selected double buffer includes, in decision block 168 , the reader 15 comparing the shared index 26 for the non-selected double buffer and the read index 22 for the non-selected double buffer.
- the non-selected double buffer contains old data if the shared index 26 for the non-selected double buffer and the read index 22 for the non-selected double buffer correspond to the same low level buffer.
- the read index 22 indicates the low level buffer from which the reader 15 last read data and the shared index 26 indicates the low level buffer from which the writer 17 last wrote data
- the low level buffer that the writer 17 last wrote data to i.e., the shared index 26
- new data has not been written to the non-selected double buffer.
- the shared index 26 for the non-selected double buffer and the read index 22 for the non-selected double buffer do not correspond to the same low level buffer, then new data was written to the non-selected double buffer.
- the reader 15 accesses (i.e., reads) the data stored in the low level buffer identified by the shared index 26 of the non-selected double buffer. In process block 172 , the reader 15 outputs the data. In process block 174 , the reader 15 optionally outputs the status old data.
- the reader 15 sets the read index 22 for the non-selected double buffer to identify the low level buffer identified by the shared index 26 for the non-selected double buffer.
- the reader 15 accesses (i.e., reads) the data stored in the low level buffer identified by the shared index 26 of the non-selected double buffer.
- the reader 15 outputs the data.
- the reader 15 optionally outputs the status new data.
- the writer 17 writing data, e.g., to the selected double buffer in process block 106 of FIG. 5 is further described.
- the writer 17 reads the transmit index 24 to determine the selected double buffer.
- the writer 17 reads the shared index 26 for the selected double buffer. As described previously, the shared index 26 identifies the low level buffer to which data was last written.
- the writer 17 determines a next low level buffer for the selected double buffer. The next low level buffer identifies a low level buffer for the selected double buffer to which the writer 17 will write new data.
- the next low level buffer may correspond to the low level buffer for the selected double buffer not indicated by the shared index 26 for the selected double buffer. If the shared index 26 for the selected double buffer corresponds to the initial value, the next low level buffer may correspond to the first low level buffer for the selected double buffer.
- the writer 17 stores (i.e., writes) data in the next low level buffer for the selected double buffer.
- the writer 17 sets the shared index 26 for the selected double buffer to correspond to the next low level buffer.
- the transmit index 24 identifies the first double buffer 28 as the selected double buffer and the shared index 26 identifies the first low level buffer 32 of the first double buffer 28 .
- the writer 17 receives another write instruction, in process blocks 190 and 192 , the writer 17 reads the transmit index 24 and shared index 26 .
- the writer 17 determines the next low level buffer to which data will be written.
- the next low level buffer is determined to be the second low level buffer 32 of the first double buffer 28 .
- the writer 17 sets the shared index 26 for the first double buffer 28 (i.e., the selected double buffer) to correspond to the second low level buffer 32 (i.e., the next low level buffer).
- the writer 17 may alternate writing data between the first low level buffer 32 and the second low level buffer 34 of the selected double buffer (i.e., the first double buffer 28 ) until the reader 15 begins a read operation.
- process block 200 the reader 15 reads the shared index 26 for the selected double buffer.
- decision block 202 a check is performed to determine if the shared index 26 for the selected double buffer corresponds to the read index 22 for the selected double buffer. If the shared index 26 for the selected double buffer does not correspond to the read index 22 for the selected double buffer, new data has been written to the selected double buffer. If new data has been written to the selected double buffer, the method progresses to process block 204 .
- the reader 15 updates the transmit index 24 to identify the non-selected double buffer such that the non-selected double buffer is now the selected double buffer and the selected double buffer is now the non-selected double buffer (i.e., the previously selected double buffer).
- the reader 15 determines if new data has been written to the previously selected double buffer in the time since decision block 200 .
- the reader 15 again reads the shared index 26 for the previously selected double buffer (identifying the low level buffer of the previously selected double buffer to which data was last written).
- the reader 15 would have incorrectly read the old data stored in the low level buffer identified by the shared index 26 in step 200 .
- the reader 15 will correctly read the last data written by the writer 17 to the previously selected double buffer.
- the reader 15 sets the read index 22 for the previously selected double buffer in the shared memory 20 to identify the low level buffer identified by the shared index 26 for the previously selected double buffer.
- the read index 22 indicates the low level buffer identified by the shared index 26 for the given double buffer from which the reader 15 last accessed data.
- the reader 15 accesses and outputs the last data written to the previously selected double buffer.
- the reader 15 accesses (i.e., reads) the data stored in the low level buffer identified by the shared index 26 of the previously selected double buffer.
- the reader 15 outputs the data.
- the reader 15 optionally outputs the status new data.
- Determining if old data or new data was written to the non-selected double buffer includes, in process block 216 , the reader 15 reading the shared index 26 for the non-selected double buffer.
- decision block 230 FIG. 8 b
- the reader 15 compares the shared index 26 for the non-selected double buffer and the read index 22 for the non-selected double buffer.
- the non-selected double buffer contains old data if the shared index 26 for the non-selected double buffer and the read index 22 for the non-selected double buffer correspond to the same low level buffer.
- the read index 22 indicates the low level buffer from which the reader 15 last read data and the shared index 26 indicates the low level buffer from which the writer 17 last wrote data
- the low level buffer that the writer 17 last wrote data to i.e., the shared index 26
- new data has not been written to the non-selected double buffer.
- the shared index 26 for the non-selected double buffer and the read index 22 for the non-selected double buffer do not correspond to the same low level buffer, then new data was written to the non-selected double buffer.
- the reader 15 accesses (i.e., reads) the data stored in the low level buffer identified by the shared index 26 of the non-selected double buffer.
- the reader 15 outputs the data.
- the reader 15 optionally outputs the status old data.
- the writer 17 writing data to the selected double buffer in process block 106 of FIG. 5 is further described.
- the writer 17 reads the transmit index 24 .
- the value of the transmit index 24 (Tx) may be an integer between zero and three.
- the writer 17 determines a corrected transmit index 14 .
- the value of the corrected transmit index may be equal to Tx mod 2.
- the corrected transmit index having a value of zero may correspond to the selected double buffer being the first double buffer 28 and the corrected transmit index 24 having a value of one may correspond to the selected double buffer being the second double buffer 30 .
- the modulus operator e.g., mod
- mod may operate according to the modulus operator in the ADA95 language or the C language.
- the sign of the output of the modulus operator may be machine-dependent for negative operands.
- the modulus operator may operate as described in Kernighan Brian, W., and M. Ritchie Dennis, “The C programming language,” Second Edition, AT&T Bell laboratories, New Jersey, Prentice Hall (1988), the entire contents of which are incorporated by reference herein.
- the writer 17 reads the shared index 26 for the selected double buffer.
- the value of the shared index 26 (Sx) may be an integer between zero and four.
- the writer 17 determines a corrected shared index to determine the low level buffer of the selected buffer to which data was last written.
- the value of the corrected shared index may be equal to ((Sx ⁇ 1)mod 2)+1.
- the corrected shared index having a value of zero may correspond to the initial value
- the corrected shared index having a value of one may correspond to the first low level buffer
- the corrected shared index having a value of two may correspond to the second low level buffer.
- the writer 17 determines a next low level buffer for the selected double buffer.
- the next low level buffer may be determined such that, if the transmit index 24 equals zero or one, the value of the next low level buffer equals (Sx mod 2)+1. If the transmit index 24 equals two or three, the value of the next low level buffer may equal (Sx mod 2)+3.
- the writer 17 stores (i.e., writes) data in the next low level buffer for the selected double buffer.
- the writer 17 sets the value of the shared index 26 equal to the value of the next low level buffer.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Software Systems (AREA)
- Human Computer Interaction (AREA)
- Memory System (AREA)
Abstract
A method and system are presented for providing deterministic inter-core, inter-process, and inter-thread communication between a reader and a writer. The reader and writer communicate by passing data through a shared memory using double buffering of double buffers. The shared memory includes a first double buffer and a second double buffer. Both double buffers include a first low level buffer and a second low level buffer. Using double buffering of the double buffers, both the reader and the writer may simultaneously access the shared memory.
Description
- The present invention relates generally to multi-core computer systems, and particularly to methods for communicating and sharing data between cores, processes, or threads.
- The need for more powerful processing platforms in the avionics industry and the availability of multi-core devices has resulted in the development of avionics processing platforms utilizing multi-core devices. However, before multi-core devices can be utilized in avionics processing platforms, testing should be performed to ensure that the operation of each multi-core device complies with required regulations. For example, it may be a requirement that a display is updated every 50 ms. Before a multi-core device can be utilized, it should be shown to comply with this requirement.
- In order to ensure that a multi-core device complies with required regulations, multi-core devices should be able to pass data between cores, processes and threads in a wait-free manner. There should also be no interference between applications running on the multi-core device. That is, each application should be partitioned in memory and time space, such that memory and timing are not affected by the execution of other applications.
- Current deterministic solutions for multi-core communication can be divided into blocking and non-blocking algorithms. Blocking algorithms are non-ideal, as threads/cores compete for shared resources and, due to mutual exclusion, can have their execution postponed indefinitely. Current, conventional non-blocking algorithms predominately use atomic read-modify-write primitives that should be provided by the underlying hardware components. Additionally, non-blocking algorithms may require a writer to wait for a reader to complete reading data from a shared resource before the writer is permitted to write data to the shared resource. That is, current non-blocking algorithms may not allow a reader to simultaneously read data from a shared resource as a writer writes data to the shared resource.
- A system and method is proposed for providing deterministic inter-core, inter-process, and inter-thread communication between a reader and a writer by passing data through shared memory using double buffering of double buffers. A system and method according to the invention enables one or more advantages to be obtained, including allowing, in a deterministic manner, a reader to simultaneously read data from a shared resource as a writer writes data to the shared resource.
- According to one aspect of the disclosure, a method for providing deterministic inter-core, inter-process, and inter-thread communication between a reader and a writer by passing data through shared memory using double buffering of double buffers includes the reader or writer selecting one of a first double buffer or a second double buffer as a selected double buffer. The writer writes data to the selected double buffer, each double buffer is stored in the shared memory, and each double buffer includes a first low level buffer and a second low level buffer. The method additionally includes the reader reading data. Reading data includes the reader determining if new data has been written to the selected double buffer. New data corresponds to data that has not been read by the reader. If new data has been written to the selected double buffer, the reader selects the non-selected double buffer as the selected double buffer such that the writer writes data to the newly selected double buffer. If new data has been written to the selected double buffer the reader also determines if new data has been written to the previously selected double buffer in the time since the previous check to determine if new data had been written to the previously selected double buffer. If new data has been written to the selected double buffer, the reader accesses and outputs the last data written to the previously selected double buffer. If new data has not been written to the selected double buffer, the reader determines if old data or new data was written to the non-selected double buffer. Old data corresponds to data that the reader has previously read. If neither old data nor new data was written to the non-selected double buffer, no data is output by the reader. If old data or new data was written to the non-selected double buffer, the reader accesses and outputs the last data written to the non-selected double buffer.
- Alternatively or additionally, the writer writing data to the selected double buffer may include the writer storing data in the low level buffer of the selected double buffer that is most convenient.
- Alternatively or additionally, the reader may read data at the same time as the writer writes data to the selected double buffer.
- Alternatively or additionally, the reader may output a state. For example, the reader may output a new data state when new data has been written to the selected double buffer. The reader may output the new data state when new data has not been written to the selected double buffer and new data has been written to the non-selected double buffer. The reader may output an old data state when new data has not been written to both the selected double buffer and the non-selected double buffer and the non-selected double buffer contains old data. The reader may output a no data state when new data has not been written to both the selected double buffer and the non-selected double buffer and the non-selected double buffer does not contain old data.
- Alternatively or additionally, the reader or writer selecting one of the first double buffer or the second double buffer as the selected double buffer may include the reader setting a transmit index in the shared memory to identify the first double buffer or the second double buffer. The double buffer identified by the transmit index may correspond to the selected double buffer and the double buffer not identified by the transmit index may correspond to an non-selected double buffer.
- Alternatively or additionally, the reader or writer may initialize both double buffers to an initial state prior to the reader reading data.
- Alternatively or additionally, initializing both double buffers to an initial state may include the reader or writer setting a shared index in the shared memory to an initial value for the first double buffer and the second double buffer. The shared index may identify one of the first low level buffer, the second low level buffer, or the initial value for each double buffer.
- Alternatively or additionally, the reader determining if new data has been written to the selected double buffer may include the reader reading the transmit index to identify the selected double buffer and the reader reading the shared index for the selected double buffer. New data may have been written to the selected double buffer if the shared index for the selected double buffer does not correspond to the initial value.
- Alternatively or additionally, the reader determining if new data has been written to the selected double buffer may include the reader reading the transmit index to identify the selected double buffer, the reader reading the shared index for the selected double buffer, and the reader reading a read index for the selected double buffer. The read index for a given double buffer may indicate the low level buffer identified by the shared index for the given double buffer from which the reader last accessed data. New data may have been written to the selected double buffer if the shared index for the selected double buffer does not correspond to the read index for the selected double buffer and the shared index for the selected double buffer does not correspond to the initial value.
- Alternatively or additionally, if new data has been written to the selected double buffer, the reader may initialize the non-selected double buffer before the reader selects the non-selected double buffer as the selected double buffer.
- Alternatively or additionally, the reader initializing the non-selected double buffer may include the reader setting the shared index for the non-selected double buffer to the initial value.
- Alternatively or additionally, the reader selecting the non-selected double buffer as the selected double buffer may include the reader updating the transmit index to identify the non-selected double buffer such that the non-selected double buffer is now the selected double buffer and the selected double buffer is now the non-selected double buffer.
- The reader determining if new data has been written to the previously selected double buffer in the time since the previous check may include the reader reading the shared index for the previously selected double buffer and the reader setting a read index for the previously selected double buffer in the shared memory to identify the low level buffer identified by the shared index for the non-selected double buffer.
- Alternatively or additionally, the reader accessing and outputting the last data written to the previously selected double buffer may include the reader accessing the data stored in the low level buffer identified by the shared index of the previously selected double buffer and the reader outputting the data.
- Alternatively or additionally, determining if old data or new data was written to the non-selected double buffer may include the reader reading the shared index for the non-selected double buffer. The non-selected double buffer may not contain old data or new data if the shared index for the non-selected double buffer corresponds to the initial value.
- Alternatively or additionally, determining if old data or new data was written to the non-selected double buffer may include, if the shared index for the non-selected double buffer does not correspond to the initial value, the reader comparing the shared index for the non-selected double buffer and the read index for the non-selected double buffer. The non-selected double buffer may contain old data if the shared index for the non-selected double buffer and the read index for the non-selected double buffer correspond to the same low level buffer.
- Alternatively or additionally, if the shared index for the non-selected double buffer and the read index for the non-selected double buffer do not correspond to the same low level buffer, new data may have been written to the non-selected double buffer and the reader setting the read index for the non-selected double buffer may identify the low level buffer identified by the shared index for the non-selected double buffer.
- Alternatively or additionally, the reader accessing and outputting the last data written to the non-selected double buffer may include the reader accessing the data stored in the low level buffer identified by the shared index of the non-selected double buffer and the reader outputting the data.
- Alternatively or additionally, the writer writing data to the selected double buffer may include the writer reading the shared index for the selected double buffer, the writer storing data in a next low level buffer for the selected double buffer, and the writer setting the shared index for the selected double buffer to correspond to the next low level buffer. The next low level buffer may corresponds to the low level buffer for the selected double buffer not indicated by the shared index for the selected double buffer if the shared index corresponds to the first low level buffer or the second low level buffer. The next low level buffer may correspond to the first low level buffer for the selected double buffer if the shared index for the selected double buffer corresponds to the initial value.
- Alternatively or additionally, the writer setting the shared index for the selected double buffer to correspond to the next low level buffer may include reading a value of the transmit index (Tx) and determining a corrected transmit index. The transmit index value may be an integer between zero and three. A value of the corrected transmit index may be equal to
Tx mod 2. The corrected transmit index having a value of zero may correspond to the selected double buffer being the first double buffer. The corrected transmit index having a value of one may correspond to the selected double buffer being the second double buffer. The writer setting the shared index for the selected double buffer to correspond to the next low level buffer may additionally include reading a value of the shared index (Sx) and determining a corrected shared index. The shared index value may be an integer between zero and four. A value of the corrected shared index may be equal to ((Sx−1)mod 2)+1. The corrected shared index having a value of zero may correspond to the initial value. The corrected shared index having a value of one may correspond to the first low level buffer. The corrected shared index having a value of two may correspond to the second low level buffer. The writer setting the shared index for the selected double buffer to correspond to the next low level buffer may also include determining a value of the next low level buffer and setting the value of the shared index equal to the value of the next low level buffer. The value of the next low level buffer may equal (Sx mod 2)+1 if the transmit index equal zero or one. The value of the next low level buffer may equal (Sx mod 2)+3 if the transmit index equal two or three. - Alternatively or additionally, a computational device may include a multicore processor and a shared memory. The multicore processor may carry out the method for providing deterministic inter-core, inter-process, and inter-thread communication between a reader and a writer by passing data through shared memory using double buffering of double buffers.
- Alternatively or additionally, a non-transitory computer-readable storage medium may store logical instructions thereon that when executed by a processor perform the steps of the method for providing deterministic inter-core, inter-process, and inter-thread communication between a reader and a writer by passing data through shared memory using double buffering of double buffers.
- The foregoing and other features of the invention are hereinafter fully described and particularly pointed out in the claims, the following description and annexed drawings setting forth in detail certain illustrative embodiments of the invention, these embodiments being indicative, however, of but a few of the various ways in which the principles of the invention may be employed.
- Features that are described and/or illustrated with respect to one embodiment may be used in the same way or in a similar way in one or more other embodiments and/or in combination with or instead of the features of the other embodiments.
-
FIG. 1 is a block diagram illustrating an exemplary multi-core computational device. -
FIG. 2 is a block diagram illustrating a method for providing deterministic inter-core, inter-process, and inter-thread communication between a reader and a writer; -
FIGS. 3 a-3 c are block diagrams illustrating steps for reading data by the reader; -
FIG. 4 is a block diagram illustrating steps for writing data by the writer; -
FIG. 5 is a block diagram of another embodiment of the method for providing deterministic inter-core, inter-process, and inter-thread communication between a reader and a writer; -
FIGS. 6 a-6 c are block diagrams illustrating steps for reading data by the reader; -
FIG. 7 is a block diagram illustrating steps for writing data by the writer; -
FIGS. 8 a-8 b are block diagrams illustrating steps for reading data by the reader; and -
FIG. 9 is a block diagram illustrating steps for writing data by the writer. - The present invention provides a system and method for providing deterministic inter-core, inter-process, and inter-thread communication between a reader and a writer. The reader and writer communicate by passing data through a shared memory using double buffering of double buffers. The shared memory includes a first double buffer and a second double buffer. Both double buffers include a first low level buffer and a second low level buffer. Using double buffering of the double buffers, both the reader and the writer may simultaneously access (i.e., read and/or write data to) the shared memory.
- Turning initially to
FIG. 1 , an exemplary multi-corecomputational device 10 is shown. The multi-corecomputational device 10 includes amulti-core processor 12 and a non-transitory computer-readable storage medium 18. Themulti-core processor 12 includes afirst core 14 having areader 15 and asecond core 16 having awriter 17. Thereader 15 andwriter 17 may have read-write access to a sharedmemory 20 included in thestorage medium 18. The sharedmemory 20 includes aread index 22, a transmitindex 24, a sharedindex 26, a firstdouble buffer 28, and a seconddouble buffer 30. The firstdouble buffer 28 has a first low level buffer 32 and a second low level buffer 34. The seconddouble buffer 30 has a firstlow level buffer 36 and a secondlow level buffer 38. - As will be understood by one of ordinary skill in the art, the
processor 12 may have various implementations. For example, theprocessor 12 may include a central processing unit (CPU) or any other suitable multi-core device, such as a programmable circuit, integrated circuit, memory and I/O circuits, an application specific integrated circuit, microcontroller, complex programmable logic device, other programmable circuits, or the like. Theprocessor 12 may also include a non-transitory computer readable memory, such as a CPU cache, computational random access memory (RAM), RAM, or any other suitable memory. Instructions for performing the method described below may be stored in the non-transitory computer readable memory and executed by the processor. - The
reader 15 andwriter 17 may communicate by passing data through the sharedmemory 20. Data may be passed through the sharedmemory 20 by thewriter 17 storing (i.e., writing) data in and thereader 15 accessing (i.e., reading) the data stored in the firstdouble buffer 28 and/or the seconddouble buffer 30. That is, thewriter 17 writes data to the first low level buffer 32 of the firstdouble buffer 28, the second low level buffer 34 of the firstdouble buffer 28, the firstlow level buffer 36 of the seconddouble buffer 30, and/or the secondlow level buffer 38 of the seconddouble buffer 30. When thereader 15 reads data form the sharedmemory 20, thereader 15 may read the last data written by thewriter 17. For example, thewriter 17 may write data three times prior to thereader 15 reading data. When thereader 15 reads data, thereader 15 will only read the last data written by the writer 17 (i.e., thereader 15 will not read the data written in the previous two write operations performed by the writer 17). - In order to determine which
double buffer writer 17 reads the transmitindex 24 to determine a selected double buffer. That is, the selected double buffer may identify either the firstdouble buffers 28 or the seconddouble buffer 30. In order to determine whichlow level buffer writer 17 reads the sharedindex 26. That is, the sharedindex 26 may identify the firstlow level buffer 32, 36 or the secondlow level buffer 34, 38 of the selected double buffer. The sharedindex 26 may identify, for a given double buffer 32, 34, the low level buffer to which data was last written. Similarly, thereader 15 also reads the transmitindex 24 to determine the selected double buffer for reading data and the sharedindex 26 to determine whichlow level buffer - Accordingly, the
reader 15 may have read-write access to theread index 22 and the transmitindex 24. Thereader 15 may have read only access to the first double buffer 32 and the second double buffer 34. Thereader 15 may also have read-write access or read only access to the sharedindex 26. Thewriter 17 may have read-write access to the sharedindex 26, the first double buffer 32, and the second double buffer 34. Thewriter 17 may have read only access to the transmitindex 24. - The read and write operations should be atomic, i.e. performed without interrupt. That is, as implemented, the
processor 12 and the sharedmemory 20 should be configured such that access to the transmitindex 24 and the sharedindex 26 occurs atomically. - As will be understood by one of ordinary skill in the art, the
storage medium 18 may include a non-transitory computer readable medium, such as random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), or any other suitable medium. Instructions for performing the method described below may be stored in the non-transitory computer readable medium and executed by the processor. - With reference to
FIG. 2 , a block diagram depicting a method for providing deterministic inter-core, inter-process, and inter-thread communication between areader 15 and awriter 17 is shown. In process block 50 a double buffer is selected for storing data. That is, thereader 15 orwriter 17, e.g., may select either the firstdouble buffer 28 or the seconddouble buffer 30 as the selected double buffer. Inprocess block 52, both the firstdouble buffer 28 and the seconddouble buffer 30 are initialized. Thereader 15, prior to reading data, may perform initialization of thedouble buffers - Following
process block 52, decision blocks 54 and 58 may occur simultaneously. That is, thereader 15 may read data at the same time as thewriter 17 writes data. Indecision block 54, a check is performed to determine if data is to be written. If data is to be written, then, inprocess block 56, thewriter 17 writes data. For example, thewriter 17 may store data in the low level buffer of the selected double buffer that is most convenient. Indecision block 58, a check is performed to determine if there data is to be read. If data is to be read, then, inprocess block 60, thereader 15 reads data. - Turning to
FIG. 3 a, reading data by thereader 15 is further described. Indecision block 62, a check is performed to determine if new data has been written to the selected double buffer. New data is data that has not previously been read by thereader 15. Inblock 64, if new data has been written to the selected double buffer, thereader 15 may, e.g., initialize the non-selected double buffer. Initializing adouble buffer FIG. 5 . Next, inprocess block 66, thereader 15, e.g., selects the non-selected double buffer as the selected double buffer, such that thewriter 17 will now write data to the newly selected double buffer. - In
process block 68, thereader 15 determines if new data has been written to the previously selected double buffer in the time since the previous check (i.e., process block 62). Inprocess block 70, thereader 15 reads and outputs the last data written to the previously selected double buffer. Inprocess block 72, thereader 15 optionally outputs a status of new data (i.e., when new data has been written to the selected double buffer). - The following example is provided to demonstrate the operation of
FIG. 3 a. In this example, thereader 15 has received an instruction to read the last data written to the sharedmemory 20. Assume, at thetime block 62 is performed, the selected double buffer is the firstdouble buffer 28 and thewriter 17 has previously written data to the first low level buffer 32 of the selected double buffer, but data has not been written to the second low level buffer 34. Followingdecision block 62, because data has been written to the selected double buffer,process block 64 is performed. Inprocess block 64, the non-selected double buffer (i.e., the second double buffer 30) is initialized. Inprocess block 66, the second double buffer 30 (i.e., the non-selected double buffer) is selected as the selected double buffer. Now, followingprocess block 66, if thewriter 17 writes new data to the sharedmemory 20, thewriter 17 will write data to the newly selected double buffer, not the double buffer from which thereader 15 is reading data (i.e., the previously selected double buffer). - Continuing the example, in
process block 68, thereader 15 determines if new data has been written to the previously selected double buffer (i.e., the first double buffer 28) sinceprocess block 62. As stated above, at thetime process block 62 was performed, data had been written to the first low level buffer 32 of the firstdouble buffer 28, but no data had been written to the second low level buffer 34. However, during operation ofblocks writer 17 wrote new data to the second low level buffer 34 of the first double buffer 32 (i.e., the selected double buffer at the time). Ifprocess block 68 is not performed (i.e., thereader 15 does not check if new data has been written to the previously selected double buffer during operation ofsteps 64 and 66), then thereader 15 may incorrectly read old data (in this example the data stored in the first low level buffer 32) and miss the new data that was written to the sharedmemory 20 during operation ofblocks 62 and 64 (in this example the data stored in the second low level buffer 34). The reading of old data as opposed to the new data may make the method non-deterministic and cause errors. - Returning to
FIGS. 3 a and 3 b, if new data has not been written to the selected double buffer, thendecision block 80 ofFIG. 3 b is performed. Indecision block 80, thereader 15 determines if old data or new data was written to the non-selected double buffer. Old data corresponds to data that thereader 15 has previously read. If neither old data nor new data was written to the non-selected double buffer, then, inprocess block 82, no data is output by thereader 15. Following process block 82 (i.e., when new data has not been written to both the selected double buffer and the non-selected double buffer does not contain old data), inprocess block 84, a status no data may optionally be output. - In
process block 86, if old data or new data was written to the non-selected double buffer, thereader 15 accesses and outputs the last data written to the non-selected double buffer. Accessing and outputting the last data written to the non-selected double buffer inprocess block 86 is further described inFIG. 3 c. - With reference to
FIG. 3 c,decision block 87 determines if new data been written to the sharedmemory 20 since data was last read from the non-selected double buffer. If new data has been written, then, inprocess block 88, thereader 15 reads and outputs the new data. In process block 90 (i.e., when new data has not been written to the selected double buffer and new data has been written to the non-selected double buffer), thereader 15 optionally outputs the status new data. If new data has not been written, then, inprocess block 92, thereader 15 outputs the old data that was last written to the non-selected double buffer. In process block 94 (i.e., when new data has not been written to both the selected double buffer and the non-selected double buffer and the non-selected double buffer contains old data), thereader 15 may optional output the status old data. - Turning to
FIG. 4 , thewriter 17 writing data inprocess block 56 ofFIG. 2 is further described. Indecision block 95, thewriter 17 determines if data has been written to the selected double buffer. If data has not been written to the selected double buffer, then, inprocess block 96 thewriter 17 writes data to either of the low level buffers of the selected double buffer. For example, thewriter 17 may write data to the low level buffer of the selected double buffer that is most convenient. The most convenient low level buffer may comprise the first low level buffer, the second low level buffer, the last low level buffer to which data was written, the low level buffer that data was not written to last, the low level buffer with the shortest access time, or any other suitable criteria for selecting the most convenient low level buffer. If data has been written to the selected double buffer, then, inprocess block 98, thewriter 17 writes data to the low level buffer of the selected double buffer that does not contain data or that contains the oldest data. - With reference to
FIG. 5 , a block diagram depicting an alternative embodiment of the method for providing deterministic inter-core, inter-process, and inter-thread communication between thereader 15 and thewriter 17 is shown. Inprocess block 102, thereader 15 sets the transmitindex 24 to identify either the firstdouble buffer 28 or the seconddouble buffer 30. Thedouble buffer index 24 corresponds to the selected double buffer. The double buffer not identified by the transmit index corresponds to an non-selected double buffer. For example, if the transmitindex 24 contains the value zero, the firstdouble buffer 28 may be the selected double buffer and the seconddouble buffer 30 may be the non-selected double buffer. Alternatively, if the transmitindex 24 contains the value one, the seconddouble buffer 30 may be the selected double buffer and the firstdouble buffer 28 may be the non-selected double buffer. - In
process block 103, thereader 15 orwriter 17 sets the sharedindex 26 to an initial value for the firstdouble buffer 28 and the seconddouble buffer 30. The sharedindex 26 may identify, for each double buffer, one of the firstlow level buffer 32, 36, the secondlow level buffer 34, 38, or the initial value. For example, the sharedindex 26 may take the form of a two element array, the first element of the array may correspond to the firstdouble buffer 28 and the second element of the array may correspond to the second double buffer 30 (i.e., the sharedindex 26 may take the form [firstdouble buffer 28, second double buffer 30]). In this example, upon initialization, the sharedindex 26 may correspond to [0,0]. If, e.g., the sharedindex 26 corresponds to [2,1], then the sharedindex 26 identifies the second low level buffer 34 for the firstdouble buffer 28 and the firstlow level buffer 36 for the seconddouble buffer 30. That is, for the sharedindex 26, a value of one may correspond to the firstlow level buffer 32, 36 and a value of two may correspond to the secondlow level buffer 34, 38. - As described above and in further detail in
FIG. 7 , the sharedindex 26 may identify the low level buffer of the selected double buffer to which data was last written. Both thereader 15 and thewriter 17 use the sharedindex 26 to determine which low level buffer of the selected double buffer to respectively read and write data. As thewriter 17 writes data to the selected double buffer, thewriter 17 may update the sharedindex 26 to identify the low level buffer of the selected double buffer to which data was written. Thus, if the sharedindex 26 has a value of zero (i.e., the initial value), then thewriter 17 has not written data to the selected double buffer, because, if thewriter 17 had written data to the selected double buffer, the sharedindex 26 would have been updated to identify the low level buffer of the selected double buffer to which data was written. - Returning to
FIG. 5 , followingprocess block 103, decision blocks 104 and 108 may occur simultaneously. That is, thereader 15 may read data at the same time as thewriter 17 writes data. Indecision block 104, a check is performed to determine if data is to be written. If data is to be written, then, inprocess block 106, thewriter 17 writes data. For example, thewriter 17 may store data in the low level buffer of the selected double buffer that is most convenient. Indecision block 108, a check is performed to determine if there data is to be read. If data is to be read, then, inprocess block 110, thereader 15 reads data. - Turning to
FIGS. 6 a-6 c, reading data by thereader 15 is further described. Inprocess block 130, thereader 15 reads the transmitindex 24 to identify the selected double buffer. Next, inprocess block 132, thereader 15 reads the sharedindex 26 for the selected double buffer. Indecision block 134, new data has been written to the selected double buffer if the sharedindex 26 for the selected double buffer does not correspond to the initial value. If the sharedindex 26 for the selected double buffer does not correspond to the initial value, the method progresses to process block 140 ofFIG. 6 b. - With reference to
FIG. 6 b, inprocess block 140, thereader 15 initializes the non-selected double buffer, i.e., thereader 15 may set the sharedindex 26 for the non-selected double buffer to the initial value. Inprocess block 142, thereader 15 updates the transmitindex 24 to identify the non-selected double buffer such that the non-selected double buffer is now the selected double buffer and the selected double buffer is now the non-selected double buffer (i.e., the previously selected double buffer). Thus, thewriter 17 will now write data to the newly selected double buffer. - In
process block 144, thereader 15 determines if new data has been written to the previously selected double buffer in the time sincedecision block 132. Inprocess block 144, thereader 15 again reads the sharedindex 26 for the previously selected double buffer (identifying the low level buffer of the previously selected double buffer to which data was last written). Thus, withoutstep 144, if thewriter 17 had written data to the previously selected double buffer during operation ofsteps reader 15 would have incorrectly read the old data stored in the low level buffer identified by the sharedindex 26 instep 132. However, by again reading the sharedindex 26 instep 144, thereader 15 will correctly read the last data written by thewriter 17 to the previously selected double buffer. - In
process block 146, thereader 15 sets theread index 22 for the previously selected double buffer in the sharedmemory 20 to identify the low level buffer identified by the sharedindex 26 for the previously selected double buffer. Theread index 22, for a given double buffer, indicates the low level buffer identified by the sharedindex 26 for the given double buffer from which thereader 15 last accessed data. For example, theread index 22 may take the form of a two element array, the first element of the array corresponding to the firstdouble buffer 28 and the second element of the array corresponding to the second double buffer 30 (i.e., theread index 22 may take the form [firstdouble buffer 28, second double buffer 30]). In this example, assuming thereader 15 has not yet read data from the sharedmemory 20, theread index 22 corresponds to [0,0]. If thereader 15 reads from the second low level buffer 34 of the firstdouble buffer 28, theread index 22 may be updated to correspond to [2,0], indicating, for the firstdouble buffer 28, thereader 15 last read data from the second low level buffer 34. - In the combination of process blocks 148 and 150, the
reader 15 accesses and outputs the last data written to the previously selected double buffer. Inprocess block 148, thereader 15 accesses (i.e., reads) the data stored in the low level buffer identified by the sharedindex 26 of the previously selected double buffer. Inprocess block 150, thereader 15 outputs the data. Inprocess block 152, thereader 15 optionally outputs the status new data. - Turning to
FIGS. 6 a and 6 c, indecision block 134 ofFIG. 6 a, if the sharedindex 26 for the selected double buffer corresponds to the initial value, the method progresses to process block 160 ofFIG. 6 c. In the combination ofblocks reader 15 determines if old data or new data was written to the non-selected double buffer. Inprocess block 160, thereader 15 reads the sharedindex 26 for the non-selected double buffer. Indecision block 162, thereader 15 determines if the shared index of the non-selected double buffer corresponds to the initial value. The non-selected double buffer does not contain old data or new data if the shared index for the non-selected double buffer corresponds to the initial value. - In
decision block 162, if the sharedindex 26 of the non-selected double buffer corresponds to the initial value, then, inprocess block 164, thereader 15 outputs no data. Inprocess block 166, thereader 15 optionally outputs the status no data. - Alternatively, in
decision block 162, if the sharedindex 26 of the non-selected double buffer does not correspond to the initial value (indicating data has been written to the non-selected double buffer), thereader 15 determines if old data or new data was written to the non-selected double buffer. Determining if old data or new data was written to the non-selected double buffer includes, indecision block 168, thereader 15 comparing the sharedindex 26 for the non-selected double buffer and theread index 22 for the non-selected double buffer. The non-selected double buffer contains old data if the sharedindex 26 for the non-selected double buffer and theread index 22 for the non-selected double buffer correspond to the same low level buffer. That is, because theread index 22 indicates the low level buffer from which thereader 15 last read data and the sharedindex 26 indicates the low level buffer from which thewriter 17 last wrote data, if the low level buffer that thewriter 17 last wrote data to (i.e., the shared index 26) is the same as the low level buffer that thereader 15 last read data from (i.e., the read index 22), then new data has not been written to the non-selected double buffer. Alternatively, if the sharedindex 26 for the non-selected double buffer and theread index 22 for the non-selected double buffer do not correspond to the same low level buffer, then new data was written to the non-selected double buffer. - In
process block 170, if the sharedindex 26 for the non-selected double buffer and theread index 22 for the non-selected double buffer correspond to the same low level buffer, thereader 15 accesses (i.e., reads) the data stored in the low level buffer identified by the sharedindex 26 of the non-selected double buffer. Inprocess block 172, thereader 15 outputs the data. Inprocess block 174, thereader 15 optionally outputs the status old data. - In
process block 176, if the sharedindex 26 for the non-selected double buffer and theread index 22 for the non-selected double buffer do not correspond to the same low level buffer, thereader 15 sets theread index 22 for the non-selected double buffer to identify the low level buffer identified by the sharedindex 26 for the non-selected double buffer. Inprocess block 178, thereader 15 accesses (i.e., reads) the data stored in the low level buffer identified by the sharedindex 26 of the non-selected double buffer. Inprocess block 180, thereader 15 outputs the data. Inprocess block 182, thereader 15 optionally outputs the status new data. - Turning to
FIG. 7 , thewriter 17 writing data, e.g., to the selected double buffer in process block 106 ofFIG. 5 is further described. Inprocess block 190, thewriter 17 reads the transmitindex 24 to determine the selected double buffer. Inprocess block 192, thewriter 17 reads the sharedindex 26 for the selected double buffer. As described previously, the sharedindex 26 identifies the low level buffer to which data was last written. Inprocess block 194, thewriter 17 determines a next low level buffer for the selected double buffer. The next low level buffer identifies a low level buffer for the selected double buffer to which thewriter 17 will write new data. If the sharedindex 26 corresponds to the first low level buffer or the second low level buffer, the next low level buffer may correspond to the low level buffer for the selected double buffer not indicated by the sharedindex 26 for the selected double buffer. If the sharedindex 26 for the selected double buffer corresponds to the initial value, the next low level buffer may correspond to the first low level buffer for the selected double buffer. Inprocess block 196, thewriter 17 stores (i.e., writes) data in the next low level buffer for the selected double buffer. Inprocess block 198, thewriter 17 sets the sharedindex 26 for the selected double buffer to correspond to the next low level buffer. - The following example is provided to demonstrate the operation of
FIG. 7 . In this example, assume the selected double buffer is the firstdouble buffer 28 and that thewriter 17 has written data to the first low level buffer 32 since thereader 15 last read data. Thus, in this example, the transmitindex 24 identifies the firstdouble buffer 28 as the selected double buffer and the sharedindex 26 identifies the first low level buffer 32 of the firstdouble buffer 28. Assuming thewriter 17 receives another write instruction, in process blocks 190 and 192, thewriter 17 reads the transmitindex 24 and sharedindex 26. Prior to writing data, inprocess block 194, thewriter 17 determines the next low level buffer to which data will be written. In this example, because data was last written to the first low level buffer 32 of the firstdouble buffer 28, the next low level buffer is determined to be the second low level buffer 32 of the firstdouble buffer 28. After writing the data to the next low level buffer inprocess block 196, thewriter 17 sets the sharedindex 26 for the first double buffer 28 (i.e., the selected double buffer) to correspond to the second low level buffer 32 (i.e., the next low level buffer). - In this example, if further write instructions are received, the
writer 17 may alternate writing data between the first low level buffer 32 and the second low level buffer 34 of the selected double buffer (i.e., the first double buffer 28) until thereader 15 begins a read operation. - Turning to
FIGS. 6 a, 8 a, and 8 b, in an alternative embodiment, in decision block 134 (FIG. 6 a), if the sharedindex 26 for the selected double buffer does not correspond to the initial value, the method may progress to process block 200 (FIG. 8 a). In this embodiment, thereader 15 may have only read access to the sharedindex 26. Thus, as opposed to the processes described inFIGS. 6 b and 6 c, followingdecision block 134, thereader 15 does not set the sharedindex 26 for eitherdouble buffer reader 15 andwriter 17 attempting to write to the sharedindex 26 at the same time. - In
process block 200, thereader 15 reads the sharedindex 26 for the selected double buffer. Indecision block 202, a check is performed to determine if the sharedindex 26 for the selected double buffer corresponds to theread index 22 for the selected double buffer. If the sharedindex 26 for the selected double buffer does not correspond to theread index 22 for the selected double buffer, new data has been written to the selected double buffer. If new data has been written to the selected double buffer, the method progresses to process block 204. - In
process block 204, thereader 15 updates the transmitindex 24 to identify the non-selected double buffer such that the non-selected double buffer is now the selected double buffer and the selected double buffer is now the non-selected double buffer (i.e., the previously selected double buffer). - In
process block 206, thereader 15 determines if new data has been written to the previously selected double buffer in the time sincedecision block 200. Inprocess block 206, thereader 15 again reads the sharedindex 26 for the previously selected double buffer (identifying the low level buffer of the previously selected double buffer to which data was last written). Thus, withoutstep 206, if thewriter 17 had written data to the previously selected double buffer during operation ofsteps reader 15 would have incorrectly read the old data stored in the low level buffer identified by the sharedindex 26 instep 200. However, by again reading the sharedindex 26 instep 206, thereader 15 will correctly read the last data written by thewriter 17 to the previously selected double buffer. - In
process block 208, thereader 15 sets theread index 22 for the previously selected double buffer in the sharedmemory 20 to identify the low level buffer identified by the sharedindex 26 for the previously selected double buffer. As described previously, theread index 22, for a given double buffer, indicates the low level buffer identified by the sharedindex 26 for the given double buffer from which thereader 15 last accessed data. - In the combination of process blocks 210 and 212, the
reader 15 accesses and outputs the last data written to the previously selected double buffer. Inprocess block 210, thereader 15 accesses (i.e., reads) the data stored in the low level buffer identified by the sharedindex 26 of the previously selected double buffer. Inprocess block 212, thereader 15 outputs the data. Inprocess block 214, thereader 15 optionally outputs the status new data. - Returning to decision block 202, if the shared
index 26 for the selected double buffer corresponds to theread index 22 for the selected double buffer, new data has not been written to the selected double buffer. If new data has not been written to the selected double buffer, the method progresses to process block 216 to determine if old data or new data was written to the non-selected double buffer. - Determining if old data or new data was written to the non-selected double buffer includes, in
process block 216, thereader 15 reading the sharedindex 26 for the non-selected double buffer. In decision block 230 (FIG. 8 b), thereader 15 compares the sharedindex 26 for the non-selected double buffer and theread index 22 for the non-selected double buffer. The non-selected double buffer contains old data if the sharedindex 26 for the non-selected double buffer and theread index 22 for the non-selected double buffer correspond to the same low level buffer. That is, because theread index 22 indicates the low level buffer from which thereader 15 last read data and the sharedindex 26 indicates the low level buffer from which thewriter 17 last wrote data, if the low level buffer that thewriter 17 last wrote data to (i.e., the shared index 26) is the same as the low level buffer that thereader 15 last read data from (i.e., the read index 22), then new data has not been written to the non-selected double buffer. Alternatively, if the sharedindex 26 for the non-selected double buffer and theread index 22 for the non-selected double buffer do not correspond to the same low level buffer, then new data was written to the non-selected double buffer. - In
process block 232, if the sharedindex 26 for the non-selected double buffer and theread index 22 for the non-selected double buffer correspond to the same low level buffer, thereader 15 accesses (i.e., reads) the data stored in the low level buffer identified by the sharedindex 26 of the non-selected double buffer. Inprocess block 234, thereader 15 outputs the data. Inprocess block 236, thereader 15 optionally outputs the status old data. - In
process block 240, if the sharedindex 26 for the non-selected double buffer and theread index 22 for the non-selected double buffer do not correspond to the same low level buffer, thereader 15 sets theread index 22 for the non-selected double buffer to identify the low level buffer identified by the sharedindex 26 for the non-selected double buffer. Inprocess block 242, thereader 15 accesses (i.e., reads) the data stored in the low level buffer identified by the sharedindex 26 of the non-selected double buffer. Inprocess block 244, thereader 15 outputs the data. Inprocess block 246, thereader 15 optionally outputs the status new data. - Turning to
FIG. 9 , thewriter 17 writing data to the selected double buffer in process block 106 ofFIG. 5 is further described. Inprocess block 260, thewriter 17 reads the transmitindex 24. The value of the transmit index 24 (Tx) may be an integer between zero and three. Inprocess block 262, to determine the selected double buffer, thewriter 17 determines a corrected transmitindex 14. The value of the corrected transmit index may be equal toTx mod 2. The corrected transmit index having a value of zero may correspond to the selected double buffer being the firstdouble buffer 28 and the corrected transmitindex 24 having a value of one may correspond to the selected double buffer being the seconddouble buffer 30. - The modulus operator (i.e., mod), e.g., may operate according to the modulus operator in the ADA95 language or the C language. The sign of the output of the modulus operator may be machine-dependent for negative operands. For example, the modulus operator may operate as described in Kernighan Brian, W., and M. Ritchie Dennis, “The C programming language,” Second Edition, AT&T Bell laboratories, New Jersey, Prentice Hall (1988), the entire contents of which are incorporated by reference herein.
- In
process block 264, thewriter 17 reads the sharedindex 26 for the selected double buffer. The value of the shared index 26 (Sx) may be an integer between zero and four. Inprocess block 266, thewriter 17 determines a corrected shared index to determine the low level buffer of the selected buffer to which data was last written. The value of the corrected shared index may be equal to ((Sx−1)mod 2)+1. The corrected shared index having a value of zero may correspond to the initial value, the corrected shared index having a value of one may correspond to the first low level buffer, and the corrected shared index having a value of two may correspond to the second low level buffer. - In
process block 268, thewriter 17 determines a next low level buffer for the selected double buffer. The next low level buffer may be determined such that, if the transmitindex 24 equals zero or one, the value of the next low level buffer equals (Sx mod 2)+1. If the transmitindex 24 equals two or three, the value of the next low level buffer may equal (Sx mod 2)+3. Inprocess block 270, thewriter 17 stores (i.e., writes) data in the next low level buffer for the selected double buffer. Inprocess block 272, thewriter 17 sets the value of the sharedindex 26 equal to the value of the next low level buffer. - Although the invention has been shown and described with respect to a certain illustrated embodiment or embodiments, equivalent alterations and modifications will occur to others skilled in the art upon reading and understanding the specification and the annexed drawings. In particular regard to the various functions performed by the above described integers (components, assemblies, devices, compositions, etc.), the terms (including a reference to a “means”) used to describe such integers are intended to correspond, unless otherwise indicated, to any integer which performs the specified function (i.e., that is functionally equivalent), even though not structurally equivalent to the disclosed structure which performs the function in the herein illustrated embodiment or embodiments of the invention.
Claims (22)
1. A method for providing deterministic inter-core, inter-process, and inter-thread communication between a reader and a writer by passing data through shared memory using double buffering of double buffers, the method comprising:
the reader or writer selecting one of a first double buffer or a second double buffer as a selected double buffer, wherein the writer writes data to the selected double buffer, each double buffer is stored in the shared memory, and each double buffer comprises a first low level buffer and a second low level buffer;
the reader reading data, wherein reading data comprises:
the reader determining if new data has been written to the selected double buffer, wherein new data corresponds to data that has not been read by the reader;
if new data has been written to the selected double buffer:
the reader selecting a non-selected double buffer as the selected double buffer such that the writer writes data to the newly selected double buffer;
the reader determining if new data has been written to the previously selected double buffer in the time since the previous check to determine if new data had been written to the previously selected double buffer;
the reader accessing and outputting the last data written to the previously selected double buffer;
if new data has not been written to the selected double buffer:
the reader determining if old data or new data was written to the non-selected double buffer, wherein old data corresponds to data that the reader has previously read;
if neither old data nor new data was written to the non-selected double buffer, no data is output by the reader; and
if old data or new data was written to the non-selected double buffer, the reader accessing and outputting the last data written to the non-selected double buffer.
2. The method of claim 1 , wherein the writer writing data to the selected double buffer comprises the writer storing data in the low level buffer of the selected double buffer that is most convenient.
3. The method of claim 1 , wherein the reader reads data at the same time as the writer writes data to the selected double buffer.
4. The method according to claim 1 , further comprising the reader outputting a state, wherein:
the reader outputs a new data state when new data has been written to the selected double buffer;
the reader outputs the new data state when new data has not been written to the selected double buffer and new data has been written to the non-selected double buffer;
the reader outputs an old data state when new data has not been written to both the selected double buffer and the non-selected double buffer and the non-selected double buffer contains old data;
and the reader outputs a no data state when new data has not been written to both the selected double buffer and the non-selected double buffer and the non-selected double buffer does not contain old data.
5. The method to claim 1 , wherein the reader or writer selecting one of the first double buffer or the second double buffer as the selected double buffer comprises:
the reader setting a transmit index in the shared memory to identify the first double buffer or the second double buffer, wherein the double buffer identified by the transmit index corresponds to the selected double buffer and the double buffer not identified by the transmit index corresponds to an non-selected double buffer.
6. The method to claim 1 , further comprising the reader or writer initializing both double buffers to an initial state prior to the reader reading data.
7. The method of claim 6 , wherein initializing both double buffers to an initial state comprises:
the reader or writer setting a shared index in the shared memory to an initial value for the first double buffer and the second double buffer, wherein the shared index identifies one of the first low level buffer, the second low level buffer, or the initial value for each double buffer.
8. The method according to claim 1 , wherein the reader determining if new data has been written to the selected double buffer comprises:
the reader reading the transmit index to identify the selected double buffer; the reader reading the shared index for the selected double buffer;
and wherein new data has been written to the selected double buffer if the shared index for the selected double buffer does not correspond to the initial value.
9. The method according to claim 1 , wherein the reader determining if new data has been written to the selected double buffer comprises:
the reader reading the transmit index to identify the selected double buffer;
the reader reading the shared index for the selected double buffer;
the reader reading a read index for the selected double buffer, wherein the read index for a given double buffer indicates the low level buffer identified by the shared index for the given double buffer from which the reader last accessed data; and
wherein new data has been written to the selected double buffer if the shared index for the selected double buffer does not correspond to the read index for the selected double buffer and the shared index for the selected double buffer does not correspond to the initial value.
10. The method according to claim 1 , further comprising, if new data has been written to the selected double buffer, the reader initializing the non-selected double buffer before the reader selecting the non-selected double buffer as the selected double buffer.
11. The method according to claim 1 , wherein the reader initializing the non-selected double buffer comprises:
the reader setting the shared index for the non-selected double buffer to the initial value.
12. The method according to claim 1 , wherein the reader selecting the non-selected double buffer as the selected double buffer comprises:
the reader updating the transmit index to identify the non-selected double buffer such that the non-selected double buffer is now the selected double buffer and the selected double buffer is now the non-selected double buffer.
13. The method according to claim 1 , wherein the reader determining if new data has been written to the previously selected double buffer in the time since the previous check comprises:
the reader reading the shared index for the previously selected double buffer; and the reader setting a read index for the previously selected double buffer in the shared memory to identify the low level buffer identified by the shared index for the non-selected double buffer.
14. The method according to claim 1 , wherein the reader accessing and outputting the last data written to the previously selected double buffer comprises:
the reader accessing the data stored in the low level buffer identified by the shared index of the previously selected double buffer;
and the reader outputting the data.
15. The method according to claim 1 , wherein determining if old data or new data was written to the non-selected double buffer comprises:
the reader reading the shared index for the non-selected double buffer; and
wherein the non-selected double buffer does not contain old data or new data if the shared index for the non-selected double buffer corresponds to the initial value.
16. The method according to claim 1 , wherein determining if old data or new data was written to the non-selected double buffer further comprises:
if the shared index for the non-selected double buffer does not correspond to the initial value:
the reader comparing the shared index for the non-selected double buffer and the read index for the non-selected double buffer;
and wherein the non-selected double buffer contains old data if the shared index for the non-selected double buffer and the read index for the non-selected double buffer correspond to the same low level buffer.
17. The method according to claim 1 , wherein determining if old data or new data was written to the non-selected double buffer further comprises:
wherein, if the shared index for the non-selected double buffer and the read index for the non-selected double buffer do not correspond to the same low level buffer:
new data was written to the non-selected double buffer; and
the reader setting the read index for the non-selected double buffer to identify the low level buffer identified by the shared index for the non-selected double buffer.
18. The method of according to claim 1 , wherein the reader accessing and outputting the last data written to the non-selected double buffer comprises:
the reader accessing the data stored in the low level buffer identified by the shared index of the non-selected double buffer;
and the reader outputting the data.
19. The method according to claim 1 , the writer writing data to the selected double buffer comprises:
the writer reading the shared index for the selected double buffer;
the writer storing data in a next low level buffer for the selected double buffer, wherein (1) the next low level buffer corresponds to the low level buffer for the selected double buffer no indicated by the shared index or the selected double buffer if the shared index corresponds to the first low level buffer or the second low level buffer and (2) the next low level buffer corresponds to the first low level buffer for the selected double buffer if the shared index for the selected double buffer corresponds to the initial value; and the writer setting the shared index for the selected double buffer to correspond to the next low level buffer.
20. The method according to claim 1 , wherein the writer setting the shared index for the selected double buffer to correspond to the next low level buffer comprises;
reading a value of the transmit index (Tx), wherein the transmit index value is an integer between zero and three;
determining a corrected transmit index, wherein a value of the corrected transmit index is equal to Tx mod 2, the corrected transmit index having a value of zero corresponds to the selected double buffer being the first double buffer, and the corrected transmit index having a value of one corresponds to the selected double buffer being the second double buffer;
reading a value of the shared index (Sx), wherein the shared index value is an integer between zero and four;
determining a corrected shared index, wherein a value of the corrected shared index is equal to ((Sx−1)mod 2)+1, the corrected shared index having a value of zero corresponds to the initial value, the corrected shared index having a value of one corresponds to the first low level buffer, and the corrected shared index having a value of two corresponds to the second low level buffer;
determining a value of the next low level buffer, wherein the value of the next low level buffer equals (Sx mod 2)+1 if the transmit index equal zero or one and the value of the next low level buffer equals (Sx mod 2)+3 if the transmit index equal two or three; and
setting the value of the shared index equal to the value of the next low level buffer.
21. A computational device comprising a multicore processor and a shared memory, the multicore processor carrying out a method of claim 1 .
22. A non-transitory computer-readable storage medium storing logical instructions thereon that when executed by a processor perform the steps of a method of claim 1 .
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US14/770,463 US20160004478A1 (en) | 2013-02-25 | 2014-02-24 | Wait-free algorithm for inter-core, inter-process, or inter-task communication |
Applications Claiming Priority (3)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US13/775,305 US9176872B2 (en) | 2013-02-25 | 2013-02-25 | Wait-free algorithm for inter-core, inter-process, or inter-task communication |
US14/770,463 US20160004478A1 (en) | 2013-02-25 | 2014-02-24 | Wait-free algorithm for inter-core, inter-process, or inter-task communication |
PCT/EP2014/053497 WO2014128288A1 (en) | 2013-02-25 | 2014-02-24 | Wait-free algorithm for inter-core, inter-process, or inter-task communication |
Related Parent Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
US13/775,305 Continuation US9176872B2 (en) | 2013-02-25 | 2013-02-25 | Wait-free algorithm for inter-core, inter-process, or inter-task communication |
Publications (1)
Publication Number | Publication Date |
---|---|
US20160004478A1 true US20160004478A1 (en) | 2016-01-07 |
Family
ID=50272574
Family Applications (2)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
US13/775,305 Expired - Fee Related US9176872B2 (en) | 2013-02-25 | 2013-02-25 | Wait-free algorithm for inter-core, inter-process, or inter-task communication |
US14/770,463 Abandoned US20160004478A1 (en) | 2013-02-25 | 2014-02-24 | Wait-free algorithm for inter-core, inter-process, or inter-task communication |
Family Applications Before (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
US13/775,305 Expired - Fee Related US9176872B2 (en) | 2013-02-25 | 2013-02-25 | Wait-free algorithm for inter-core, inter-process, or inter-task communication |
Country Status (3)
Country | Link |
---|---|
US (2) | US9176872B2 (en) |
EP (1) | EP2959386A1 (en) |
WO (1) | WO2014128288A1 (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20160080491A1 (en) * | 2014-09-15 | 2016-03-17 | Ge Aviation Systems Llc | Mechanism and method for accessing data in a shared memory |
Families Citing this family (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10169073B2 (en) | 2015-12-20 | 2019-01-01 | Intel Corporation | Hardware accelerators and methods for stateful compression and decompression operations |
US10310897B2 (en) * | 2016-09-30 | 2019-06-04 | Intel Corporation | Hardware accelerators and methods for offload operations |
US10445016B2 (en) | 2016-12-13 | 2019-10-15 | International Business Machines Corporation | Techniques for storage command processing |
US11836547B2 (en) * | 2017-09-27 | 2023-12-05 | Hitachi Astemo, Ltd. | Data transmission device including shared memory having exclusive bank memories for writing and reading |
US20190138242A1 (en) * | 2017-11-08 | 2019-05-09 | Raytheon Company | Lock-free asynchronous buffer |
CN111465919A (en) | 2017-12-28 | 2020-07-28 | 深圳市大疆创新科技有限公司 | System and method for supporting low latency in a mobile platform environment |
DE102018205392A1 (en) * | 2018-04-10 | 2019-10-10 | Robert Bosch Gmbh | Method and device for error handling in a communication between distributed software components |
DE102018205390A1 (en) * | 2018-04-10 | 2019-10-10 | Robert Bosch Gmbh | Method and device for error handling in a communication between distributed software components |
CN109976675B (en) * | 2019-04-01 | 2023-02-03 | 广州市百果园信息技术有限公司 | Data updating and reading method, device, equipment and storage medium |
US11748174B2 (en) * | 2019-10-02 | 2023-09-05 | Intel Corporation | Method for arbitration and access to hardware request ring structures in a concurrent environment |
DE102020205156A1 (en) | 2020-04-23 | 2021-10-28 | Robert Bosch Gesellschaft mit beschränkter Haftung | Evaluation of measurement data for safety-critical applications |
CN112506676B (en) * | 2020-12-02 | 2024-04-05 | 深圳市广和通无线股份有限公司 | Inter-process data transmission method, computer device and storage medium |
Family Cites Families (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP3003418B2 (en) | 1992-09-25 | 2000-01-31 | 株式会社日立製作所 | Data communication method between processors |
US6356938B1 (en) | 1994-09-09 | 2002-03-12 | The United States Of America As Represented By The Secretary Of The Navy | System and method for transmission of information packets between provider and consumer processors |
US6100906A (en) | 1998-04-22 | 2000-08-08 | Ati Technologies, Inc. | Method and apparatus for improved double buffering |
US6223335B1 (en) | 1998-12-09 | 2001-04-24 | Sun Microsystems, Inc. | Platform independent double compare and swap operation |
US20020112100A1 (en) | 1999-08-19 | 2002-08-15 | Myron Zimmerman | System and method for data exchange |
US6904597B2 (en) | 2001-03-30 | 2005-06-07 | Intel Corporation | Inter-thread communications between different components using double buffer |
US7620753B1 (en) * | 2005-03-17 | 2009-11-17 | Apple Inc. | Lockless access to a ring buffer |
EP1956484B1 (en) * | 2007-02-07 | 2011-10-19 | Robert Bosch Gmbh | Administration module, producer and consumer processor, arrangement thereof and method for inter-processor communication via a shared memory |
US8095727B2 (en) | 2008-02-08 | 2012-01-10 | Inetco Systems Limited | Multi-reader, multi-writer lock-free ring buffer |
US8063910B2 (en) | 2008-07-08 | 2011-11-22 | Seiko Epson Corporation | Double-buffering of video data |
US8904067B2 (en) * | 2012-03-13 | 2014-12-02 | Microsoft Corporation | Adaptive multi-threaded buffer |
-
2013
- 2013-02-25 US US13/775,305 patent/US9176872B2/en not_active Expired - Fee Related
-
2014
- 2014-02-24 US US14/770,463 patent/US20160004478A1/en not_active Abandoned
- 2014-02-24 WO PCT/EP2014/053497 patent/WO2014128288A1/en active Application Filing
- 2014-02-24 EP EP14709575.6A patent/EP2959386A1/en not_active Withdrawn
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20160080491A1 (en) * | 2014-09-15 | 2016-03-17 | Ge Aviation Systems Llc | Mechanism and method for accessing data in a shared memory |
US9794340B2 (en) * | 2014-09-15 | 2017-10-17 | Ge Aviation Systems Llc | Mechanism and method for accessing data in a shared memory |
Also Published As
Publication number | Publication date |
---|---|
US9176872B2 (en) | 2015-11-03 |
WO2014128288A1 (en) | 2014-08-28 |
US20140244944A1 (en) | 2014-08-28 |
EP2959386A1 (en) | 2015-12-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9176872B2 (en) | Wait-free algorithm for inter-core, inter-process, or inter-task communication | |
US9678750B2 (en) | Vector instructions to enable efficient synchronization and parallel reduction operations | |
CN104572568B (en) | Read lock operation method, write lock operation method and system | |
US9535839B2 (en) | Arithmetic processing device, method of controlling arithmetic processing device, and information processing device | |
US10782896B2 (en) | Local instruction ordering based on memory domains | |
US10628352B2 (en) | Heterogeneous multi-processor device and method of enabling coherent data access within a heterogeneous multi-processor device | |
US11941429B2 (en) | Persistent multi-word compare-and-swap | |
CN104750459A (en) | Processor With Transactional Capability and Logging Circuitry To Report Transactional Operations | |
US9824012B2 (en) | Providing coherent merging of committed store queue entries in unordered store queues of block-based computer processors | |
CN112905365A (en) | Data processing method, device, equipment and medium | |
US8893137B2 (en) | Transaction-based shared memory protection for high availability environments | |
US9304777B1 (en) | Method and apparatus for determining relative ages of entries in a queue | |
US10409610B2 (en) | Method and apparatus for inter-lane thread migration | |
US10101999B2 (en) | Memory address collision detection of ordered parallel threads with bloom filters | |
WO2022218337A1 (en) | Method for inspecting code under weak memory order architecture, and corresponding device | |
US10310914B2 (en) | Methods and systems for recursively acquiring and releasing a spinlock | |
US11074200B2 (en) | Use-after-free exploit prevention architecture | |
US20150286640A1 (en) | Data storage device, data storage method and program | |
BRPI0805218A2 (en) | omission scheme of pre-post withdrawal hybrid hardware lock | |
US11972261B2 (en) | Hardware device for enforcing atomicity for memory operations | |
EP2782015A1 (en) | Processor, information processing apparatus, and method for controlling cache write-back | |
JP4370227B2 (en) | Processor | |
KR101667426B1 (en) | Lock-free memory controller and multiprocessor system using the lock-free memory controller | |
CN116324717A (en) | Register compaction with early release | |
US20160117271A1 (en) | Smart holding registers to enable multiple register accesses |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
STCB | Information on status: application discontinuation |
Free format text: ABANDONED -- FAILURE TO RESPOND TO AN OFFICE ACTION |