David,
On 2 Jul 2014, at 11:42, David Matthews <David.Matthews at prolingua.co.uk> wrote:
On 29/06/2014 11:41, Rob Arthan wrote:
The files are only 4096 bytes so it is not much of an overhead, but it is a bit messy. Would it make sense to provide a function in PolyML.Statistics allowing a process to opt into making its statistics available? (Or conversely, is there a requirement to access statistics from a program that has not been designed with that in mind?)
The idea was to make the statistics available for another poly or a different program. The difficulty is finding a way to make them available. In Windows it is possible to have a named shared memory segment which is created by the poly process and can be opened, read-only, by another process. When the creating process finishes the memory segment is deleted unless another process is currently reading it. There's no equivalent, as far as I can tell, in Unix. The only way to make a shared memory segment available to another process is to map a file and the file will remain after the creating process exits unless it is explicitly deleted.
My preference would be for a way to have the equivalent of named shared memory segments.
Have you looked at System V shared memory (shmget/shmat etc.)? This seems to be available on most flavours of UN*X these days. However, it is a long while since I have used these interfaces and they may just move the problem from the world of ls and rm to the world of ipcs and ipcrm.
If there is no alternative to the present scheme of creating a mapped file in the file system then it would probably be better to only create it if the creating process explicitly requests it. That could be a flag somewhere in PolyML.Statistics or, probably easier, a command line option. Any ideas?
If you stick with mmap, then control via the command line looks good to me.
Regards,
Rob.