I want to implement a one-producer, multiple-consumer model with shared memory in Unix
Producer: put the data frame(~char[1024]) in a memory segment
Consumers: memcpy the data into its own private memory and do some processing
Some relevant info:
- It is okay for consumer to miss some data frame
- Consumers are independent, eg. It's okay if one consumer only gets data 1,2,4, and another gets 2,3,5
- About 10 consumers will be running at the same time
- Producer can generate data faster than consumers can process
- Slow/zombie consumer should not slow down the whole system
- Consumer will skip the memcpy if it sees the same data
I have setup the shared memory stuff, and use the pthread read-write lock, but it seems slower than using a tcp model
My question: what synchronization is best suited for this kind of model?