I need to write a kernel module that mimics a "multicaster". Using the / proc file system.
This is mainly necessary to support the following scenarios:
1) allow one write access to the / proc file and many accesses to the / proc file.
2) The module must have a buffer of the last successful write. Each entry should be matched by reading from the entire reader.
Consider scenario 2, the writer wrote something and there are two readers (A and B), A read the contents of the buffer, and then A tried to read again, in this case he should go to wait_queue and wait for the next message, it should not receive that again same buffer.
I need to save a map of all pid that have already read the current buffer, and in case they try to read again and the buffer has not been changed, they must be blocked until a new buffer appears. I am trying to understand that there is a way to save this information without a map. I heard that there are several redundant fields in the I / O system that I can use for a process flag if it already reads the current buffer.
Can someone give me advice where I should look for this field? How can I save information about the current process without saving the "map" pid and buffers?
Thanks!
source share