 
 #ifdef R__WIN32
 	HANDLE* semLock = new HANDLE;
-	*semLock = CreateSemaphore(NULL, 0, 1, "AliceHLTTPCCAGPUTrackerInitLock");
+	*semLock = CreateSemaphore(NULL, 1, 1, SemLockName);
+	if (*semLock == NULL)
+	{
+		HLTError("Error creating GPUInit Semaphore");
+		return(1);
+	}
 	WaitForSingleObject(*semLock, INFINITE);
 #else
-	sem_t* semLock = sem_open("AliceHLTTPCCAGPUTrackerInitLock", O_CREAT);
+	sem_t* semLock = sem_open(SemLockName, O_CREAT, 0x01B6, 1);
+	if (semLock == SEM_FAILED)
+	{
+		HLTError("Error creating GPUInit Semaphore");
+		return(1);
+	}
 	sem_wait(semLock);
 #endif
 
 	if (fgGPUUsed)
 	{
 	    HLTWarning("CUDA already used by another AliHLTTPCCAGPUTracker running in same process");
+		ReleaseGlobalLock(semLock);
 	    return(1);
 	}
 	fgGPUUsed = 1;

ClassImp( AliHLTTPCCAGPUTracker )

bool AliHLTTPCCAGPUTracker::fgGPUUsed = false;

void AliHLTTPCCAGPUTracker::ReleaseGlobalLock(void* sem)
{

#else
#include <sys/syscall.h>
#include <semaphore.h>
#include <fcntl.h>
#endif

#include "AliHLTTPCCADef.h"
