Changeset 3206 for trunk/src


Ignore:
Timestamp:
Mar 23, 2000, 8:23:48 PM (25 years ago)
Author:
sandervl
Message:

mutex fixes + added vsemaphore class

Location:
trunk/src/kernel32
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kernel32/KERNEL32.DEF

    r3074 r3206  
    1 ; $Id: KERNEL32.DEF,v 1.74 2000-03-10 16:11:59 sandervl Exp $
     1; $Id: KERNEL32.DEF,v 1.75 2000-03-23 19:23:46 sandervl Exp $
    22
    33;Created by BLAST for IBM's compiler
     
    979979
    980980;VMutex
    981    enter__6VMutexFUl                                              @1204
    982    leave__6VMutexF                                             @1205
    983    __ct__6VMutexFi                                                @1206
     981   enter__6VMutexFUlPUl                                           @1204
     982   leave__6VMutexFPUl                                             @1205
     983   __ct__6VMutexFiPUl                                             @1206
    984984   __dt__6VMutexFv                                                @1207
    985985
     
    10631063;code memory allocation
    10641064    _cmalloc__FUi                                                 @1272
     1065
     1066;VSemaphore
     1067   wait__10VSemaphoreFUlPUl                                       @1280
     1068   post__10VSemaphoreFPUl                                         @1281
     1069   reset__10VSemaphoreFPUl                                        @1282
     1070   __ct__10VSemaphoreFiPUl                                        @1283
     1071   __dt__10VSemaphoreFv                                           @1284
    10651072
    10661073;Export for MSACM32
  • trunk/src/kernel32/dbglocal.cpp

    r3128 r3206  
    1 /* $Id: dbglocal.cpp,v 1.4 2000-03-16 19:20:37 sandervl Exp $ */
     1/* $Id: dbglocal.cpp,v 1.5 2000-03-23 19:23:44 sandervl Exp $ */
    22
    33/*
     
    114114"queue",
    115115"hmthread",
    116 "hmprocess"
     116"hmprocess",
     117"vsemaphore"
    117118};
    118119//******************************************************************************
  • trunk/src/kernel32/dbglocal.h

    r3128 r3206  
    1 /* $Id: dbglocal.h,v 1.4 2000-03-16 19:20:37 sandervl Exp $ */
     1/* $Id: dbglocal.h,v 1.5 2000-03-23 19:23:45 sandervl Exp $ */
    22
    33/*
     
    115115#define DBG_hmthread       94
    116116#define DBG_hmprocess      95
    117 #define DBG_MAXFILES       96
     117#define DBG_VSemaphore     96
     118#define DBG_MAXFILES       97
    118119
    119120extern USHORT DbgEnabled[DBG_MAXFILES];
  • trunk/src/kernel32/makefile

    r3128 r3206  
    1 # $Id: makefile,v 1.91 2000-03-16 19:20:39 sandervl Exp $
     1# $Id: makefile,v 1.92 2000-03-23 19:23:46 sandervl Exp $
    22
    33#
     
    2020# Flag overloads and local macros.
    2121CLEANEXTRAS = kernelrsrc.asm
     22
     23#CFLAGS   = $(CFLAGS) -DDEBUG
     24#CXXFLAGS = $(CXXFLAGS) /Fa+
    2225
    2326
     
    5962$(OBJDIR)\os2heap.OBJ \
    6063$(OBJDIR)\vmutex.OBJ \
     64$(OBJDIR)\vsemaphore.OBJ \
    6165$(OBJDIR)\initterm.OBJ \
    6266$(OBJDIR)\handlemanager.OBJ \
  • trunk/src/kernel32/mmap.cpp

    r3059 r3206  
    1 /* $Id: mmap.cpp,v 1.36 2000-03-09 19:03:19 sandervl Exp $ */
     1/* $Id: mmap.cpp,v 1.37 2000-03-23 19:23:47 sandervl Exp $ */
    22
    33/*
     
    3535#include "dbglocal.h"
    3636
     37//NOTE: This must be in the local data segment -> if a shared semaphore was
     38//      created by a different process, the handle returned by DosOpenMutexSem
     39//      will be returned in hGlobalMapMutex
     40HMTX             hGlobalMapMutex = 0;
     41
    3742//Global DLL Data
    3843#pragma data_seg(_GLOBALDATA)
    3944Win32MemMap     *Win32MemMap::memmaps = NULL;
    40 VMutex           globalmapMutex(VMUTEX_SHARED);
     45VMutex           globalmapMutex(VMUTEX_SHARED, &hGlobalMapMutex);
    4146#pragma data_seg()
    4247VMutex           globalviewMutex;
     
    4954               : nrMappings(0), pMapping(NULL), mMapAccess(0), referenced(0), image(0)
    5055{
    51   globalmapMutex.enter();
     56  globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex);
    5257  next    = memmaps;
    5358  memmaps = this;
    54   globalmapMutex.leave();
     59  globalmapMutex.leave(&hGlobalMapMutex);
    5560
    5661  hMemFile   = hfile;
     
    7277               : nrMappings(0), pMapping(NULL), mMapAccess(0), referenced(0)
    7378{
    74   globalmapMutex.enter();
     79  globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex);
    7580  next    = memmaps;
    7681  memmaps = this;
    77   globalmapMutex.leave();
     82  globalmapMutex.leave(&hGlobalMapMutex);
    7883
    7984  hMemFile   = -1;
     
    148153  mapMutex.leave();
    149154
    150   globalmapMutex.enter();
     155  globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex);
    151156  Win32MemMap *map = memmaps;
    152157
     
    165170        else    dprintf(("Win32MemMap::~Win32MemMap: map not found!! (%x)", this));
    166171  }
    167   globalmapMutex.leave();
     172  globalmapMutex.leave(&hGlobalMapMutex);
    168173}
    169174//******************************************************************************
     
    467472        return NULL;
    468473
    469   globalmapMutex.enter();
     474  globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex);
    470475  Win32MemMap *map = memmaps;
    471476
     
    477482        }
    478483  }
    479   globalmapMutex.leave();
     484  globalmapMutex.leave(&hGlobalMapMutex);
    480485  if(!map) dprintf(("Win32MemMap::findMap: couldn't find map %s", lpszName));
    481486  return map;
     
    485490Win32MemMap *Win32MemMap::findMap(ULONG address)
    486491{
    487   globalmapMutex.enter();
     492  globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex);
    488493  Win32MemMap *map = memmaps;
    489494
     
    498503        }
    499504  }
    500   globalmapMutex.leave();
     505  globalmapMutex.leave(&hGlobalMapMutex);
    501506  return map;
    502507}
  • trunk/src/kernel32/vmutex.cpp

    r2802 r3206  
    1 /* $Id: vmutex.cpp,v 1.8 2000-02-16 14:22:47 sandervl Exp $ */
     1/* $Id: vmutex.cpp,v 1.9 2000-03-23 19:23:47 sandervl Exp $ */
    22
    33/*
    44 * Mutex class
    55 *
    6  * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
     6 * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl)
    77 *
     8 *
     9 * NOTE: When creating a shared mutex object, you must call the ctor, enter &
     10 *       leave with a 2nd parameter (HMTX *). This mutex handle must be located
     11 *       in the local data segment of the dll.
     12 *       This enables other processes than the one that created the mutex object
     13 *       to access it
    814 *
    915 * Project Odin Software License can be found in LICENSE.TXT
    1016 *
    1117 */
    12 #define  INCL_DOSSEMAPHORES
     18#define INCL_DOSSEMAPHORES
     19#define INCL_DOSERRORS
    1320#include <os2wrap.h>    //Odin32 OS/2 api wrappers
    1421#include <vmutex.h>
     
    2128/******************************************************************************/
    2229/******************************************************************************/
    23 VMutex::VMutex(int fShared) : waiting(0)
     30VMutex::VMutex(int fShared, HMTX *phMutex) : waiting(0)
    2431{
    2532 APIRET rc;
    2633
     34  this->fShared = fShared;
    2735  rc = DosCreateMutexSem(NULL, &sem_handle, (fShared == VMUTEX_SHARED) ? DC_SEM_SHARED : 0, FALSE);
    2836  if(rc != 0) {
    2937    dprintf(("Error creating mutex %X\n", rc));
    3038    sem_handle = 0;
     39  }
     40  if(fShared) {
     41        *phMutex = sem_handle;
    3142  }
    3243}
     
    3849
    3950  if(sem_handle) {
    40     for(i=0;i<waiting;i++) {
    41         DosReleaseMutexSem(sem_handle);
    42     }
    43     DosCloseMutexSem(sem_handle);
     51        if(fShared != VMUTEX_SHARED) {
     52                for(i=0;i<waiting;i++) {
     53                        DosReleaseMutexSem(sem_handle);
     54                }
     55        }
     56        DosCloseMutexSem(sem_handle);
    4457  }
    4558}
    4659/******************************************************************************/
    4760/******************************************************************************/
    48 void VMutex::enter(ULONG timeout)
     61void VMutex::enter(ULONG timeout, HMTX *phMutex)
    4962{
     63 APIRET rc;
     64
     65  if(fShared == VMUTEX_SHARED && phMutex == NULL) {
     66        DebugInt3();
     67        return;
     68  }
    5069  if(sem_handle) {
    51     waiting++;
    52     DosRequestMutexSem(sem_handle, timeout);
    53     waiting--;
     70        if(fShared == VMUTEX_SHARED && *phMutex == 0) {
     71                //must open the shared semaphore first (other process created it)
     72                *phMutex = sem_handle;
     73                rc = DosOpenMutexSem(NULL, phMutex);
     74                if(rc) {
     75                        DebugInt3();
     76                }
     77        }
     78        waiting++;
     79        rc = DosRequestMutexSem((fShared == VMUTEX_SHARED) ? *phMutex : sem_handle, timeout);
     80        waiting--;
    5481  }
    5582}
    5683/******************************************************************************/
    5784/******************************************************************************/
    58 void VMutex::leave()
     85void VMutex::leave(HMTX *phMutex)
    5986{
    60   DosReleaseMutexSem(sem_handle);
     87  if((fShared == VMUTEX_SHARED && phMutex == NULL) ||
     88     (fShared == VMUTEX_SHARED && *phMutex == 0)) {
     89        DebugInt3();
     90        //should always call enter first...
     91        return;
     92  }
     93  DosReleaseMutexSem((fShared == VMUTEX_SHARED) ? *phMutex : sem_handle);
    6194}
    6295/******************************************************************************/
  • trunk/src/kernel32/winimagepeldr.cpp

    r3059 r3206  
    1 /* $Id: winimagepeldr.cpp,v 1.35 2000-03-09 19:03:22 sandervl Exp $ */
     1/* $Id: winimagepeldr.cpp,v 1.36 2000-03-23 19:23:48 sandervl Exp $ */
    22
    33/*
     
    11781178 ULONG nsize;
    11791179
     1180  if(!strcmp(apiname, "At"))
     1181        DebugInt3();
    11801182  if(nameexports == NULL) {
    11811183        nameExportSize= 4096;
     
    15181520        strcpy(tmp, name);
    15191521        apiname = tmp;
     1522        apilen  = 4;
    15201523  }
    15211524  else  apiname = name;
Note: See TracChangeset for help on using the changeset viewer.