On 21.05.2012 15:34, Voznesensky Vladimir wrote:
So, every message write to the ring buffer consist of the steps:
- If buffer_size - (write_pointer - read_pointer) %
buffer_size < message_size + 1,
- set errno=EAGAIN and return;
- If write_pointer + message_size > buf_pointer + buf_size
- write a special message to mark buffer overlimit,
- set write_pointer = buf_pointer,
- do the 1st step again and goto 3.
- Write the message starting from the write pointer;
- Write 1 to the eventfd;
- <write pointer> += <message size>.
Every read consists of the steps:
- Poll the file descriptors including the eventfd in the main
loop, so the eventfd becomes readable;
- Read the value from the eventfd.
- Read the message from the buffer;
- If the message is special,
- set read_pointer= buffer_pointer,
- do the 3d step again;
- Process the message;
- read_pointer += message_size;
- If the read pointer is not equal to the write pointer,
Am I correct here? Is my pseudocode optimal?
Opps, reading the eventfd should be done after the last step.
-- VV
|
_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss