Skip to content

Commit 86c1d20

Browse files
committed
Remove allocMutex to avoid possible deadlocks
1 parent bf99541 commit 86c1d20

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

source/memory_mapping.cpp

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
// #define DEBUG_FUNCTION_LINE(x,...)
1414

15-
OSMutex allocMutex;
15+
//OSMutex allocMutex;
1616

1717
void runOnAllCores(CThread::Callback callback, void *callbackArg, int32_t iAttr = 0, int32_t iPriority = 16, int32_t iStackSize = 0x8000) {
1818
int32_t aff[] = {CThread::eAttributeAffCore2, CThread::eAttributeAffCore1, CThread::eAttributeAffCore0};
@@ -552,14 +552,14 @@ void MemoryMapping_setupMemoryMapping() {
552552
//readTestValuesFromMemory();
553553

554554
//runOnAllCores(writeSegmentRegister,&srTableCpy);
555-
OSInitMutex(&allocMutex);
555+
// OSInitMutex(&allocMutex);
556556

557557
memset(pageTableCpy, 0, sizePageTable);
558558
gMEMFreeToDefaultHeapForThreads(pageTableCpy);
559559
}
560560

561561
void *MemoryMapping_allocEx(uint32_t size, int32_t align, bool videoOnly) {
562-
OSLockMutex(&allocMutex);
562+
//OSLockMutex(&allocMutex);
563563
void *res = nullptr;
564564
for (int32_t i = 0; /* waiting for a break */; i++) {
565565
if (mem_mapping[i].physical_addresses == nullptr) {
@@ -587,7 +587,7 @@ void *MemoryMapping_allocEx(uint32_t size, int32_t align, bool videoOnly) {
587587
}
588588
}
589589
OSMemoryBarrier();
590-
OSUnlockMutex(&allocMutex);
590+
//OSUnlockMutex(&allocMutex);
591591
return res;
592592
}
593593

@@ -659,7 +659,7 @@ bool CheckMemExpHeap(MEMExpHeap *heap) {
659659
}
660660

661661
void MemoryMapping_checkHeaps() {
662-
OSLockMutex(&allocMutex);
662+
//OSLockMutex(&allocMutex);
663663
for (int32_t i = 0; /* waiting for a break */; i++) {
664664
if (mem_mapping[i].physical_addresses == nullptr) {
665665
break;
@@ -672,7 +672,7 @@ void MemoryMapping_checkHeaps() {
672672
#endif
673673
}
674674
}
675-
OSUnlockMutex(&allocMutex);
675+
//OSUnlockMutex(&allocMutex);
676676
}
677677

678678
void *MemoryMapping_alloc(uint32_t size, int32_t align) {
@@ -710,7 +710,7 @@ void MemoryMapping_free(void *ptr) {
710710
if (ptr == nullptr) {
711711
return;
712712
}
713-
OSLockMutex(&allocMutex);
713+
//OSLockMutex(&allocMutex);
714714
auto ptr_val = (uint32_t) ptr;
715715
for (int32_t i = 0; /* waiting for a break */; i++) {
716716
if (mem_mapping[i].physical_addresses == nullptr) {
@@ -723,15 +723,15 @@ void MemoryMapping_free(void *ptr) {
723723
}
724724
}
725725
OSMemoryBarrier();
726-
OSUnlockMutex(&allocMutex);
726+
//OSUnlockMutex(&allocMutex);
727727
}
728728

729729
uint32_t MemoryMapping_MEMGetAllocatableSize() {
730730
return MemoryMapping_MEMGetAllocatableSizeEx(4);
731731
}
732732

733733
uint32_t MemoryMapping_MEMGetAllocatableSizeEx(uint32_t align) {
734-
OSLockMutex(&allocMutex);
734+
//OSLockMutex(&allocMutex);
735735
uint32_t res = 0;
736736
for (int32_t i = 0; /* waiting for a break */; i++) {
737737
if (mem_mapping[i].physical_addresses == nullptr) {
@@ -743,12 +743,12 @@ uint32_t MemoryMapping_MEMGetAllocatableSizeEx(uint32_t align) {
743743
res = curRes;
744744
}
745745
}
746-
OSUnlockMutex(&allocMutex);
746+
//OSUnlockMutex(&allocMutex);
747747
return res;
748748
}
749749

750750
uint32_t MemoryMapping_GetFreeSpace() {
751-
OSLockMutex(&allocMutex);
751+
//OSLockMutex(&allocMutex);
752752
uint32_t res = 0;
753753
for (int32_t i = 0; /* waiting for a break */; i++) {
754754
if (mem_mapping[i].physical_addresses == nullptr) {
@@ -758,12 +758,12 @@ uint32_t MemoryMapping_GetFreeSpace() {
758758
DEBUG_FUNCTION_LINE_VERBOSE("heap at %08X MEMGetTotalFreeSizeForExpHeap: %d KiB", mem_mapping[i].effective_start_address, curRes / 1024);
759759
res += curRes;
760760
}
761-
OSUnlockMutex(&allocMutex);
761+
//OSUnlockMutex(&allocMutex);
762762
return res;
763763
}
764764

765765
void MemoryMapping_CreateHeaps() {
766-
OSLockMutex(&allocMutex);
766+
//OSLockMutex(&allocMutex);
767767
for (int32_t i = 0; /* waiting for a break */; i++) {
768768
if (mem_mapping[i].physical_addresses == nullptr) {
769769
break;
@@ -780,11 +780,11 @@ void MemoryMapping_CreateHeaps() {
780780
DEBUG_FUNCTION_LINE("Created heap @%08X, size %d KiB", heap, size / 1024);
781781
#endif
782782
}
783-
OSUnlockMutex(&allocMutex);
783+
//OSUnlockMutex(&allocMutex);
784784
}
785785

786786
void MemoryMapping_DestroyHeaps() {
787-
OSLockMutex(&allocMutex);
787+
//OSLockMutex(&allocMutex);
788788
for (int32_t i = 0; /* waiting for a break */; i++) {
789789
if (mem_mapping[i].physical_addresses == nullptr) {
790790
break;
@@ -796,7 +796,7 @@ void MemoryMapping_DestroyHeaps() {
796796
memset(address, 0, size);
797797
DEBUG_FUNCTION_LINE_VERBOSE("Destroyed heap @%08X", address);
798798
}
799-
OSUnlockMutex(&allocMutex);
799+
//OSUnlockMutex(&allocMutex);
800800
}
801801

802802
uint32_t MemoryMapping_getAreaSizeFromPageTable(uint32_t start, uint32_t maxSize) {

0 commit comments

Comments
 (0)