MCPcopy Create free account
hub / github.com/devkitPro/libctru / LightSemaphore_Acquire

Function LightSemaphore_Acquire

libctru/source/synchronization.c:365–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363}
364
365void LightSemaphore_Acquire(LightSemaphore* semaphore, s32 count)
366{
367 s32 old_count;
368 s16 num_threads_acq;
369
370 do
371 {
372 for (;;)
373 {
374 old_count = __ldrex(&semaphore->current_count);
375 if (old_count >= count)
376 break;
377 __clrex();
378
379 do
380 num_threads_acq = (s16)__ldrexh((u16 *)&semaphore->num_threads_acq);
381 while (__strexh((u16 *)&semaphore->num_threads_acq, num_threads_acq + 1));
382
383 syncArbitrateAddress(&semaphore->current_count, ARBITRATION_WAIT_IF_LESS_THAN, count);
384
385 do
386 num_threads_acq = (s16)__ldrexh((u16 *)&semaphore->num_threads_acq);
387 while (__strexh((u16 *)&semaphore->num_threads_acq, num_threads_acq - 1));
388 }
389 } while (__strex(&semaphore->current_count, old_count - count));
390
391 __dmb();
392}
393
394int LightSemaphore_TryAcquire(LightSemaphore* semaphore, s32 count)
395{

Callers

nothing calls this directly

Calls 7

__ldrexFunction · 0.85
__clrexFunction · 0.85
__ldrexhFunction · 0.85
__strexhFunction · 0.85
syncArbitrateAddressFunction · 0.85
__strexFunction · 0.85
__dmbFunction · 0.85

Tested by

no test coverage detected