Skip to content

Commit 409905c

Browse files
yank out shared mutex impl
Initially shared mutex was needed to lock cores so thread pool executes one parallel for at a time but on machine with high core count we cant saturate processor all the time so we switched to shared semaphore and block thread when all cores are busy.
1 parent 0ca9d97 commit 409905c

File tree

3 files changed

+0
-66
lines changed

3 files changed

+0
-66
lines changed

src/os/core/linux/os_core_linux.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -861,32 +861,6 @@ os_mutex_drop(OS_Handle mutex)
861861
pthread_mutex_unlock(&entity->mutex_handle);
862862
}
863863

864-
internal OS_Handle
865-
os_shared_mutex_alloc(String8 name)
866-
{
867-
NotImplemented;
868-
OS_Handle handle = {0};
869-
return handle;
870-
}
871-
872-
internal void
873-
os_shared_mutex_release(OS_Handle mutex)
874-
{
875-
NotImplemented;
876-
}
877-
878-
internal B32
879-
os_shared_mutex_take(OS_Handle mutex, U64 endt_us)
880-
{
881-
NotImplemented;
882-
}
883-
884-
internal void
885-
os_shared_mutex_drop(OS_Handle mutex)
886-
{
887-
NotImplemented;
888-
}
889-
890864
//- rjf: reader/writer mutexes
891865

892866
internal OS_Handle

src/os/core/os_core.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,6 @@ internal void os_rw_mutex_drop_r(OS_Handle mutex);
277277
internal void os_rw_mutex_take_w(OS_Handle mutex);
278278
internal void os_rw_mutex_drop_w(OS_Handle mutex);
279279

280-
//- shared mutex
281-
internal OS_Handle os_shared_mutex_alloc(String8 name);
282-
internal void os_shared_mutex_release(OS_Handle mutex);
283-
internal B32 os_shared_mutex_take(OS_Handle mutex, U64 endt_us);
284-
internal void os_shared_mutex_drop(OS_Handle mutex);
285-
286280
//- rjf: condition variables
287281
internal OS_Handle os_condition_variable_alloc(void);
288282
internal void os_condition_variable_release(OS_Handle cv);

src/os/core/win32/os_core_win32.c

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,40 +1106,6 @@ os_mutex_drop(OS_Handle mutex)
11061106
LeaveCriticalSection(&entity->mutex);
11071107
}
11081108

1109-
internal OS_Handle
1110-
os_shared_mutex_alloc(String8 name)
1111-
{
1112-
Assert(name.size);
1113-
Temp scratch = scratch_begin(0,0);
1114-
String16 name16 = str16_from_8(scratch.arena, name);
1115-
HANDLE handle = CreateMutexW(0, 0, (WCHAR*)name16.str);
1116-
Assert(handle != 0);
1117-
OS_Handle mutex = {(U64)handle};
1118-
scratch_end(scratch);
1119-
return mutex;
1120-
}
1121-
1122-
internal void
1123-
os_shared_mutex_release(OS_Handle mutex)
1124-
{
1125-
CloseHandle((HANDLE)mutex.u64[0]);
1126-
}
1127-
1128-
internal B32
1129-
os_shared_mutex_take(OS_Handle mutex, U64 endt_us)
1130-
{
1131-
U32 sleep_ms = os_w32_sleep_ms_from_endt_us(endt_us);
1132-
DWORD wait_result = WaitForSingleObject((HANDLE)mutex.u64[0], sleep_ms);
1133-
B32 result = (wait_result == WAIT_OBJECT_0);
1134-
return result;
1135-
}
1136-
1137-
internal void
1138-
os_shared_mutex_drop(OS_Handle mutex)
1139-
{
1140-
ReleaseMutex((HANDLE)mutex.u64[0]);
1141-
}
1142-
11431109
//- rjf: reader/writer mutexes
11441110

11451111
internal OS_Handle

0 commit comments

Comments
 (0)