File read/write advisory locking in Ada?

Hi;

I may have missed this in the docs, forgive me please if so…

If I have two or more processes (tasks perhaps?) that are reading and/or writing to a file, how can I obtain temporary locking?

I certainly do not want file corruption.

I really do not want to have an unhandled exception from being uable to get access to the file by the second process while the first process does have access, which would result in the program exiting.

Perhaps I have to do exception handling, have a delay, and try again, if the second process can’t get access?

Perhaps “good” Ada programmers in a program that does multiprocessing only has one task that does the I/O for a specific file and it performs that locking and the rendezvous synchronization so that all the other processes have to busy wait for the task responsible for I/O to accept requests for the file?

Thanks,
Retired Build Engineer

Re-reading the docs…I should just use the “Is_Open” function provided by Ada.Text_IO, and then use a busy-wait loop if necessary until available?

I guess I was over-thinking it :frowning:

Thanks,
Retired Build Engineer

1 Like