05-23-2024, 04:59 AM
One thing you might consider is to write a "Last Used By" Variable at the top of the code.
PUT #1, , UsedBY
PUT #1, , Data_to_Transfer
Now, whenever you look at the file, you can tell from that first set of bytes if it's available for read/write or not.
If those bytes are:
00 -- then there's no read/writing going on. The file is in a blank slate and either side can write to the file. There's nothing to read.
01 -- the first file is now accessing this data. The 2nd one should wait for it to finish whatever it's doing.
10 -- the second file is now accessing the data. The 1st program should now wait for it to finish whatever it's doing.
When one file needs to do something, it always checks the status of that first byte to make certain that the file is ready for it to send/recieve data, and thus doesn't try to access it while the other program is manipulating the data in that file, until its finished.
PUT #1, , UsedBY
PUT #1, , Data_to_Transfer
Now, whenever you look at the file, you can tell from that first set of bytes if it's available for read/write or not.
If those bytes are:
00 -- then there's no read/writing going on. The file is in a blank slate and either side can write to the file. There's nothing to read.
01 -- the first file is now accessing this data. The 2nd one should wait for it to finish whatever it's doing.
10 -- the second file is now accessing the data. The 1st program should now wait for it to finish whatever it's doing.
When one file needs to do something, it always checks the status of that first byte to make certain that the file is ready for it to send/recieve data, and thus doesn't try to access it while the other program is manipulating the data in that file, until its finished.