You understand that a critical section is a protected block of (usually) shared code in memory that you set up.
This block can have only one process running that code. Process B want to run the code. It requests it. Meanwhile process A just keeps running the code over and over. If process A can go on as long as it wants, then process B is stuck waiting almost forever. So, if we can count the number of time A hits the section, and then say after A hits the section 100 times: 'Okay A, you've had enough turns... process B, the section is now yours'.
It is part of scheduling, very like the idea of a quantum (time slice) of the CPU. You get your turn, and when somebody else wants a turn and your time is up, the other guy gets his turn.
|