Hi Raji, > > Design : Plugin uses memory mapped file for high performance input/output > > operations. File is used as cyclic queue for storing or reading records, it > > store s 50 records of 78bytes,hence fixed size file of 3916 bytes is used. > > File's first 16 bytes were used for storing header, and next 3900 bytes for > > data. Header structure has head pointer, tail pointer,unread and lastid. > > Head pointer points to next slot for writing record into,tail for reading > > record, unread for number of history records unread by client, lastid for > > id of the last record that is written. > > Just a couple quick points. Memory mapped files do not really give any > benefit over read/write/lseek for small files (e.g. less than a few > pages) with small record sizes (e.g. less than a 4K page.) In fact > they're probably slower in these cases. > > > Locking: > > Accessing Memory mapped file pointer , all header fields > > (head,tail,unread,lastid), temp_unread,temp_tail are synchronized by a > > mutex. writing into memory file and reading from memory file happen > > asynchronously, so mutex is used to protect the memory mapped file pointer > > , header, temp_unread, temp_tail. > > I'm totally confused by this one; you use no threads in your plugin (and > neither does oFono) and you have no external clients accessing the same > shared memory region. It seems to me that locking is completely > unnecessary. > > Raji > History reads are client driven, can happen during the write > operation. Same with writing, if there is any read operation in progress, > write operation needs to wait. So the mutex will lock the memory information > until read/write operation is done.
who reads from this file. The mutex is local to ofonod. If any other program reads from that memory you need a proper memory lock. The local mutex is not helping since ofonod is (on purpose) single threaded and thus no locking is actually needed since read and write operations from ofonod can't happen at the same time. Regards Marcel _______________________________________________ ofono mailing list [email protected] http://lists.ofono.org/listinfo/ofono
