Good day, every process in my software is about to update 3 specific globals in row when the process is called to do some job. I need to guarantee that during updating of those globals with multiple processes there is only one process that is actually working with those globals. Moreover I need my globals unreadable if other process is in critical area.
(for example globals: ^data1, ^data2, ^data3 are critical area)
Should I use somehow function $LOCK() or there is another way how this can be done? I need only one process at the same time in critical area, due to that I don't need semaphores. And how to detect in other processes if there is some process already in critical area? Should I use transactions too if in the same time two processes would get into cirtical area where one of them should call trans. rollaback?
Thanks in advance for your answers and help.