[NeXus-tech] NAPI Thread safety
Mark Koennecke
Mark.Koennecke at psi.ch
Wed Oct 20 13:01:25 BST 2010
Freddie,
freddie.akeroyd at stfc.ac.uk wrote:
> Hi,
>
> In the HDF5 thread examples H5Fopen() is called once and the fid_t
> returned used by separate threads - as NXhandle contains state
> information it is not possible to share it between threads so I think we
> need to either:
> (1) add an NXclone_handle() / NXcopy_handle() function to create a copy
> of an NXhandle connected to the same HDF5 file via H5Freopen()
> or
> (2) Modify NXopen() so it keeps internally a list of open files and
> associated HDF5 file handles so if you open a file a second time in the
> same process it uses H5Freopen() rather than H5Fopen() to generate the
> NXhandle.
>
> (1) is easier to code; (2) is easier for the end user, but we need to be
> careful about correctly identifying if a file is already open (e.g.
> handling links - is just checking the inode number field returned by
> stat() enough for all cases?)
>
> Any thoughts?
>
> Regards,
>
> Freddie
>
I found another point in favour of NXclode_handle: If we maintain a list
of open files, we need another global data structure which needs to be
protected
by locks in order to be thread safe. Not a good idea.
Regards,
Mark
More information about the NeXus-tech
mailing list