What is the difference between the test and set implementation of mutex
and the Peterson's Algorithm?
Which of them is actually used in the real systems?
Peterson's algorithm doesn't work very well in a modern memory architecture with caching. You end up needing to flush constantly. Test-and-set and interlocked operations like interlocked exchange or interlocked increment are going to be much more commonly used and have direct support on the CPU.
FreeRTOS
,Linux
,ReactOS
and link the source code...