Example #1
0
int main( int argc, char **argv )
{
    char        buff[256];
    TID         tid;
    APIRET      rc;

    MemInit();
    getcmd( buff );
    CmdData = buff;
    DebugMain();
    _SwitchOff( SW_ERROR_STARTUP );
    DoInput();
    VarInitInfo( &Locals );
    DosCreateEventSem( NULL, &Requestsem, 0, false );
    DosCreateEventSem( NULL, &Requestdonesem, 0, false );
    DosPostEventSem( Requestdonesem ); // signal req done
    rc = DosCreateThread( &tid, ControlFunc, 0, 0, 32768 );
    if( rc != 0 ) {
        printf( "Stubugger: Error creating thread!\n" );
    }
    while( !Done ) {
        DlgCmd();
    }
    DosCloseEventSem( Requestsem );
    DosCloseEventSem( Requestdonesem );
    DebugFini();
    RunRequest( REQ_BYE );
    MemFini();
    return( 0 );
}
Example #2
0
int GetClipText(ClipData *cd) {
    int rc;
    ULONG PostCount;
    char *mem;
    
    rc = DosOpenMutexSem(SEM_PREFIX "CLIPSYN", &hmtxSyn);
    if (rc != 0) return -1;
    rc = DosOpenEventSem(SEM_PREFIX "CLIPGET", &hevGet);
    if (rc != 0) return -1;
/*    rc = DosOpenEventSem(SEM_PREFIX "CLIPPUT", &hevPut);*/
/*    if (rc != 0) return -1;*/
    rc = DosOpenEventSem(SEM_PREFIX "CLIPEND", &hevEnd);
    if (rc != 0) return -1;
    
    DosRequestMutexSem(hmtxSyn, SEM_INDEFINITE_WAIT);
    DosResetEventSem(hevEnd, &PostCount);
    DosPostEventSem(hevGet);
    DosWaitEventSem(hevEnd, SEM_INDEFINITE_WAIT);
    if (0 == DosGetNamedSharedMem((void **)&mem, MEM_PREFIX "CLIPDATA", PAG_READ | PAG_WRITE)) {
        cd->fLen = *(ULONG*)mem;
        cd->fChar = strdup(mem + 4);
        DosFreeMem(mem);
    } else {
        cd->fLen = 0;
        cd->fChar = 0;
    }
    DosPostEventSem(hevGet);
    DosReleaseMutexSem(hmtxSyn);
/*    DosCloseEventSem(hevPut);*/
    DosCloseEventSem(hevGet);
    DosCloseEventSem(hevEnd);
    DosCloseMutexSem(hmtxSyn);
    return 0;
}
Example #3
0
File: thread.c Project: Tilka/vlc
static void vlc_thread_cleanup (struct vlc_thread *th)
{
    vlc_threadvar_t key;

retry:
    /* TODO: use RW lock or something similar */
    vlc_mutex_lock (&super_mutex);
    for (key = vlc_threadvar_last; key != NULL; key = key->prev)
    {
        void *value = vlc_threadvar_get (key);
        if (value != NULL && key->destroy != NULL)
        {
            vlc_mutex_unlock (&super_mutex);
            vlc_threadvar_set (key, NULL);
            key->destroy (value);
            goto retry;
        }
    }
    vlc_mutex_unlock (&super_mutex);

    if (th->detached)
    {
        DosCloseEventSem (th->cancel_event);
        DosCloseEventSem (th->done_event );
        free (th);
    }
}
int _System decoder_init( void **ppvPluginWork )
{
    PLUGINWORK *pPluginWork;
    pPluginWork = (void *)malloc( sizeof( PLUGINWORK ) );
    if(pPluginWork == 0) {
        *ppvPluginWork = 0;
        return -1;
    }
    memset( pPluginWork, 0, sizeof( PLUGINWORK ) );
    DosCreateEventSem( NULL, &pPluginWork->hevThreadTrigger, 0UL, FALSE );
    DosCreateEventSem( NULL, &pPluginWork->hevThreadA,       0UL, FALSE );

    pPluginWork->tidThreadDecode = _beginthread( ThreadDecodeMain, NULL, 1024 * 1024, pPluginWork );
    if(pPluginWork->tidThreadDecode == -1) {
        /* can't create thread */
        DosCloseEventSem( pPluginWork->hevThreadTrigger ); pPluginWork->hevThreadTrigger = NULLHANDLE;
        DosCloseEventSem( pPluginWork->hevThreadA       ); pPluginWork->hevThreadA       = NULLHANDLE;
        free( pPluginWork ); pPluginWork = NULL;
        *ppvPluginWork = 0;
        return -1;
    }

    *ppvPluginWork = (void *)pPluginWork;
    pPluginWork->songlength = 0xffffffffUL;
    pPluginWork->fStop = FALSE;
    pPluginWork->fTerminate = FALSE;
//    DosSetPriority( PRTYS_THREAD, PRTYC_TIMECRITICAL, PRTYD_MAXIMUM, pPluginWork->tidThreadDecode );

    return 0;
}
Example #5
0
/**
 * This function initializes KVA vout method.
 */
static int Open ( vlc_object_t *object )
{
    vout_display_t *vd = (vout_display_t *)object;
    vout_display_sys_t *sys;

    vd->sys = sys = calloc( 1, sizeof( *sys ));
    if( !sys )
        return VLC_ENOMEM;

    DosCreateEventSem( NULL, &sys->ack_event, 0, FALSE );

    sys->tid = _beginthread( PMThread, NULL, 1024 * 1024, vd );
    DosWaitEventSem( sys->ack_event, SEM_INDEFINITE_WAIT );

    if( sys->i_result != VLC_SUCCESS )
    {
        DosCloseEventSem( sys->ack_event );

        free( sys );

        return VLC_EGENERIC;
    }

    return VLC_SUCCESS;
}
static cairo_status_t
_cairo_os2_surface_finish (void *abstract_surface)
{
    cairo_os2_surface_t *local_os2_surface;

    local_os2_surface = (cairo_os2_surface_t *) abstract_surface;
    if ((!local_os2_surface) ||
        (local_os2_surface->base.backend != &cairo_os2_surface_backend))
    {
        /* Invalid parameter (wrong surface)! */
        return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
    }

    DosRequestMutexSem (local_os2_surface->hmtx_use_private_fields, SEM_INDEFINITE_WAIT);

    /* Destroy old image surface */
    cairo_surface_destroy ((cairo_surface_t *) (local_os2_surface->image_surface));
    /* Destroy old pixel buffer */
    _buffer_free (local_os2_surface->pixels);
    DosCloseMutexSem (local_os2_surface->hmtx_use_private_fields);
    DosCloseEventSem (local_os2_surface->hev_pixel_array_came_back);

    /* The memory itself will be free'd by the cairo_surface_destroy ()
     * who called us.
     */

    return CAIRO_STATUS_SUCCESS;
}
Example #7
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;
}
Example #8
0
int __CBeginThread( thread_fn *start_addr, void *stack_bottom,
                    unsigned stack_size, void *arglist )
/******************************************************/
{
    TID         tid;
    APIRET      rc;
    thread_args td;

    if( __ThreadData == NULL ) {
        if( __InitThreadProcessing() == NULL )  return( -1 );
        __InitMultipleThread();
    }
    stack_bottom = stack_bottom;
    td.rtn = start_addr;
    td.argument = arglist;
    rc = DosCreateEventSem( NULL, &td.event, 0, 0 );
    if( rc != 0 ) return( -1 );
    rc = DosCreateThread( &tid, (PFNTHREAD)begin_thread_helper, (ULONG)&td,
                          0, stack_size + __threadstksize );
    if( rc != 0 ) {
        tid = -1;
    } else {
        /*
           suspend parent thread so that it can't call _beginthread() again
           before new thread extracts data from "td" (no problem if new
           thread calls _beginthread() since it has its own stack)
        */
        DosWaitEventSem( td.event, SEM_INDEFINITE_WAIT );
    }
    DosCloseEventSem( td.event );
    return( tid );
}
Example #9
0
void DART_CloseAudio(_THIS)
{
  MCI_GENERIC_PARMS GenericParms;
  int rc;

  
  rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_STOP, MCI_WAIT, &GenericParms, 0);
  if (rc!=MCIERR_SUCCESS)
  {
#ifdef SFX_DEBUG_BUILD
    printf("Could not stop DART playback!\n");
    fflush(stdout);
#endif
  }

  
  DosCloseEventSem(_this->hidden->hevAudioBufferPlayed);

  
  {
    int i;
    for (i=0; i<_this->hidden->iCurrNumBufs; i++) SDL_free((void *)(_this->hidden->pMixBuffers[i].ulUserParm));
  }

  
  rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0);

  
  SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;

  
  rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_CLOSE, MCI_WAIT, &(GenericParms), 0);
}
/****************************************************************\
 * Routine to signal consumer to release resource.              *
 *--------------------------------------------------------------*
 *                                                              *
 *  Name:     SignalUserEvent(pfAutoMode)                       *
 *                                                              *
 *  Purpose:  Posts user event semaphore to signal thread to    *
 *            release resource.  Also posts event to stop       *
 *            Auto mode if *pfAutoMode is true.                 *
 *                                                              *
 *  Usage:    Called in file usercmd.c when the user selects    *
 *            Event from the semaphore menu.                    *
 *                                                              *
 *  Method:   Turns off Auto mode, if present by posting auto   *
 *            semaphore.  User event is then posted.            *
 *                                                              *
 *  Returns:                                                    *
 *                                                              *
\****************************************************************/
VOID SignalUserEvent(PULONG pfAutoMode)
{
  ULONG rc;

                          /* If sample is in auto mode turn auto mode off. */
  if (*pfAutoMode)
  {
      rc = DosPostEventSem(hevStopAuto);
      if (rc)
      {
         SemError("DosPostEventSem Stop Auto",rc);
      }
                       /* Wait for auto mode thread to die, so we don't
                          end up with multiple copies of it later.    */

      rc = DosWaitThread(&tidAutoThread,0L);
      if (rc)
      {
         SemError("DosWaitThread",rc);
      }
      *pfAutoMode = FALSE;
      DosCloseEventSem (hevStopAuto);
  }

  /* If Auto mode haas already posted the event this is OK
     so we will not check error codes here. */

  DosPostEventSem(aSquares[rand() % MAXRESOURCES].hev);
  return;
}
Example #11
0
int main(void)
{
    APIRET apiret;
    HPIPE hpipe;
    PSZ pipeName = "\\pipe\\testpipe";
    PSZ semName = "\\sem32\\pipesem";
    HEV hev;
    CHAR objname[50];
    RESULTCODES rc;
    ULONG bytesread;
    CHAR buf[50];

    printf(__FILE__ " main function invoked\n");
    printf("Test named pipe functions\n");

    apiret = DosCreateNPipe(pipeName, &hpipe, 0, NP_WAIT, 0, 0, 0);
    printf("DosCreateNPipe function returned %d\n", (int)apiret);

    apiret = DosCreateEventSem(semName, &hev, DC_SEM_SHARED, FALSE);
    printf("DosCreateEventSem function returned %d\n", (int)apiret);

    apiret = DosExecPgm(objname, 50, EXEC_ASYNC, NULL, NULL, &rc, "./test11a");
    printf("DosExecPgm function returned %d\n", (int)apiret);

    apiret = DosWaitEventSem(hev, 5000);
    printf("DosWaitEventSem function returned %d\n", (int)apiret);

    apiret = DosRead((HFILE)hpipe, buf, sizeof(buf) - 1, &bytesread);
    printf("DosRead function returned %d\n", (int)apiret);
    buf[bytesread] = '\0';
    printf("Message was \"%s\"\n", buf);

    apiret = DosWaitEventSem(hev, 5000);
    printf("DosWaitEventSem function returned %d\n", (int)apiret);

    apiret = DosRead((HFILE)hpipe, buf, sizeof(buf) - 1, &bytesread);
    printf("DosRead function returned %d\n", (int)apiret);
    buf[bytesread] = '\0';
    printf("Message was \"%s\"\n", buf);

    apiret = DosWaitEventSem(hev, 5000);
    printf("DosWaitEventSem function returned %d\n", (int)apiret);

    apiret = DosRead((HFILE)hpipe, buf, sizeof(buf) - 1, &bytesread);
    printf("DosRead function returned %d\n", (int)apiret);
    buf[bytesread] = '\0';
    printf("Message was \"%s\"\n", buf);

    /* wait for test11a to catch up with us */
    DosSleep(2000);

    apiret = DosCloseEventSem(hev);
    printf("DosCloseEventSem function returned %d\n", (int)apiret);

    apiret = DosClose((HFILE)hpipe);
    printf("DosClose function returned %d\n", (int)apiret);

    return 0;
}
void
_PR_MD_DESTROY_SEM(_MDSemaphore *md)
{
   int rv;
   rv = DosCloseEventSem(md->sem);
   PR_ASSERT(rv == NO_ERROR);

}
Example #13
0
/**
 * free what has been allocated by avcodec_thread_init().
 * must be called after decoding has finished, especially do not call while avcodec_thread_execute() is running
 */
void avcodec_thread_free(AVCodecContext *s){
    ThreadContext *c= s->thread_opaque;
    int i;

    for(i=0; i<s->thread_count; i++){

        c[i].func= NULL;
        DosPostEventSem(c[i].work_sem);
        //        ReleaseSemaphore(c[i].work_sem, 1, 0);
        DosWaitThread((PTID)&c[i].thread,DCWW_WAIT);
//        WaitForSingleObject(c[i].thread, INFINITE);
        if(c[i].work_sem) DosCloseEventSem(c[i].work_sem);//CloseHandle(c[i].work_sem);
        if(c[i].done_sem) DosCloseEventSem(c[i].done_sem);//CloseHandle(c[i].done_sem);
    }

    av_freep(&s->thread_opaque);
}
//***************************************************************************
//*                                                                         *
//*  BOOL closeSemaphore()                                                  *
//*                                                                         *
//*  Closes the Event Semaphore                                             *
//*  Returns:                                                               *
//*    TRUE - Success                                                       *
//*    FALSE - Unsuccessful closing of event semaphore                      *
//*                                                                         *
//*  Preconditions: init_Semaphore has to be called successfully before     *
//*                                                                         *
//***************************************************************************
BOOL scsiObj::closeSemaphore()
{
  ULONG  rc;                                            // return value

  rc = DosCloseEventSem(postSema);                      // close event semaphore
  if (rc) return FALSE;                                 // DosCloseEventSem failed
  return TRUE;
}
Example #15
0
/* delete_async_info deletes the structure created by create_async_info and
 * all of its components.
 */
static void Os2_delete_async_info(void *async_info)
{
   AsyncInfo *ai = async_info;

   if (ai == NULL)
      return;
   DosCloseEventSem(ai->sem);
   Free_TSD(ai->TSD, ai);
}
omni_semaphore::~omni_semaphore(void)
{
   APIRET rc = DosCloseEventSem( nt_sem );
  if (rc!=0) {
    DB( cerr << "omni_semaphore::~omni_semaphore: DosCloseEventSem error "
         << rc << endl );
    throw omni_thread_fatal(rc);
  }
}
Example #17
0
File: thread.c Project: Tilka/vlc
void vlc_join (vlc_thread_t th, void **result)
{
    ULONG rc;

    do
    {
        vlc_testcancel();
        rc = vlc_WaitForSingleObject( th->done_event, SEM_INDEFINITE_WAIT );
    } while( rc == ERROR_INTERRUPT );

    if (result != NULL)
        *result = th->data;

    DosCloseEventSem( th->cancel_event );
    DosCloseEventSem( th->done_event );

    free( th );
}
Example #18
0
/* Free the semaphore */
DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_sem *sem)
{
        if ( sem ) {
                if ( sem->id ) {
                        DosCloseEventSem(sem->changed);
                        DosCloseMutexSem(sem->id);
                        sem->id = 0;
                }
                SDL_free(sem);
        }
}
/****************************************************************\
 * Routine to really stop semaphore example.                    *
 *--------------------------------------------------------------*
 *                                                              *
 *  Name:     StopSemaphore( PVOID pvArg )                      *
 *                                                              *
 *  Purpose:  Waits for threads to complete,                    *
 *            Sends message to message thread to indicate this  *
 *            has occurred, and exits.                          *
 *                                                              *
 *  Usage:    Exec'd from BeginStop when user selects Stop from *
 *            Semaphore menu.                                   *
 *                                                              *
 *  Method:   Turns off Auto mode, if present by posting auto   *
 *            semaphore.  Then stop event is posted.  Waits     *
 *            for threads to die.                               *
 *  Returns:                                                    *
 *                                                              *
\****************************************************************/
VOID StopSemaphore( PVOID pvArg )
{
   ULONG rc,usCount, i;
   PULONG pfAutoMode = (PULONG)pvArg;

   if (*pfAutoMode)
   {
      rc = DosWaitThread(&tidAutoThread,0L);
      if (rc && (rc != ERROR_INVALID_THREADID))
      {
         SemError("DosWaitThread",rc);
      }
      *pfAutoMode = FALSE;
   }
   /* Wait for usConsumer threads to die.  Order of death not important. */

   for (usCount = 0; usCount < usConsumerThreadsCreated; usCount++)
   {
      rc = DosWaitThread(&thrConsumers[usCount].tid,0L);

      /* rc is ERROR_INVALID_THREADID the thread is already dead.*\
      \* This is OK and not a error.                             */

      if (rc && (rc != ERROR_INVALID_THREADID))
      {
         SemError("DosWaitThread",rc);
      }
   }
                /* Threads dead so we don't need semaphores any more.  */
   DosCloseEventSem(hevStopAuto);
   DosCloseEventSem(hevStop);
   DosCloseMutexSem(hmtxOwnResource);
   for (i = 0; i < MAXRESOURCES; i++)
   {
      DosCloseEventSem(aSquares[i].hev);
   }
   DosCloseMuxWaitSem (hmuxResource);
   WinPostMsg (hwndMain, WM_COMMAND, (MPARAM)IDM_STOPFINISHED, (MPARAM)NULL);
   DosExit (EXIT_THREAD, 0);
   return;
}
Example #20
0
static void
DART_CloseDevice(_THIS)
{
    MCI_GENERIC_PARMS GenericParms;
    int rc;
    int i;

    if (_this->hidden != NULL) {
        // Stop DART playback
        if (_this->hidden->iCurrDeviceOrd) {
            rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_STOP,
                                MCI_WAIT, &GenericParms, 0);
#ifdef SFX_DEBUG_BUILD
            if (rc != MCIERR_SUCCESS) {
                printf("Could not stop DART playback!\n");
                fflush(stdout);
            }
#endif
        }
        // Close event semaphore
        if (_this->hidden->hevAudioBufferPlayed) {
            DosCloseEventSem(_this->hidden->hevAudioBufferPlayed);
            _this->hidden->hevAudioBufferPlayed = 0;
        }
        // Free memory of buffer descriptions
        for (i = 0; i < _this->hidden->iCurrNumBufs; i++) {
            SDL_free((void *) (_this->hidden->pMixBuffers[i].ulUserParm));
            _this->hidden->pMixBuffers[i].ulUserParm = 0;
        }
        _this->hidden->iCurrNumBufs = 0;

        // Deallocate buffers
        if (_this->hidden->iCurrDeviceOrd) {
            rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_BUFFER,
                                MCI_WAIT | MCI_DEALLOCATE_MEMORY,
                                &(_this->hidden->BufferParms), 0);
        }
        // Free bufferlist
        if (_this->hidden->pMixBuffers != NULL) {
            SDL_free(_this->hidden->pMixBuffers);
            _this->hidden->pMixBuffers = NULL;
        }
        // Close dart
        if (_this->hidden->iCurrDeviceOrd) {
            rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_CLOSE,
                                MCI_WAIT, &(GenericParms), 0);
        }
        _this->hidden->iCurrDeviceOrd = 0;

        SDL_free(_this->hidden);
        _this->hidden = NULL;
    }
}
Example #21
0
File: thread.c Project: Tilka/vlc
void vlc_timer_destroy (vlc_timer_t timer)
{
    if (timer->htimer != NULLHANDLE)
        DosStopTimer (timer->htimer);

    timer->quit = true;
    DosPostEventSem (timer->hev);
    DosWaitThread (&timer->tid, DCWW_WAIT);
    DosCloseEventSem (timer->hev);

    free (timer);
}
Example #22
0
File: thread.c Project: Tilka/vlc
static int vlc_clone_attr (vlc_thread_t *p_handle, bool detached,
                           void *(*entry) (void *), void *data, int priority)
{
    struct vlc_thread *th = malloc (sizeof (*th));
    if (unlikely(th == NULL))
        return ENOMEM;
    th->entry = entry;
    th->data = data;
    th->detached = detached;
    th->killable = false; /* not until vlc_entry() ! */
    th->killed = false;
    th->cleaners = NULL;

    if( DosCreateEventSem (NULL, &th->cancel_event, 0, FALSE))
        goto error;
    if( DosCreateEventSem (NULL, &th->done_event, 0, FALSE))
        goto error;

    th->tid = _beginthread (vlc_entry, NULL, 1024 * 1024, th);
    if((int)th->tid == -1)
        goto error;

    if (p_handle != NULL)
        *p_handle = th;

    if (priority)
        DosSetPriority(PRTYS_THREAD,
                       HIBYTE(priority),
                       LOBYTE(priority),
                       th->tid);

    return 0;

error:
    DosCloseEventSem (th->cancel_event);
    DosCloseEventSem (th->done_event);
    free (th);

    return ENOMEM;
}
Example #23
0
static BOOL _sendQuery(PGROPDATA pGrop, PGROPQUERY pQuery, BOOL fPrivateEvSem)
{
  ULONG      ulRC;
  BOOL       fSuccess;
  PTIB       tib;
  PPIB       pib;

  DosGetInfoBlocks( &tib, &pib );
  if ( tib->tib_ptib2->tib2_ultid == pGrop->tid )
  {
    // Query send from callback function.
    debug( "Query send from callback function." );

    pQuery->hevReady = NULLHANDLE;
    _wmGropQuery( pGrop, pQuery );
    return pQuery->fSuccess;
/*    return (BOOL)WinSendMsg( pGrop->hwnd, WM_GROP_QUERY, MPFROMP( pQuery ), 0 )
             && pQuery->fSuccess;*/
  }

  if ( fPrivateEvSem )
  {
    ulRC = DosCreateEventSem( NULL, &pQuery->hevReady, 0, FALSE );
    if ( ulRC != NO_ERROR )
    {
      debug( "DosCreateEventSem(), rc = %u.", ulRC );
      return FALSE;
    }
  }
  else
    pQuery->hevReady = pGrop->hevReady;

  fSuccess = WinPostMsg( pGrop->hwnd, WM_GROP_QUERY, MPFROMP( pQuery ), 0 );
  if ( !fSuccess )
  {
    debug( "WinPostMsg() failed" );
  }
  else
  {
    ulRC = DosWaitEventSem( pQuery->hevReady, 3000 );
    if ( ulRC != NO_ERROR )
    {
      debug( "DosWaitEventSem(), rc = %u.", ulRC );
    }
    fSuccess = pQuery->fSuccess;
  }

  if ( fPrivateEvSem )
    DosCloseEventSem( pQuery->hevReady );

  return fSuccess;
}
Example #24
0
int pthread_cond_destroy(pthread_cond_t *cond)
{
   APIRET   rc;

   do {
      rc = DosCloseEventSem(cond->semaphore);
      if (rc == 301) DosPostEventSem(cond->semaphore);
   } while (rc == 301);
   if (rc)
      return EINVAL;

	return 0;
}
Example #25
0
int GUI::ClosePipe(int id) {
  if ((id < 0) || (id > MAX_PIPES)) return -1;

  if (Pipes[id].used == 0) return -1;

  if (Pipes[id].reading == 1) {
    Pipes[id].DoTerm = 1;
    DosPostEventSem(Pipes[id].ResumeRead);
    DosWaitThread(&Pipes[id].tid, DCWW_WAIT);
  }
  free(Pipes[id].buffer);
  free(Pipes[id].Command);
  DosCloseEventSem(Pipes[id].NewData);
  DosCloseEventSem(Pipes[id].ResumeRead);
  DosCloseMutexSem(Pipes[id].Access);

  //    fprintf(stderr, "Pipe Close: %d\n", id);
  Pipes[id].used = 0;

  // ConContinue();
  return Pipes[id].RetCode;
}
Event::~Event ( ) {

   if ( Handle ) {
      #ifdef __OS2__
         DosCloseEventSem ( Handle ) ;
      #else
         CloseHandle ( Handle ) ;
      #endif
   } /* endif */

   if ( Tag ) free ( Tag ) ;

} /* endmethod */
Example #27
0
int PutClipText(ClipData *cd) {
    int rc;
    ULONG PostCount;
    char *mem;
    
    rc = DosOpenMutexSem(SEM_PREFIX "CLIPSYN", &hmtxSyn);
    if (rc != 0) return -1;
/*    rc = DosOpenEventSem(SEM_PREFIX "CLIPGET", &hevGet);*/
/*    if (rc != 0) return -1;*/
    rc = DosOpenEventSem(SEM_PREFIX "CLIPPUT", &hevPut);
    if (rc != 0) return -1;
    rc = DosOpenEventSem(SEM_PREFIX "CLIPEND", &hevEnd);
    if (rc != 0) return -1;
    
    DosRequestMutexSem(hmtxSyn, SEM_INDEFINITE_WAIT);
    DosResetEventSem(hevEnd, &PostCount);
    if (0 == DosAllocSharedMem((void **)&mem,
                               MEM_PREFIX "CLIPDATA",
                               cd->fLen + 5,
                               PAG_COMMIT | PAG_READ | PAG_WRITE))
    {
        ULONG L = cd->fLen;
        memcpy((void *)mem, (void *)&L, 4);
        strcpy(mem + 4, cd->fChar);
    }
    DosPostEventSem(hevPut);
    DosWaitEventSem(hevEnd, SEM_INDEFINITE_WAIT);
    DosPostEventSem(hevPut);
    DosReleaseMutexSem(hmtxSyn);
    DosCloseEventSem(hevPut);
/*    DosCloseEventSem(hevGet); */
    DosCloseEventSem(hevEnd);
    DosCloseMutexSem(hmtxSyn);
    if (mem)
        DosFreeMem(mem);
    return 0;
    
}
Example #28
0
void scsi_close_device
	(
	)
	{
	if (postSema)
		DosCloseEventSem(postSema);	// Close event semaphore.
	postSema = 0;
	if (driver_handle)			// Close driver.
		DosClose(driver_handle);
	driver_handle = 0;
	if (buffer)				// Free buffer.
		DosFreeMem(buffer);
	buffer = 0;
	}
Example #29
0
static apr_status_t thread_cond_cleanup(void *data)
{
    apr_thread_cond_t *cv = data;

    if (cv->semaphore) {
        DosCloseEventSem(cv->semaphore);
    }

    if (cv->mutex) {
        DosCloseMutexSem(cv->mutex);
    }

    return APR_SUCCESS;
}
Example #30
0
BOOL _System decoder_uninit( void *pvPluginWork )
{
    PLUGINWORK *pPluginWork = (PLUGINWORK *)pvPluginWork;
    ULONG ulTmp;

    if (pvPluginWork) {
        pPluginWork->fTerminate = TRUE;

        if (pPluginWork->hevThreadTrigger) {
            DosResetEventSem( pPluginWork->hevThreadA, &ulTmp );
            pPluginWork->fTerminate = TRUE;
            DosPostEventSem( pPluginWork->hevThreadTrigger );
            DosWaitEventSem( pPluginWork->hevThreadA, 20000 );
            DosCloseEventSem( pPluginWork->hevThreadTrigger );
        }

        if (pPluginWork->hevThreadA) {
            DosCloseEventSem( pPluginWork->hevThreadA );
        }
        free( pvPluginWork );
    }
    return 0;
}