Thought I'd throw this out as I'm sure I'm not the only one to have to
have solved this...
I have a stream of data arriving in one a pipe via process A -- about 50M/day
I want to buffer this data to a large disk buffer.
Multiple readers want to get at that circular buffer and read data.
In memory, this would be easy, with a large number of threads and their
condition variables this would be easy.
I first thought I'd divide the buffer into say 1000000 "pages". The writer
could lock any page as it was accessing/updating it. Readers would have to
aquire a lock to read the page.
Still, readers need to know where a writer is, so I need an index of some
sort. This needs to be on disk as well, but I thought I'd mmmap that into core.
After the writer started work on a page, it would msync() the shared map.
Still, locking is an issue. How do I keep the index pages consistent without
hitting the disk continuouly and using lock() style code. Again, condition
variables work, but I need one million of them.
Any ideas?