Ignore:
Timestamp:
Jun 21, 2001, 11:07:54 PM (24 years ago)
Author:
sandervl
Message:

semaphore updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/hmsemaphore.cpp

    r6049 r6060  
    1 /* $Id: hmsemaphore.cpp,v 1.4 2001-06-19 10:50:25 sandervl Exp $ */
     1/* $Id: hmsemaphore.cpp,v 1.5 2001-06-21 21:07:54 sandervl Exp $ */
    22
    33/*
     
    88 * TODO: No inheritance when CreateSemaphore is called for existing named event semaphore?
    99 *       (see HMCreateSemaphore in handlemanager.cpp)
     10 * TODO: OpenSemaphore does not work right now! initialcount/maximumcount)
    1011 * TODO: Name collisions with files & mutex not allowed. Check if this can happen in OS/2
    1112 * TODO: Does NOT work for sharing semaphores between processes!!
     
    3334#ifdef USE_OS2SEMAPHORES
    3435#define INCL_DOSSEMAPHORES
     36#define INCL_DOSERRORS
    3537#include <os2wrap.h>
    3638#include <win32type.h>
     
    115117      lpszSemaphoreName = szSemName;
    116118  }
    117   //Manual reset means all threads waiting on the event semaphore will be
    118   //unblocked and the app must manually reset the event semaphore
    119   //Automatic reset -> only one waiting thread unblocked & state reset
    120119  rc = DosCreateEventSem(lpszSemaphoreName, &hev, DCE_POSTONE, lInitialCount);
    121120
     
    127126  pHMHandleData->dwAccess  = SEMAPHORE_ALL_ACCESS_W;
    128127  pHMHandleData->dwFlags   = lMaximumCount;
     128  pHMHandleData->dwCreation= lInitialCount;
    129129  pHMHandleData->hHMHandle = hev;
    130130  return ERROR_SUCCESS_W;
     
    176176  char szSemName[CCHMAXPATH];
    177177
     178  //TODO: NOT WORKING (initialcount/maximumcount)
    178179  dprintf(("KERNEL32: HandleManager::Semaphore::OpenSemaphore(%08xh,%08xh,%s)\n",
    179180           pHMHandleData,
     
    293294  }
    294295  pHMHandleData->dwAccess  = fdwAccess;
    295   pHMHandleData->dwFlags   = pHMSrcHandle->dwFlags; //lMaximumCount;
     296  pHMHandleData->dwFlags   = pHMSrcHandle->dwFlags;    //lMaximumCount;
     297  pHMHandleData->dwCreation= pHMSrcHandle->dwCreation; //lInitialCount;
    296298  pHMHandleData->hHMHandle = hev;
    297299  SetLastError(ERROR_SUCCESS_W);
    298300  return TRUE;
     301}
     302#endif
     303
     304#ifdef USE_OS2SEMAPHORES
     305/*****************************************************************************
     306 * Name      : DWORD HMDeviceSemaphoreClass::WaitForSingleObject
     307 * Purpose   : object synchronization
     308 * Parameters: PHMHANDLEDATA pHMHandleData
     309 *             DWORD dwTimeout
     310 * Variables :
     311 * Result    : API returncode
     312 * Remark    :
     313 * Status    :
     314 *
     315 * Author    : SvL
     316 *****************************************************************************/
     317
     318DWORD HMDeviceSemaphoreClass::WaitForSingleObject(PHMHANDLEDATA pHMHandleData,
     319                                               DWORD         dwTimeout)
     320{
     321 DWORD rc;
     322
     323  dprintf2(("KERNEL32: HMDeviceSemaphoreClass::WaitForSingleObject(%08xh %08xh)",
     324            pHMHandleData->hHMHandle, dwTimeout));
     325
     326  if(!(pHMHandleData->dwAccess & SYNCHRONIZE_W) )
     327  {
     328      dprintf(("ERROR: Access denied!!"));
     329      SetLastError(ERROR_ACCESS_DENIED_W);
     330      return WAIT_FAILED_W;
     331  }
     332
     333  rc = DosWaitEventSem(pHMHandleData->hHMHandle, dwTimeout);
     334  if(rc && rc != ERROR_INTERRUPT && rc != ERROR_TIMEOUT && rc != ERROR_SEM_OWNER_DIED) {
     335      dprintf(("DosWaitEventSem %x failed with rc %d", pHMHandleData->hHMHandle, rc));
     336      SetLastError(error2WinError(rc));
     337      return WAIT_FAILED_W;
     338  }
     339  SetLastError(ERROR_SUCCESS_W);
     340  if(rc == ERROR_INTERRUPT || rc == ERROR_SEM_OWNER_DIED) {
     341      return WAIT_ABANDONED_W;
     342  }
     343  else
     344  if(rc == ERROR_TIMEOUT) {
     345      return WAIT_TIMEOUT_W;
     346  }
     347  return WAIT_OBJECT_0_W;
     348}
     349#endif
     350
     351#ifdef USE_OS2SEMAPHORES
     352/*****************************************************************************
     353 * Name      : DWORD HMDeviceSemaphoreClass::WaitForSingleObjectEx
     354 * Purpose   : object synchronization
     355 * Parameters: PHMHANDLEDATA pHMHandleData
     356 *             DWORD dwTimeout
     357 *             BOOL  fAlertable
     358 * Variables :
     359 * Result    : API returncode
     360 * Remark    :
     361 * Status    :
     362 *
     363 * Author    : SvL
     364 *****************************************************************************/
     365
     366DWORD HMDeviceSemaphoreClass::WaitForSingleObjectEx(PHMHANDLEDATA pHMHandleData,
     367                                                 DWORD         dwTimeout,
     368                                                 BOOL          fAlertable)
     369{
     370    dprintf2(("KERNEL32: HMDeviceSemaphoreClass::WaitForSingleObjectEx(%08xh,%08h,%08xh) not implemented correctly.\n",
     371              pHMHandleData->hHMHandle, dwTimeout, fAlertable));
     372
     373    if(!(pHMHandleData->dwAccess & SYNCHRONIZE_W) )
     374    {
     375        dprintf(("ERROR: Access denied!!"));
     376        SetLastError(ERROR_ACCESS_DENIED_W);
     377        return WAIT_FAILED_W;
     378    }
     379
     380    return WaitForSingleObject(pHMHandleData, dwTimeout);
     381}
     382#endif
     383
     384#ifdef USE_OS2SEMAPHORES
     385/*****************************************************************************
     386 * Name      : BOOL HMDeviceSemaphoreClass::MsgWaitForMultipleObjects
     387 * Purpose   :
     388 * Variables :
     389 * Result    :
     390 * Remark    :
     391 * Status    :
     392 *
     393 * Author    : SvL
     394 *****************************************************************************/
     395DWORD HMDeviceSemaphoreClass::MsgWaitForMultipleObjects(PHMHANDLEDATA pHMHandleData,
     396                                                        DWORD      nCount,
     397                                                        PHANDLE    pHandles,
     398                                                        BOOL       fWaitAll,
     399                                                        DWORD      dwMilliseconds,
     400                                                        DWORD      dwWakeMask)
     401{
     402    dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::MsgWaitForMultipleObjects %08x %d %x %d %d %x",
     403              pHMHandleData->hHMHandle, nCount, pHandles, fWaitAll, dwMilliseconds, dwWakeMask));
     404
     405    if(!(pHMHandleData->dwAccess & SYNCHRONIZE_W) )
     406    {
     407        dprintf(("ERROR: Access denied!!"));
     408        SetLastError(ERROR_ACCESS_DENIED_W);
     409        return WAIT_FAILED_W;
     410    }
     411
     412    return WAIT_FAILED_W;
     413}
     414#endif
     415
     416#ifdef USE_OS2SEMAPHORES
     417/*****************************************************************************
     418 * Name      : BOOL HMDeviceSemaphoreClass::WaitForMultipleObjects
     419 * Purpose   :
     420 * Variables :
     421 * Result    :
     422 * Remark    :
     423 * Status    :
     424 *
     425 * Author    : SvL
     426 *****************************************************************************/
     427DWORD HMDeviceSemaphoreClass::WaitForMultipleObjects(PHMHANDLEDATA pHMHandleData,
     428                                                 DWORD   cObjects,
     429                                                 PHANDLE lphObjects,
     430                                                 BOOL    fWaitAll,
     431                                                 DWORD   dwTimeout)
     432{
     433    dprintf(("KERNEL32: ERROR: HandleManager::DeviceHandler::WaitForMultipleObjects %08x %d %x %d %x",
     434              pHMHandleData->hHMHandle, cObjects, lphObjects, fWaitAll, dwTimeout));
     435
     436    if(!(pHMHandleData->dwAccess & SYNCHRONIZE_W) )
     437    {
     438        dprintf(("ERROR: Access denied!!"));
     439        SetLastError(ERROR_ACCESS_DENIED_W);
     440        return WAIT_FAILED_W;
     441    }
     442
     443    return WAIT_FAILED_W;
    299444}
    300445#endif
Note: See TracChangeset for help on using the changeset viewer.