 
 	// getValue for each Thread
 	do {
-		atomicExch(&d_kernelWrapper->active_thread_id, thread_id);
+
+		atomicExch((int *) &d_kernelWrapper->active_thread_id, thread_id);
+		//__threadfence_system();
 
 		if (d_kernelWrapper->active_thread_id == thread_id) {
 			accessed = true;


	h_kernelWrapper->active_thread_id = 0;
	h_kernelWrapper->sendDone();
	h_kernelWrapper->done = true;

	pthread_join(t_socket_server, NULL);
	exit(0);

	// clean up after cuPrintf
	cudaPrintfEnd();

	h_kernelWrapper->active_thread_id = 0;
	h_kernelWrapper->sendDone();

	// wait for SocketServer
	pthread_join(t_socket_server, NULL);

