Race Conditions
Race Conditions: The situation where two or more processes reading or writing some share data and the final results depends on who runs precisely when are called RACE CONDITIONS. Let's take an Example: A print spooler: When a process wants to print a file it enters the filename in a special spooler directly. Another process, the Printer Daemon, periodically checks to see if there are any files to be printed, and if there are, it prints them and removes their name from the directory. Imagine that our spooler directory has a large number of slots, numbered 0,1,2,..... each one capable of holding a filename. also imagine that there are two shared variables, out : points to next file to printed. in : points to next free slot in the directory. slots 0 to 3 files already printed. slots 4 to 6 files names which has to be printed. Now the main issue comes: Process A reads in and store the value, 7, in a local variable called next-free-slot. Just then a clock interrupt occurs ...