Claims
- 1. A method of exchanging data between a reader and a writer on a computer system, the method comprising:
establishing a region of global shared memory, the memory comprising a plurality of discrete buffers and a write ticket, each buffer having an associated buffer sequence number and comprising a data area, and the write ticket encoding a current buffer index and the buffer sequence number of the current buffer; assigning a subset of the buffers to a writer; writing data to memory, where writing comprises, in sequence:
selecting a buffer from the subset of buffers; incrementing the buffer sequence number of the selected buffer; writing data to the selected buffer; and atomically updating the current buffer index and buffer sequence number of the write ticket with identifying information for the selected buffer; reading data from memory, where reading comprises, in sequence:
atomically reading the write ticket to obtain the current buffer index and buffer sequence number; reading data from the buffer referred to by the obtained current buffer index; atomically reading the buffer sequence number of the buffer referred to by the obtained current buffer index; comparing the results of the read of the buffer sequence number of the buffer referred to by the obtained current buffer index with the buffer sequence number read from the obtained write ticket; and if the compared results differ, restarting the reading step.
- 2. A method of exchanging data between a reader and a writer on a computer system, the method comprising:
establishing a region of global shared memory, the memory comprising a plurality of discrete buffers and a write ticket, each buffer comprising a buffer sequence number, a time stamp, and a data area, and the write ticket encoding a current buffer index and the buffer sequence number of the current buffer; assigning a subset of the buffers to a writer; writing data to memory, where writing comprises, in sequence:
selecting a buffer from the subset of buffers; incrementing the buffer sequence number of the selected buffer; writing data and a time stamp to the selected buffer; atomically reading the write ticket to determine the current buffer; comparing the time stamps of the current buffer and the selected buffer; and if the time stamp of the selected buffer is not earlier than the current buffer, atomically updating the current buffer index and buffer sequence number of the write ticket to make the selected buffer the current buffer; reading data from memory, where reading comprises, in sequence:
atomically reading the write ticket to obtain the current buffer index and buffer sequence number; reading data from the buffer referred to by the current buffer index; atomically reading the buffer sequence number of the buffer referred to by the current buffer index; comparing the results of the read of the buffer sequence number of the buffer referred to by the current buffer index with the buffer sequence number read from the obtained write ticket; and if the compared results differ, restarting the reading step.
- 3. The method of claim 1 or claim 2, wherein there is a plurality of writers on the computer system, and wherein assigning includes assigning each writer a distinct subset of buffers.
- 4. The method of claim 1 or claim 2, wherein there is a plurality of readers on the computer system.
- 5. The method of claim 4, wherein the readers run on the same processor.
- 6. The method of claim 4, wherein the readers run on different processors.
- 7. The method of claim 1 or claim 2, wherein selecting a buffer during writing comprises selecting the least recently used buffer from the writer's assigned buffers.
- 8. The method of claim 1 or claim 2, wherein the reader or the writer is selected from the group consisting of a general process, a thread of a general process, a kernel process, a thread of a kernel process, and an interrupt routine.
- 9. The method of claim 1 or claim 2, wherein the current buffer is the most recently written buffer.
- 10. A data exchange system for a computer, comprising:
at least one reader; at least one writer; and a region of global shared memory comprising a plurality of buffers and a write ticket, each buffer comprising a buffer sequence number and a data area, wherein
each writer on the system has assigned to it a subset of the buffers; each writer on the system writes to each of its buffers in sequence in successive write operations; and each reader on the system reads buffers written by the writers by consulting the write ticket to determine which of a writer's buffers is the current buffer and to determine the expected buffer sequence number; reading the current buffer; after reading, consulting the buffer sequence number to determine whether the read buffer has been rewritten during reading; and if the read buffer has been rewritten, initiating a new read operation.
- 11. The data exchange system of claim 9, wherein a plurality of readers exist on the system.
- 12. The data exchange system of claim 11, wherein the readers run on different processors.
- 13. The data exchange system of claim 11, wherein the readers run on the same processor.
- 14. The data exchange system of claim 9, wherein a plurality of writers exist on the system, and wherein the subset of the buffers assigned to each of the writers is distinct.
- 15. The data exchange system of claim 14, wherein the writers run on different processors.
- 16. The data exchange system of claim 14, wherein the writers run on the same processor.
- 17. The data exchange system of claim 9, wherein the reader or the writer is selected from the group consisting of a general process, a thread of a general process, a kernel process, a thread of a kernel process, and an interrupt routine.
- 18. The method of claim 3, wherein the writers run on the same processor.
- 19. The method of claim 3, wherein the writers run on different processors.
- 20. The method of claim 1 or claim 2, wherein selecting a buffer during writing comprises selecting any buffer except the most recently written buffer from the writer's assigned buffers.
CROSS-REFERENCE TO RELATED APPLICATIONS
[0001] This application is a continuation-in-part of U.S. application Ser. No. 09/642,041, filed Aug. 18, 2000, and claims benefit and priority of U.S. Provisional Application No. 60/149,831, filed Aug. 19, 1999, and of U.S. application Ser. No. 09/642,041, both of which are incorporated herein by reference.
Provisional Applications (1)
|
Number |
Date |
Country |
|
60149831 |
Aug 1999 |
US |
Continuation in Parts (1)
|
Number |
Date |
Country |
Parent |
09642041 |
Aug 2000 |
US |
Child |
09849946 |
May 2001 |
US |