Changeset 8203 for trunk/src/kernel32/mmap.cpp
- Timestamp:
- Apr 7, 2002, 5:44:11 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/mmap.cpp
r8121 r8203 1 /* $Id: mmap.cpp,v 1.5 4 2002-03-24 13:10:30sandervl Exp $ */1 /* $Id: mmap.cpp,v 1.55 2002-04-07 15:44:11 sandervl Exp $ */ 2 2 3 3 /* … … 29 29 #include <string.h> 30 30 #include <win\virtual.h> 31 #include < vmutex.h>31 #include <odincrt.h> 32 32 #include <handlemanager.h> 33 33 #include "mmap.h" … … 38 38 #include "dbglocal.h" 39 39 40 //NOTE: This must be in the local data segment -> if a shared semaphore was41 // created by a different process, the handle returned by DosOpenMutexSem42 // will be returned in hGlobalMapMutex43 HMTX hGlobalMapMutex = 0;44 45 40 //Global DLL Data 46 41 #pragma data_seg(_GLOBALDATA) 47 Win32MemMap 48 VMutex globalmapMutex(VMUTEX_SHARED, &hGlobalMapMutex);42 Win32MemMap *Win32MemMap::memmaps = NULL; 43 CRITICAL_SECTION_OS2 globalmapcritsect = {0}; 49 44 #pragma data_seg() 50 VMutex globalviewMutex;51 45 Win32MemMapView *Win32MemMapView::mapviews = NULL; 52 46 47 //****************************************************************************** 48 //****************************************************************************** 49 void InitializeMemMaps() 50 { 51 if(globalmapcritsect.hmtxLock == 0) { 52 dprintf(("InitializeMemMaps -> create shared critical section")); 53 DosInitializeCriticalSection(&globalmapcritsect, MEMMAP_CRITSECTION_NAME); 54 } 55 else { 56 dprintf(("InitializeMemMaps -> access shared critical section")); 57 DosAccessCriticalSection(&globalmapcritsect, MEMMAP_CRITSECTION_NAME); 58 } 59 } 53 60 //****************************************************************************** 54 61 //TODO: sharing between processes … … 57 64 : nrMappings(0), pMapping(NULL), mMapAccess(0), referenced(0), image(0) 58 65 { 59 globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex);66 DosEnterCriticalSection(&globalmapcritsect); 60 67 next = memmaps; 61 68 memmaps = this; 62 globalmapMutex.leave(&hGlobalMapMutex);69 DosLeaveCriticalSection(&globalmapcritsect); 63 70 64 71 hMemFile = hfile; … … 80 87 : nrMappings(0), pMapping(NULL), mMapAccess(0), referenced(0), image(0) 81 88 { 82 globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex);89 DosEnterCriticalSection(&globalmapcritsect); 83 90 next = memmaps; 84 91 memmaps = this; 85 globalmapMutex.leave(&hGlobalMapMutex);92 DosLeaveCriticalSection(&globalmapcritsect); 86 93 87 94 hMemFile = -1; … … 169 176 mapMutex.leave(); 170 177 171 globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex);178 DosEnterCriticalSection(&globalmapcritsect); 172 179 Win32MemMap *map = memmaps; 173 180 … … 186 193 else dprintf(("Win32MemMap::~Win32MemMap: map not found!! (%x)", this)); 187 194 } 188 globalmapMutex.leave(&hGlobalMapMutex);195 DosLeaveCriticalSection(&globalmapcritsect); 189 196 } 190 197 //****************************************************************************** … … 511 518 return NULL; 512 519 513 globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex);520 DosEnterCriticalSection(&globalmapcritsect); 514 521 Win32MemMap *map = memmaps; 515 522 … … 521 528 } 522 529 } 523 globalmapMutex.leave(&hGlobalMapMutex);530 DosLeaveCriticalSection(&globalmapcritsect); 524 531 if(!map) dprintf(("Win32MemMap::findMap: couldn't find map %s", lpszName)); 525 532 return map; … … 529 536 Win32MemMap *Win32MemMap::findMap(ULONG address) 530 537 { 531 globalmapMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalMapMutex);538 DosEnterCriticalSection(&globalmapcritsect); 532 539 Win32MemMap *map = memmaps; 533 540 … … 542 549 } 543 550 } 544 globalmapMutex.leave(&hGlobalMapMutex);551 DosLeaveCriticalSection(&globalmapcritsect); 545 552 return map; 546 553 } … … 553 560 554 561 //delete all maps created by this process 555 globalviewMutex.enter();562 DosEnterCriticalSection(&globalmapcritsect); 556 563 while(map) { 557 564 nextmap = map->next; … … 571 578 map = nextmap; 572 579 } 573 globalviewMutex.leave();580 DosLeaveCriticalSection(&globalmapcritsect); 574 581 } 575 582 //****************************************************************************** … … 630 637 dprintf(("Win32MemMapView::Win32MemMapView: created %x (alias for %x), size %d", pMapView, viewaddr, size)); 631 638 632 globalviewMutex.enter();639 DosEnterCriticalSection(&globalmapcritsect); 633 640 if(tmpview == NULL || tmpview->getViewAddr() > pMapView) { 634 641 next = mapviews; … … 645 652 tmpview->next = this; 646 653 } 647 globalviewMutex.leave();654 DosLeaveCriticalSection(&globalmapcritsect); 648 655 } 649 656 //****************************************************************************** … … 667 674 } 668 675 669 globalviewMutex.enter();676 DosEnterCriticalSection(&globalmapcritsect); 670 677 Win32MemMapView *view = mapviews; 671 678 … … 684 691 else dprintf(("Win32MemMapView::~Win32MemMapView: map not found!! (%x)", this)); 685 692 } 686 globalviewMutex.leave();693 DosLeaveCriticalSection(&globalmapcritsect); 687 694 } 688 695 //****************************************************************************** … … 690 697 void Win32MemMapView::deleteViews(Win32MemMap *map) 691 698 { 692 globalviewMutex.enter();699 DosEnterCriticalSection(&globalmapcritsect); 693 700 Win32MemMapView *view = mapviews, *nextview; 694 701 … … 698 705 if(view->getParentMap() == map) 699 706 { 700 globalviewMutex.leave();707 DosLeaveCriticalSection(&globalmapcritsect); 701 708 delete view; 702 globalviewMutex.enter();709 DosEnterCriticalSection(&globalmapcritsect); 703 710 } 704 711 view = nextview; 705 712 } 706 713 } 707 globalviewMutex.leave();714 DosLeaveCriticalSection(&globalmapcritsect); 708 715 } 709 716 //****************************************************************************** … … 716 723 if(mapviews == NULL) return NULL; 717 724 718 globalviewMutex.enter();725 DosEnterCriticalSection(&globalmapcritsect); 719 726 Win32MemMapView *view = mapviews; 720 727 ULONG ulViewAddr; … … 764 771 #endif 765 772 766 globalviewMutex.leave();773 DosLeaveCriticalSection(&globalmapcritsect); 767 774 768 775 if(pView) … … 777 784 Win32MemMapView *view = mapviews; 778 785 779 globalviewMutex.enter();786 DosEnterCriticalSection(&globalmapcritsect); 780 787 if(view != NULL) { 781 788 while(view) { … … 787 794 } 788 795 } 789 globalviewMutex.leave();796 DosLeaveCriticalSection(&globalmapcritsect); 790 797 return view; 791 798 }
Note:
See TracChangeset
for help on using the changeset viewer.