Exemplo n.º 1
0
/** \brief Initialize the mutex taking the mutex attributes
 *         into account
 */
os_result os_mutexInit (os_mutex *mutex, const os_mutexAttr *mutexAttr)
{
   Error err;
   os_mutexAttr defAttr;

   assert (mutex != NULL);

#if !defined NDEBUG && !defined INTEGRITY
   assert(mutex->signature != OS_MUTEX_MAGIC_SIG);
#endif

   if(!mutexAttr) {
       os_mutexAttrInit(&defAttr);
       mutexAttr = &defAttr;
   }

   if ( mutexAttr->scopeAttr == OS_SCOPE_SHARED)
   {
      Semaphore newsem;
      mutex->localsem = NULL;

#ifndef NDEBUG
      checkMutexCache(mutex);
#endif

      err = rsNewSemaphore(&newsem, &mutex->index, &mutex->uid);
      if ( err == Success )
      {
         os_mutexAddToMap(mutex, newsem);
      }
   }
   else
   {
      err = CreateBinarySemaphore(&mutex->localsem);
   }

#ifndef NDEBUG
   if ( err == Success )
   {
      mutex->signature = OS_MUTEX_MAGIC_SIG;
   }
#endif

   return ( err == Success ? os_resultSuccess : os_resultFail );
}
Exemplo n.º 2
0
Arquivo: utils.c Projeto: AEUG/400plus
// this is a disassembled version of eventproc_release()
int shutter_release_disasm() {

	extern char * aRelSem;

	if (hRelSem == 0) {
		hRelSem = CreateBinarySemaphore(aRelSem, 0);
	}

	SendToIntercom(IC_RELEASE, 0, 0);
	SendToIntercom(0x6D, 1, 1); // set burst counter

	TakeSemaphore(hRelSem, 30000);
	DeleteSemaphore(hRelSem);
	hRelSem = 0;

	SleepTask(EVENT_WAIT); // we added this
	return 0;
}