Adding Shared Memory version with locks