Software and Hardware C-language Locking Algorithms and Implementations