I was reading the implementation of Linux semaphores. Due to atomicity, signal and wait (up and down in the source code) use spin locks. Then I saw Linux disabled interrupt in spin_lock_irqsave and reenabled interrupt in spin_unlock. This confused me. In my opinion, there is really no point disabling interrupt within a critical section. For example, proc A (currently active)
Tag: atomic
How to use atomic variables in C?
I need to use an atomic variable in C as this variable is accessed across different threads. Don’t want a race condition. My code is running on CentOS. What are my options? Answer If you are using GCC on your CentOS platform, then you can use the __atomic built-in functions. Of particular interest might be this function: — Built-in Function:
Is rename() atomic?
I am not being able to check this via experiments and could not gather it from the man pages as well. Say I have two processes, one moving(rename) file1 from directory1 to directory2. Say the other process running concurrently copies the contents of directory1 and directory2 to another location. Is it possible that the copy happens in such a way