I'm studying the concurrency in programming and the atomic instructions. What i have not understood is the concept of "fairness" applied to this matter. Can you give me an hint ?
Suppose you are running two concurrent processes (or threads), which both perform intensive disk I/O. Both repeatedly attempt to read/write on some file.
Now, the scheduler must decide which requests to handle. The scheduler could serve the first process, then the second on, then the first, etc. in a round-robin fashion. This would guarantee fairness: any process request is eventually served.
Suppose instead that the scheduler wants to maximize disk throughput. One way to do that is to move the disk head as little as possible. This can be done by serving the I/O request which operates on the closest file (roughly speaking) to where the head is found at the moment. Assume the first process only accesses file A, while the second process accesses only file B. If both continuously perform requests on their files, the only one of them will be served: e.g. if A is the first accessed file, B will never get accessed since keeping the disk head on A optimizes performance with respect to moving the head to file B. Hence, the second process will never get served, and will "starve". This scheduler is not fair.