The following program used the implementation of atomic locks from 'Cuda By Example', but running the program makes my machine frozen. Can someone tell me what's wrong with my program? Thanks a lot
Yifei
#include <stdio.h>
__global__ void test()
{
__shared__ int i, mutex;
if (threadIdx.x == 0) {
i = 0;
mutex = 0;
}
__syncthreads();
while( atomicCAS(&mutex, 0, 1) != 0);
i++;
printf("thread %d: %d\n", threadIdx.x, i);
atomicExch(&mutex,0);
}