svc · mach trap -89
mach_wait_until
Endort le thread courant jusqu'à une échéance absolue de mach_absolute_time().
Prototype
kern_return_t mach_wait_until(/* 2 args */);Retour: kern_return_t
Historique des versions
| XNU tag | macOS | # |
|---|---|---|
| xnu-123.5 | macOS 10.0 Cheetah | -89 |
| xnu-201 | macOS 10.1 Puma | -89 |
| xnu-344 | macOS 10.2 Jaguar | -89 |
| xnu-517 | macOS 10.3 Panther | -89 |
| xnu-124.1 | — | -89 |
| xnu-124.13 | — | -89 |
| xnu-124.7 | — | -89 |
| xnu-201.14 | — | -89 |
| xnu-201.19 | — | -89 |
| xnu-201.19.3 | — | -89 |
| xnu-201.42.3 | — | -89 |
| xnu-201.5 | — | -89 |
| xnu-344.12.2 | — | -89 |
| xnu-344.2 | — | -89 |
| xnu-344.21.73 | — | -89 |
| xnu-344.21.74 | — | -89 |
| xnu-344.23 | — | -89 |
| xnu-344.26 | — | -89 |
| xnu-344.32 | — | -89 |
| xnu-344.34 | — | -89 |
| xnu-344.49 | — | -89 |
| xnu-517.11.1 | — | -89 |
| xnu-517.12.7 | — | -89 |
| xnu-517.3.15 | — | -89 |
| xnu-517.3.7 | — | -89 |
| xnu-517.7.21 | — | -89 |
| xnu-517.7.7 | — | -89 |
| xnu-517.9.4 | — | -89 |
| xnu-517.9.5 | — | -89 |
Exemples
Sleep 5 ms with high precision
#include <mach/mach_time.h>
static mach_timebase_info_data_t tb;
if (tb.denom == 0) mach_timebase_info(&tb);
uint64_t now = mach_absolute_time();
uint64_t ns_to_ticks = (5ULL * 1000000ULL) * tb.denom / tb.numer;
mach_wait_until(now + ns_to_ticks);
Notes
mach_wait_until est la mise en sommeil haute résolution canonique sur Darwin : elle prend une échéance uint64_t en ticks mach (conversion depuis ns via mach_timebase_info) et revient quand ce temps monotone est atteint. Elle est implémentée comme une fine enveloppe autour de mach_wait_until_trap et c'est ce qu'appellent in fine dispatch_after, CADisplayLink et la plupart des frameworks média. Contrairement à nanosleep, elle n'est pas interrompue par les signaux livrés au processus sauf si l'attente est explicitement avortée.
Détection
Providers mach_trap et sched de DTrace ; non exposée dans Endpoint Security.