本文整理匯總了C++中DosPostEventSem函數的典型用法代碼示例。如果您正苦於以下問題:C++ DosPostEventSem函數的具體用法?C++ DosPostEventSem怎麽用?C++ DosPostEventSem使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DosPostEventSem函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: BeginStop
/****************************************************************\
* Routine to stop semaphore example. *
*--------------------------------------------------------------*
* *
* Name: BeginStop(pfAutoMode) *
* *
* Purpose: Posts stop event semaphore to signal threads to *
* die. Also posts event to stop Auto mode if *
* necessary. Then waits for threads to complete, *
* Creates thread StopSemaphore which posts stop *
* event and waits for child threads. *
* *
* Usage: Called in file usercmd.c when the user selects *
* Stop from the semaphore menu. *
* *
* Method: Execs thread to do waits so that message thread *
* doesn't hang. *
* Returns: *
* *
\****************************************************************/
VOID BeginStop (PULONG pfAutoMode)
{
ULONG rc;
TID tidLocal;
rc = DosPostEventSem(hevStop);
if (rc)
{
SemError("DosPostEventSem",rc);
return;
}
if (*pfAutoMode)
{
rc = DosPostEventSem(hevStopAuto);
if (rc)
{
SemError("DosPostEventSem",rc);
}
}
rc = DosCreateThread((PTID)&tidLocal, (PFNTHREAD)StopSemaphore,
(ULONG)pfAutoMode,(ULONG)0,(ULONG) STACKSIZE);
if (rc)
{
SemError("DosCreateThread",rc);
}
return;
}
示例2: SignalUserEvent
/****************************************************************\
* 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;
}
示例3: GetClipText
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;
}
示例4: ReadLoopThread
void APIENTRY ReadLoopThread()
{
THREAD *pstThd = pstThread;
CONFIG *pCfg = &pstThd->stCfg;
THREADCTRL *pThread = &pstThd->stThread;
BOOL bReadComplete;
CHAR *pString;
APIRET rc;
BOOL bSkipRead = FALSE;
char szMessage[80];
ULONG ulStringLength;
ULONG ulPostCount;
// DosSetPriority(PRTYS_THREAD,PRTYC_FOREGROUNDSERVER,-28L,0);
DosSetPriority(PRTYS_THREAD,PRTYC_REGULAR,-10L,0);
ulStringLength = pCfg->wReadStringLength;
DosAllocMem((PPVOID)&pString,10010,(PAG_COMMIT | PAG_WRITE | PAG_READ));
while (!pThread->bStopThread)
{
if (ulStringLength != pCfg->wReadStringLength)
{
DosFreeMem(pString);
ulStringLength = pCfg->wReadStringLength;
DosAllocMem((PPVOID)&pString,(ulStringLength + 10),(PAG_COMMIT | PAG_WRITE | PAG_READ));
}
if (pCfg->bHalfDuplex)
{
while ((rc = DosWaitEventSem(hevStartReadSem,10000)) != 0)
if (rc == ERROR_SEM_TIMEOUT)
{
ErrorNotify(pstThd,"Read start semaphore timed out");
bSkipRead = TRUE;
}
else
{
sprintf(szMessage,"Read start semaphore error - rc = %u",rc);
ErrorNotify(pstThd,szMessage);
}
DosResetEventSem(hevStartReadSem,&ulPostCount);
}
if (bSkipRead)
bSkipRead = FALSE;
else
{
if (!pCfg->bReadCharacters)
bReadComplete = ReadString(pstThd,pString);
else
bReadComplete = ReadCharacters(pstThd,pString);
if (bReadComplete)
DosPostEventSem(hevStartWriteSem);
}
}
DosFreeMem(pString);
DosPostEventSem(hevKillReadThreadSem);
DosExit(EXIT_THREAD,0);
}
示例5: _PR_MD_POST_SEM
void
_PR_MD_POST_SEM(_MDSemaphore *md)
{
int rv;
rv = DosPostEventSem(md->sem);
PR_ASSERT(rv == NO_ERROR);
}
示例6: begin_thread_helper
static void APIENTRY begin_thread_helper( thread_args *td )
/*********************************************************/
{
thread_fn *rtn;
void *arg;
EXCEPTIONREGISTRATIONRECORD xcpt;
thread_data *tdata;
rtn = td->rtn;
arg = td->argument;
tdata = __alloca( __ThreadDataSize );
memset( tdata, 0, __ThreadDataSize );
// tdata->__allocated = 0;
tdata->__data_size = __ThreadDataSize;
if( !__Is_DLL ) {
if( !__OS2AddThread( *_threadid, tdata ) ) return;
}
DosPostEventSem( td->event );
_fpreset();
__XCPTHANDLER = &xcpt;
__sig_init_rtn();
(*rtn)( arg );
_endthread();
}
示例7: avcodec_thread_execute
int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size){
ThreadContext *c= s->thread_opaque;
int i;
assert(s == c->avctx);
assert(count <= s->thread_count);
/* note, we can be certain that this is not called with the same AVCodecContext by different threads at the same time */
for(i=0; i<count; i++){
c[i].arg= (char*)arg + i*size;
c[i].func= func;
c[i].ret= 12345;
DosPostEventSem(c[i].work_sem);
// ReleaseSemaphore(c[i].work_sem, 1, 0);
}
for(i=0; i<count; i++){
DosWaitEventSem(c[i].done_sem,SEM_INDEFINITE_WAIT);
// WaitForSingleObject(c[i].done_sem, INFINITE);
c[i].func= NULL;
if(ret) ret[i]= c[i].ret;
}
return 0;
}
示例8: DrvMountDrivesThread
void DrvMountDrivesThread( void * hev)
{
ULONG rc;
HMODULE hmod = 0;
pRediscover_PRMs pfn = 0;
char * pErr = 0;
char szErr[16];
rc = DosLoadModule( szErr, sizeof(szErr), "LVM", &hmod);
if (rc)
pErr = "DosLoadModule";
else {
rc = DosQueryProcAddr( hmod, 0, "Rediscover_PRMs", (PFN*)&pfn);
if (rc)
pErr = "DosQueryProcAddr";
else {
pfn( &rc);
if (rc)
pErr = "Rediscover_PRMs";
}
rc = DosFreeModule( hmod);
if (rc && !pErr)
pErr = "DosFreeModule";
}
if (pErr)
printf( "DrvMountDrivesThread - %s - rc= %lx\n", pErr, rc);
rc = DosPostEventSem( (HEV)hev);
if (rc)
printf( "DrvMountDrivesThread - DosPostEventSem - rc= %lx\n", rc);
return;
}
示例9: WPSamFolder_wpSaveState
SOM_Scope BOOL SOMLINK WPSamFolder_wpSaveState (WPSamF *somSelf)
{
BOOL bRC = TRUE;
WPSamFData *somThis = WPSamFGetData (somSelf);
WPSamFMethodDebug ("WPSamF","WPSamFolder_wpSaveState");
bRC &= parent_wpSaveState (somSelf);
_ulChiffreKey = (ULONG) _wpQueryHandle (somSelf);
bRC &= _wpSaveLong (somSelf, CLASSNAME, KEY_ZEITPUNKT2,
_ulZeitpunkt2 ^ (_ulChiffreKey + 0x87654321));
bRC &= _wpSaveLong (somSelf, CLASSNAME, KEY_ZEITPUNKT1,
_ulZeitpunkt1 ^ (_ulChiffreKey + _ulZeitpunkt2));
bRC &= _wpSaveLong (somSelf, CLASSNAME, KEY_FLAG, _ulFlag);
if (bRC == FALSE)
{
DebugE (D_SOM, "_wpSaveState", "Failed!");
MessageBox (IDS_SAVESTATEFAILED, MBTITLE_ERROR, MB_ENTER | MB_ERROR);
}
if (_wpIsCurrentDesktop (somSelf))
{
DosPostEventSem(hevPrfResetLock);
DebugE (D_SOM, "_wpSaveState", "PrfReset unlocked");
}
return (bRC);
}
示例10: LoopThread
void APIENTRY LoopThread()
{
THREAD *pstThd = pstThread;
CONFIG *pCfg = &pstThd->stCfg;
THREADCTRL *pThread = &pstThd->stThread;
int iError;
CHAR szMessage[81];
DCB stComDCB;
// DosSetPriority(PRTYS_THREAD,PRTYC_FOREGROUNDSERVER,-32L,0);
DosSetPriority(PRTYS_THREAD,PRTYC_REGULAR,-14L,0);
while (!pThread->bStopThread)
{
switch (pCfg->wSimulateType)
{
case TERMINAL:
GetDCB(&stIOctlInst,pstThd->hCom,&stComDCB);
stComDCB.Flags3 &= ~F3_RTO_MASK;
stComDCB.Flags3 |= F3_WAIT_SOMETHING;
stComDCB.ReadTimeout = 100;
SendDCB(&stIOctlInst,pstThd->hCom,&stComDCB);
TerminalRead(pstThd);
break;
case STRING_TRANSFER:
DoStringTransfer(pstThd);
break;
}
}
DosPostEventSem(hevKillThreadSem);
DosExit(EXIT_THREAD,0);
}
示例11: _cairo_os2_surface_release_source_image
static void
_cairo_os2_surface_release_source_image (void *abstract_surface,
cairo_image_surface_t *image,
void *image_extra)
{
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;
}
/* Decrease Lend counter! */
DosRequestMutexSem (local_os2_surface->hmtx_use_private_fields, SEM_INDEFINITE_WAIT);
if (local_os2_surface->pixel_array_lend_count > 0)
local_os2_surface->pixel_array_lend_count--;
DosPostEventSem (local_os2_surface->hev_pixel_array_came_back);
DosReleaseMutexSem (local_os2_surface->hmtx_use_private_fields);
return;
}
示例12: pthread_alarm
unsigned pthread_alarm(unsigned sec)
{
int ret = 0;
pthread_t self = pthread_self();
if (sec == 0) { /* cancel pending alarm */
self->alarm_timeout = 0;
if (self->alarm_timer)
DosStopTimer(self->alarm_timer);
if (self->alarm_event)
DosPostEventSem(self->alarm_event);
} else
if (sec > 0) {
if (self->alarm_timer && self->alarm_thread) {
DosStopTimer(self->alarm_timer);
} else {
DosCreateEventSem(NULL,&self->alarm_event,DC_SEM_SHARED,FALSE);
pthread_create(&self->alarm_thread,NULL,_alarm_thread,(void *)self);
}
DosAsyncTimer(sec * 1000L,(HSEM)self->alarm_event,&self->alarm_timer);
self->alarm_timeout = sec;
} else {
ret = EINVAL;
errno = EINVAL;
}
return (ret);
}
示例13: return
unsigned long Event::Post ( ) {
if ( Handle == 0 )
return ( (unsigned long) 0xFFFFFFFF ) ;
if ( DebugFlag ) Log ( "Event(%s)::Post.", Tag?Tag:"" ) ;
BOOL Result = FALSE ;
#ifdef __OS2__
APIRET Status = DosPostEventSem ( Handle ) ;
if ( Status && ( Status != ERROR_ALREADY_POSTED ) )
Result = FALSE ;
else
Result = TRUE ;
#else
Result = SetEvent ( Handle ) ;
#endif
return ( Result ) ;
} /* endmethod */
示例14: DARTEventFunc
LONG APIENTRY DARTEventFunc(ULONG ulStatus,
PMCI_MIX_BUFFER pBuffer,
ULONG ulFlags)
{
if (ulFlags && MIX_WRITE_COMPLETE)
{
pMixBufferDesc pBufDesc;
if (pBuffer)
{
pBufDesc = (pMixBufferDesc) (*pBuffer).ulUserParm;
if (pBufDesc)
{
SDL_AudioDevice *pSDLAudioDevice = pBufDesc->pSDLAudioDevice;
pBufDesc->iBufferUsage = BUFFER_EMPTY;
if (pSDLAudioDevice)
DosPostEventSem(pSDLAudioDevice->hidden->hevAudioBufferPlayed);
}
}
}
return TRUE;
}
示例15: Reader
void _System Reader(ULONG arg)
{
int data;
ULONG read;
int new_index;
APIRET rc;
OverRun = FALSE;
for( ;; ) {
rc = DosRead( ComPort, &data, 1, &read );
if( rc != NO_ERROR )
break;
if( read == 1 ) {
new_index = ReadBuffAdd + 1;
new_index &= BSIZE-1;
if( new_index == ReadBuffRemove ) {
OverRun = TRUE;
} else {
ReadBuff[ ReadBuffAdd ] = data;
ReadBuffAdd = new_index;
}
DosPostEventSem( ReadSemaphore );
}
}
}