Example #1
0
MIKMODAPI BOOL MikMod_InitThreads(void)
{
	static int firstcall=1;
	static int result=0;
	
	if (firstcall) {
		firstcall=0;
#ifdef HAVE_PTHREAD
		result=1;
#elif defined(__OS2__)||defined(__EMX__)
		if(DosCreateMutexSem((PSZ)NULL,&_mm_mutex_lists,0,0) ||
		   DosCreateMutexSem((PSZ)NULL,&_mm_mutex_vars,0,0)) {
			_mm_mutex_lists=_mm_mutex_vars=(HMTX)NULL;
			result=0;
		} else
			result=1;
#elif defined(WIN32)
		if((!(_mm_mutex_lists=CreateMutex(NULL,FALSE,"libmikmod(lists)")))||
		   (!(_mm_mutex_vars=CreateMutex(NULL,FALSE,"libmikmod(vars)"))))
			result=0;
		else
			result=1;
#endif
	}
	return result;
}
Example #2
0
void sound_init_dart(void)
{
/*    static int first=TRUE;
    if (!first)
        return;
*/
    dlog = log_open("Dart");

    DosCreateMutexSem("\\SEM32\\Vice2\\Sound\\OC.sem",    &hmtxOC,  0, FALSE);
    DosCreateMutexSem("\\SEM32\\Vice2\\Sound\\Write.sem", &hmtxSnd, 0, FALSE);
/*    first=FALSE;*/
}
Example #3
0
/*** Semaphore ***/
void vlc_sem_init (vlc_sem_t *sem, unsigned value)
{
    if (DosCreateEventSem(NULL, &sem->hev, 0, value > 0 ? TRUE : FALSE))
        abort ();

    if (DosCreateMutexSem(NULL, &sem->wait_mutex, 0, FALSE))
        abort ();

    if (DosCreateMutexSem(NULL, &sem->count_mutex, 0, FALSE))
        abort ();

    sem->count = value;
}
Example #4
0
void fly_init (int x0, int y0, int rows, int cols, char *font)
{
    TID       tid;
    int       rc;
    ULONG     reset;

    tiled1 = _tmalloc (tiled_size);
    if (tiled1 == NULL) fly_error ("cannot allocate tiled memory\n");
    us1_16 = _tmalloc (sizeof(USHORT));
    us2_16 = _tmalloc (sizeof(USHORT));
    pci = _tmalloc (sizeof(VIOCURSORINFO));

    rc = DosCreateMutexSem (NULL, &mtx_Queue, 0, FALSE);
    debug_tools ("rc = %d after DosCreateMutexSem\n", rc);

    rc = DosCreateMutexSem (NULL, &mtx_Video, 0, FALSE);
    debug_tools ("rc = %d after DosCreateMutexSem\n", rc);

    rc = DosCreateEventSem (NULL, &hev_NewMessage, 0, FALSE);
    debug_tools ("rc = %d after DosCreateEventSem\n", rc);

    rc = DosCreateEventSem (NULL, &hev_VideoReady, 0, FALSE);
    debug_tools ("rc = %d after DosCreateEventSem\n", rc);
    
    grab_video ();
    if (rows != -1 && cols != -1)
        video_init (rows, cols);
    else
        video_init (25, 80);
    release_video ();

    DosResetEventSem (hev_VideoReady, &reset);
    rc = DosCreateThread (&tid, interface_thread, 0, 0, 32786);
    debug_tools ("rc = %d after DosCreateThread\n", rc);

    DosWaitEventSem (hev_VideoReady, SEM_INDEFINITE_WAIT);
    fl_opt.initialized = TRUE;
    DosSleep (300);

    if (font != NULL)
        fly_set_font (font);

    //debug_tools ("rows = %d, cols = %d in fly_init\n", rows, cols);
    if (rows != -1 && cols != -1)
        video_set_window_size (rows, cols);
    
    debug_tools ("x0 = %d, y0 = %d in fly_init\n", x0, y0);
    if (x0 >= 0 && y0 >= 0)
        video_set_window_pos (x0, y0);
}
Example #5
0
/* Create a semaphore */
DECLSPEC SDL_sem * SDLCALL SDL_CreateSemaphore(Uint32 initial_value)
{
        SDL_sem *sem;
        ULONG ulrc;

        /* Allocate sem memory */
        sem = (SDL_sem *)SDL_malloc(sizeof(*sem));
        if ( sem ) {
                /* Create the mutex semaphore */
                ulrc = DosCreateMutexSem(NULL,&(sem->id),0,TRUE);
                if ( ulrc ) {
                        SDL_SetError("Couldn't create semaphore");
                        SDL_free(sem);
                        sem = NULL;
                } else
                {
                    DosCreateEventSem(NULL, &(sem->changed), 0, FALSE);
                    sem->value = initial_value;
                    DosReleaseMutexSem(sem->id);
                }
        } else {
                SDL_OutOfMemory();
        }
        return(sem);
}
Example #6
0
int GUI::OpenPipe(char *Command, EModel *notify) {
  int i;

  for (i = 0; i < MAX_PIPES; i++) {
    if (Pipes[i].used == 0) {
      Pipes[i].reading = 1;
      Pipes[i].stopped = 1;
      Pipes[i].id      = i;
      Pipes[i].bufused = 0;
      Pipes[i].bufpos  = 0;
      Pipes[i].buflen  = PIPE_BUFLEN;
      Pipes[i].Command = strdup(Command);
      Pipes[i].notify  = notify;
      Pipes[i].DoTerm  = 0;

      if ((Pipes[i].buffer = (char *)malloc(PIPE_BUFLEN)) == 0) {
        free(Pipes[i].Command);
        return -1;
      }

      if (0 != DosCreateMutexSem(0, &Pipes[i].Access, 0, 0)) {
        free(Pipes[i].Command);
        free(Pipes[i].buffer);
        return -1;
      }

      if (0 != DosCreateEventSem(0, &Pipes[i].ResumeRead, 0, 0)) {
        free(Pipes[i].Command);
        free(Pipes[i].buffer);
        DosCloseMutexSem(Pipes[i].Access);
        return -1;
      }

      if (0 != DosCreateEventSem(0, &Pipes[i].NewData, 0, 0)) {
        free(Pipes[i].Command);
        free(Pipes[i].buffer);
        DosCloseEventSem(Pipes[i].ResumeRead);
        DosCloseMutexSem(Pipes[i].Access);
        return -1;
      }

#if defined(__WATCOMC__) || defined(__MT__) || defined(__MULTI__)
      Pipes[i].tid = _beginthread(PipeThread,
                                  FAKE_BEGINTHREAD_NULL
                                  16384, &Pipes[i]);
#else // if defined(__WATCOMC__) || defined(__MT__) || defined(__MULTI__)
      DosCreateThread(Pipes[i].tid,
                      (PFNTHREAD)PipeThread,
                      &Pipes[i],
                      0, /* immediate */
                      16384);
#endif // if defined(__WATCOMC__) || defined(__MT__) || defined(__MULTI__)
      Pipes[i].used = 1;

      // fprintf(stderr, "Pipe Open: %d\n", i);
      return i;
    }
  }
  return -1;
}
VOID MMKbdListener_StartThread( VOID )
{
 // Сбрасываем переменную для ответа от потока.
 Thread_responds.Thread_is_created = 0;

 // Если поток уже создан - выход.
 CHAR Semaphore_name[] = "\\SEM32\\NICE-OS2!Krnl!MMKbdListener"; HMTX hmtxAlreadyRunning = NULLHANDLE;
 if( DosOpenMutexSem( Semaphore_name, &hmtxAlreadyRunning ) == NO_ERROR ) return;
 else DosCreateMutexSem( Semaphore_name, &hmtxAlreadyRunning, DC_SEM_SHARED, 1 );

 // Создаем поток.
 APIRET Thread_is_created = DosCreateThread( &Enhancer.Modules.MMKbdListener->Thread, (PFNTHREAD) MMKbdListener_MMKbdListenerThread, 0, 0, THREAD_STACK_SIZE );
 // Если он создан - ждем, пока в нем будет создана очередь сообщений.
 if( Thread_is_created == NO_ERROR ) while( Thread_responds.Thread_is_created == 0 ) { Retard(); }
 // Если поток создать не удалось - возврат.
 if( Thread_is_created != NO_ERROR || Thread_responds.Thread_is_created == -1 ) { Enhancer.Modules.MMKbdListener->Thread = 0; return; }
 // Устанавливаем приоритет потока.
 WinPostQueueMsg( Enhancer.Modules.MMKbdListener->Message_queue, SM_PRIORITY, (MPARAM) PRTYC_REGULAR, (MPARAM) PRTYD_QUICK );

 // Посылаем в поток сообщение о том, что ему следует вызвать функцию ожидания сообщений.
 WinPostQueueMsg( Enhancer.Modules.MMKbdListener->Message_queue, SM_WAIT_MMKBD_EVENTS, 0, 0 );

 // Возврат.
 return;
}
int OpenMarkerList(PMARKERLIST pList)
{
   if (DosCreateMutexSem(NULL, &pList->hmtxAccess, 0, FALSE))
      return 1;
   else
      return 0;
}
Example #9
0
video_canvas_t video_canvas_create(const char *title, UINT *width,
                             UINT *height, int mapped,
                             canvas_redraw_t exposure_handler,
                             const palette_t *palette,
                             struct video_frame_buffer_s *fb)
{
    video_canvas_t canvas_new;

    DEBUG(("Creating canvas width=%d height=%d", *width, *height));

    if (palette->num_entries > 255) {
       log_error(video_log, "Too many colors requested.");
       return (video_canvas_t) NULL;
    }

    vidlog("canvas alloc",1);
    canvas_new = lib_calloc(1,sizeof(struct _canvas));
    if (!canvas_new) return (video_canvas_t) NULL;

    canvas_new->init_ready       =  FALSE;  // canvas_new not yet initialized
    canvas_new->width            = *width;
    canvas_new->height           = *height;
    canvas_new->pbmi_initialized =  FALSE;  // pbmi not yet initialized

    rc=DosCreateMutexSem("\\SEM32\\GFX", &hmtx, 0, FALSE); // gfx init begin
    vidlog("Create: ",rc);
    _beginthread(PM_mainloop,NULL,0x4000,&canvas_new);

    while (!canvas_new->pbmi_initialized) DosSleep(1);
    video_canvas_set_palette(canvas_new, palette);

    canvas_new->exposure_handler = exposure_handler;
    return canvas_new;
}
//---------------------------------------------------------------------
// LibMain
//
// This gets called at DLL initialization and termination.
//---------------------------------------------------------------------
unsigned _System LibMain(unsigned hmod, unsigned termination)
{
  int i;

  if (termination)
  {
    // Cleanup!
    if (bRunning)
      SSModule_StopSaving();

    // Free NLS text, if it wouldn't be (safety net)
    for (i=0; i<SSMODULE_NLSTEXT_MAX+1; i++)
    {
      if (apchNLSText[i])
      {
        free(apchNLSText[i]);
        apchNLSText[i] = NULL;
      }
    }
    // Free semaphore
    DosCloseMutexSem(hmtxUseNLSTextArray); hmtxUseNLSTextArray = NULLHANDLE;
  } else
  {
    // Startup!
    hmodOurDLLHandle = (HMODULE) hmod;
    bRunning = FALSE;
    // Initialize NLS text array
    for (i=0; i<SSMODULE_NLSTEXT_MAX+1; i++)
      apchNLSText[i] = NULL;
    // Create semaphore to protect it
    DosCreateMutexSem(NULL, &hmtxUseNLSTextArray, 0, FALSE);
  }
  return 1;
}
/* Create a mutex */
DECLSPEC SDL_mutex * SDLCALL SDL_CreateMutex(void)
{
  SDL_mutex *mutex;
  APIRET ulrc;

  /* Allocate mutex memory */
  mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex));
  if (mutex)
  {
    /* Create the mutex, with initial value signaled */
    ulrc = DosCreateMutexSem(NULL,                  // Create unnamed semaphore
                             &(mutex->hmtxID),      // Pointer to handle
                             0L,                    // Flags: create it private (not shared)
                             FALSE);                // Initial value: unowned
    if (ulrc!=NO_ERROR)
    {
      SDL_SetError("Couldn't create mutex");
      SDL_free(mutex);
      mutex = NULL;
    }
  } else {
    SDL_OutOfMemory();
  }
  return(mutex);
}
Example #12
0
File: thread.c Project: Tilka/vlc
/*** Mutexes ***/
void vlc_mutex_init( vlc_mutex_t *p_mutex )
{
    /* This creates a recursive mutex. This is OK as fast mutexes have
     * no defined behavior in case of recursive locking. */
    DosCreateMutexSem( NULL, &p_mutex->hmtx, 0, FALSE );
    p_mutex->dynamic = true;
}
void QFMotionPlayer::initialize()
{
  ULONG returnCode;

  returnCode = DosOpenMutexSem(SEM_PREPARING, &preparing);
  if (returnCode)
    DosCreateMutexSem(SEM_PREPARING, &preparing, DC_SEM_SHARED, FALSE);
}
Example #14
0
/* Allocate a mutex. */
int
__objc_mutex_allocate(objc_mutex_t mutex)
{
  if (DosCreateMutexSem (NULL, (HMTX)(&(mutex->backend)),0L,0) > 0)
    return -1;
  else
    return 0;
}
Example #15
0
/* rc = 0 (NO_ERROR) - Ok
      = 1 - error
      = 2 - DUPLICATE_NAME
*/
int SetupSemaphore(void)
{
    PID     pidOwner = 0;          /* PID of current mutex semaphore owner */
    TID     tidOwner = 0;          /* TID of current mutex semaphore owner */
    ULONG   ulCount  = 0;          /* Request count for the semaphore */
    APIRET  rc       = NO_ERROR;   /* Return code */
    char *pstr;
    pstr = FREEPM_MUTEX_NAME;
    rc = DosCreateMutexSem(FREEPM_MUTEX_NAME,      /* Semaphore name */
                           &FREEPM_hmtx, 0, FALSE);  /* Handle returned */
    if (rc != NO_ERROR)
    {
        if(rc == ERROR_DUPLICATE_NAME)
        {   return 2;
        } else {
            printf("DosCreateMutexSem error: return code = %u\n", rc);
            return 1;
        }
    }
//  if(!detachedMode)
//       printf("DosCreateMutexSem %i \n",__LINE__);
    /* This would normally be done by another unit of work */
    rc = DosOpenMutexSem(FREEPM_MUTEX_NAME,      /* Semaphore name  */
                         &FREEPM_hmtx);          /* Handle returned */
    if (rc != NO_ERROR) {
        printf("DosOpenMutexSem error: return code = %u\n", rc);
        return 1;
    }
//  if(!detachedMode)
//       printf("DosOpenMutexSem %i\n",__LINE__);

    rc = DosRequestMutexSem(FREEPM_hmtx,      /* Handle of semaphore */
                            (ULONG) 1000);  /* Timeout  */
    if (rc != NO_ERROR) {
        printf("DosRequestMutexSem error: return code = %u\n", rc);
        return 1;
    }
//  if(!detachedMode)
//      printf("DosRequestMutexSem %i\n",__LINE__);

    rc = DosQueryMutexSem(FREEPM_hmtx,         /* Handle of semaphore */
                          &pidOwner,    /* Process ID of owner */
                          &tidOwner,    /* Thread ID of owner */
                          &ulCount);    /* Count */
    if (rc != NO_ERROR) {
        printf("DosQueryMutexSem error: return code = %u\n", rc);
        return 1;
    } else if (!_FreePM_detachedMode)  {
        printf("Semaphore owned by PID %u, TID %u.", pidOwner, tidOwner);
        printf("  Request count is %u.\n", ulCount);
    } /* endif */

//  if(!detachedMode)
//       printf("DosQueryMutexSem %i\n",__LINE__);

    return NO_ERROR;
}
Example #16
0
static APIRET CreateSem(void)
{
#ifdef __os2_16__
  char SemName[32];
  sprintf(SemName, "\\SEM\\jed\\%u", getpid());
  return ( DosCreateSem (0, &Hmtx, SemName) );
#else
  return ( DosCreateMutexSem (NULL, &Hmtx, 0, 0) );
#endif
}
Example #17
0
static void archdep_create_mutex_sem(HMTX *hmtx, const char *pszName, int fState)
{
    APIRET rc;

    char *sem = lib_malloc(13+strlen(pszName) + 5 + 1);

    sprintf(sem, "\\SEM32\\VICE2\\%s_%04x", pszName, vsyncarch_gettime()&0xffff);

    rc = DosCreateMutexSem(sem, hmtx, 0, fState);
}
Example #18
0
int Initialize_PluginList()
{
  int rc;

  if (PluginListProtector_Sem != -1) return TRUE;

  PluginListHead = NULL;

  rc = DosCreateMutexSem(NULL, &PluginListProtector_Sem, 0, FALSE);
  return (rc == NO_ERROR);
}
Example #19
0
static bool thread_init(void)
{
              /* I have to create SEMs here, but only used in getkey  */
   rc = DosCreateMutexSem(NULL, &hkbdsem, 1L, FALSE);
   if (rc != 0)  return FALSE;
   rc = DosCreateMutexSem(NULL, &hkquesem, 1L, FALSE);
   if (rc != 0)  return FALSE;
   rc = DosCreateMutexSem(NULL, &hshell_ok_sem, 1L, FALSE);
   if (rc != 0)  return FALSE;

                                 /* start keyboard thread    */
  if(_beginthread(inchar,THREADSTACK,NULL) == -1) {
     err_exit(" Failed to start critical threads", 0);
  }
  while(!inchar_ready) {      // 1st time, wait for inchar to start
    DosSleep(50);
  }

return TRUE;
}
Example #20
0
int Initialize_EventCallbackList()
{
  int rc;

  if (CallbackListProtector_Sem != -1) return TRUE;

  CallbackListHead = NULL;

  rc = DosCreateMutexSem(NULL, &CallbackListProtector_Sem, 0, FALSE);
  return (rc == NO_ERROR);
}
Example #21
0
/* ------------------------------------------------------------------------ */
void archdep_create_mutex_sem(HMTX *hmtx, const char *pszName, int fState)
{
    APIRET rc;

    char *sem = lib_malloc(13+strlen(pszName) + 5 + 1);

    sprintf(sem, "\\SEM32\\VICE2\\%s_%04x", pszName, vsyncarch_gettime()&0xffff);

    if (rc = DosCreateMutexSem(sem, hmtx, 0, fState)) {
        log_error(archlog, "DosCreateMutexSem '%s' (rc=%i)", pszName, rc);
    }
}
Example #22
0
void enter_sync()
{
    if (Mutex == NULL)
    {   // first call => initialize mutex
        HMTX newmtx;
        DosCreateMutexSem(NULL, &newmtx, 0, FALSE);
        if (InterlockedCxc((volatile unsigned*)&Mutex, 0, (unsigned)newmtx) != 0)
            // compare exchange failed => destroy mutex
            DosCloseMutexSem(newmtx);
    }
    DosRequestMutexSem(Mutex, SEM_INDEFINITE_WAIT);
}
Example #23
0
int DLLCALL pthread_mutex_init(pthread_mutex_t* mutex, void* attr)
{
	(void)attr;
#if defined(PTHREAD_MUTEX_AS_WIN32_MUTEX)
	return ((((*mutex)=CreateMutex(/* security */NULL, /* owned */FALSE, /* name */NULL))==NULL) ? -1 : 0);
#elif defined(_WIN32)	/* Win32 Critical Section */
	InitializeCriticalSection(mutex);
	return 0;	/* No error */
#elif defined(__OS2__)
	return DosCreateMutexSem(/* name */NULL, mutex, /* attr */0, /* owned */0);
#endif
}
Example #24
0
int Initialize_ChannelSetList()
{
  int rc;

  if (ChannelSetListProtector_Sem != -1) return TRUE;

  ChannelSetListHead = NULL;
  pLastChannelSet = NULL;
  iNextChannelSetID = 1;
  bChannelSetListChanged = 0;

  rc = DosCreateMutexSem(NULL, &ChannelSetListProtector_Sem, 0, FALSE);
  return (rc == NO_ERROR);
}
Example #25
0
void debug_init(char *pcDebugFile, char *pcFileFunc, int iLine)
{
  if ( cInit == 0 )
  {
    fdDebug = fopen( pcDebugFile, "a" );
    if ( fdDebug == NULL )
      printf( "Cannot open debug file %s\n", pcDebugFile );

    lsBufPSZ.ppLast = &lsBufPSZ.pList;
    DosCreateMutexSem( NULL, &hMtx, 0, FALSE );
  }

  cInit++;
  debug_write( "debugInit(): %s line %d, %d'th call\n",
               pcFileFunc, iLine, cInit );
}
/****************************************************************\
 * Routine to create  semaphores used in this file.             *
 *--------------------------------------------------------------*
 *                                                              *
 *  Name:    CreateAllSems(VOID)                                *
 *                                                              *
 *  Purpose: Create semaphores needed by the consumer threads.  *
 *           Checks return codes from semaphore creation.       *
 *                                                              *
 *  Usage:   Called by StartSemExample.                         *
 *                                                              *
 *  Method:  Semaphores are all anonymous private semaphores    *
 *           since the semaphores are used by threads in the    *
 *           same process.                                      *
 *                                                              *
 *  Returns: 0 if all semaphores are created successfully.      *
 *           Otherwise returns error code for first create      *
 *           semaphore API to fail.                             *
 *                                                              *
\****************************************************************/
ULONG CreateAllSems(VOID)
{
   ULONG      rc;
   SEMRECORD   asr[MAXRESOURCES];
   INT         i;

   rc = DosCreateMutexSem((PSZ)NULL,&hmtxOwnResource, 0L,FALSE);
   if (rc)
   {
       SemError("DosCreateMutexSem",rc);
       return(rc);
   }

   for (i = 0; i < MAXRESOURCES; i++)
   {
      rc = DosCreateEventSem( (PSZ)NULL, &aSquares[i].hev,
                                      0L, FALSE);
      if (rc)
      {
          SemError("DosCreateEventSem",rc);
          return(rc);
      }
      else
      {
          asr[i].ulUser = i;
          asr[i].hsemCur = (VOID *)aSquares[i].hev;
      }
   }
                          /* this muxwait semaphore contains all of the
                          event semaphores created in the loop above. */
   rc = DosCreateMuxWaitSem((PSZ)NULL,&hmuxResource,
           MAXRESOURCES,asr, DCMW_WAIT_ANY);
   if (rc)
   {
      SemError("DosCreateMuxWaitSem",rc);
      return(rc);
   }
   rc = DosCreateEventSem((PSZ)NULL,&hevStop,0L,FALSE);
   if (rc)
   {
       SemError("DosCreateEventSem",rc);
       return(rc);
   }
   return(rc);
}
Example #27
0
/* XXX: Need to respect APR_THREAD_MUTEX_[UN]NESTED flags argument
 *      or return APR_ENOTIMPL!!!
 */
APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex,
                                                  unsigned int flags,
                                                  apr_pool_t *pool)
{
    apr_thread_mutex_t *new_mutex;
    ULONG rc;

    new_mutex = (apr_thread_mutex_t *)apr_palloc(pool, sizeof(apr_thread_mutex_t));
    new_mutex->pool = pool;

    rc = DosCreateMutexSem(NULL, &(new_mutex->hMutex), 0, FALSE);
    *mutex = new_mutex;

    if (!rc)
        apr_pool_cleanup_register(pool, new_mutex, thread_mutex_cleanup, apr_pool_cleanup_null);

    return APR_OS2_STATUS(rc);
}
EditBoxCollection::EditBoxCollection():Collection(10,2), init(), keys(), vars(),
										npFED(cPipe), MouHandle(0)
{
	cName = new char[1024];

    cur_box   = 0;
    shutdown  = 0;
    recording = 0;
    last_box  = 0;

    head = tail = 0;

    DosCreateMutexSem(0, &hMtx, 0, 0);

    Clipboard = new Buffer;
    Clipboard->add_line(new Line);

	save_screen = vio_save_box(0, 0, Rows, Cols);
}
void TThreads::resume() {
   //  cerr << "TThreads::resume\n";
   shutDownFlag=0;
   assert(! DosAllocMem((void **)&tiled,sizeof(TiledStruct),fALLOC | OBJ_TILE));
   tiled->modeInfo.cb = (unsigned short) sizeof(VIOMODEINFO);
#if 0
   printf("tiled=%lx\n", tiled);
   char line[5];
   gets(line);
#endif

   if (MouOpen((PSZ) 0, &tiled->mouseHandle) != 0) tiled->mouseHandle = 0xFFFF;

   assert(! DosCreateEventSem(NULL, &hevMouse1, 0, 0));
   assert(! DosCreateEventSem(NULL, &hevMouse2, 0, 0));
   assert(! DosCreateEventSem(NULL, &hevKeyboard1, 0, 0));
   assert(! DosCreateEventSem(NULL, &hevKeyboard2, 0, 0));
   assert(! DosCreateMutexSem(NULL, &hmtxMouse1, 0, 0));

   evCombined[0].ulUser=0;
   evCombined[0].hsemCur=(HSEM)hevMouse1;
   evCombined[1].ulUser=1;
   evCombined[1].hsemCur=(HSEM)hevKeyboard1;

   assert(!DosCreateMuxWaitSem(NULL,&hmuxMaster,2,evCombined,DCMW_WAIT_ANY));

   mouseThreadID = 0xFFFF;
   if (tiled->mouseHandle != 0xFFFF) {
#ifdef __BORLANDC__
      mouseThreadID = _beginthread(mouseThread,16384,NULL);
#else
      mouseThreadID = _beginthread(mouseThread,NULL,16384,NULL);
#endif
   }
   DosSetPriority(PRTYS_THREAD,PRTYC_REGULAR,31,mouseThreadID);
   DosPostEventSem(TThreads::hevMouse2);
#ifdef __BORLANDC__
   keyboardThreadID = _beginthread(keyboardThread,16384,NULL);
#else
   keyboardThreadID = _beginthread(keyboardThread,NULL,16384,NULL);
#endif
   DosSetPriority(PRTYS_THREAD,PRTYC_REGULAR,31,keyboardThreadID);
}
Example #30
0
RTDECL(int) RTSemMutexCreateEx(PRTSEMMUTEX phMutexSem, uint32_t fFlags,
                               RTLOCKVALCLASS hClass, uint32_t uSubClass, const char *pszNameFmt, ...)
{
    AssertReturn(!(fFlags & ~RTSEMMUTEX_FLAGS_NO_LOCK_VAL), VERR_INVALID_PARAMETER);

    /*
     * Create the semaphore.
     */
    HMTX hmtx;
    int rc = DosCreateMutexSem(NULL, &hmtx, 0, FALSE);
    if (!rc)
    {
        /** @todo implement lock validation of OS/2 mutex semaphores. */
        *phMutexSem = (RTSEMMUTEX)(void *)hmtx;
        return VINF_SUCCESS;
    }

    return RTErrConvertFromOS2(rc);
}