[petsc-dev] PetscExceptionTry1

Barry Smith bsmith at mcs.anl.gov
Mon Feb 14 14:05:50 CST 2011


On Feb 14, 2011, at 1:56 PM, Jed Brown wrote:

> On Mon, Feb 14, 2011 at 20:54, Barry Smith <bsmith at mcs.anl.gov> wrote:
> You could do that. But I think it is better to not generate an error at all by first checking if you can actually open the file before trying to open it.
> 
> That's a race condition. Opening a file is atomic, testing and then opening is not.

   Then we need a PetscFOpen() to be able to return a flag indicating that it cannot open the file.

   But I don't think it is right to call it a "race condition", it is just a non-atomic operation and it is possible that after the test succeeds the open may fail. But I don't think we should be using algorithms/approaches that rely on checking that a file exists and opening it be an atomic operation we don't use the filesystem in such a dynamic way so I think checking then opening is fine for PETSc.

  Barry

It is not that I don't think there is a place in the whole world for an atomic check and open, it is just not something that I think PETSc needs.





More information about the petsc-dev mailing list