http://rocky.colby.edu/cs357/code/hw6/The file lock.c contains an incorrect implementation of a lock written in C. The file lock.s contains a correct (I think) implementation of a lock written in Intel x86 assembler code. I will explain the latter in class. The Makefile shows how to make two programs called goodlock and badlock based on the two versions of a lock. Compile and run both programs.
There are many ways to do this. Here is just one suggestion: make the shared variable a counter that hands out unique identifiers in sequence. Create a big array and count the number of times each identifier gets handed out. If the lock is working correctly, every identifier should get handed out exactly once, so each array element should be 1.