View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

thread safe

douglas brenner wrote on Oct 15, 2008

Is iraf considered "thread safe". In a script, can it be called multiple times in a C program using threads?
Thanks

Mike Fitzpatrick wrote on Oct 15, 2008

It depends how you call it: If you mean you do a fork()/system() call to something like a #!cl script as a host command, then yes it is safe to do this from threads since each command is a separate instance of the CL. If instead you mean you want to link directly to iraf libraries (e.g. the CVOS interface or imfort), then the answer is no except for purely computational procedures.

The problem is that there are several global data structures used in the system that overwrite themselves when using threads (in particular, the file i/o buffering is a problem).

-Mike

douglas brenner wrote on Oct 15, 2008

Thanks. I'm using system () calls and it does seem to work.

Francisco Valdes wrote on Oct 15, 2008

If I understand, you want to run a number of CL scripts at the same time (using separate CL sessions as Mike indicated). We do this with our NOAO parallel and distributed pipelines. Some possible concerns we had to deal with are to make sure the scripts are using separate uparm directories or use the "cache" command if any task is called that updates its parameters. The other problem was with pipes; IRAF uses temporary files for the pipes with autogenerated names. In prior versions of the CL the pipes could get the same names for processes with similar pids. There was a change in the CL to be more clever about this and seems to be quite reliable though the algorithm isn't 100% guaranteed not to conflict. There may be some other subtleties but our pipeline experience has shown it is possible to use IRAF #!cl scripts in a parallel fashion.

Yours,
Frank Valdes

douglas brenner wrote on Oct 15, 2008

Thanks.
I have focal planes that have to be turned into data cubes (x,y, lambda) in the usual learn while you earn format. I discovered that the fitsio library was not thread safe and wanted to know about iraf. I'm still trying to figure the whole thing out.

Last post on Oct 15, 2008