1*bbb1b6f9SApple OSS Distributions /* 2*bbb1b6f9SApple OSS Distributions * mpsc: test the MPSC interface 3*bbb1b6f9SApple OSS Distributions */ 4*bbb1b6f9SApple OSS Distributions 5*bbb1b6f9SApple OSS Distributions #ifdef T_NAMESPACE 6*bbb1b6f9SApple OSS Distributions #undef T_NAMESPACE 7*bbb1b6f9SApple OSS Distributions #endif 8*bbb1b6f9SApple OSS Distributions 9*bbb1b6f9SApple OSS Distributions #include <darwintest.h> 10*bbb1b6f9SApple OSS Distributions #include <sys/sysctl.h> 11*bbb1b6f9SApple OSS Distributions 12*bbb1b6f9SApple OSS Distributions T_GLOBAL_META(T_META_NAMESPACE("xnu.mpsc"), 13*bbb1b6f9SApple OSS Distributions T_META_RUN_CONCURRENTLY(true)); 14*bbb1b6f9SApple OSS Distributions 15*bbb1b6f9SApple OSS Distributions T_DECL(pingpong, "mpsc_pingpong", T_META_ASROOT(true)) 16*bbb1b6f9SApple OSS Distributions { 17*bbb1b6f9SApple OSS Distributions uint64_t count = 100 * 1000, nsecs = 0; 18*bbb1b6f9SApple OSS Distributions size_t nlen = sizeof(nsecs); 19*bbb1b6f9SApple OSS Distributions int error; 20*bbb1b6f9SApple OSS Distributions 21*bbb1b6f9SApple OSS Distributions error = sysctlbyname("kern.mpsc_test_pingpong", &nsecs, &nlen, 22*bbb1b6f9SApple OSS Distributions &count, sizeof(count)); 23*bbb1b6f9SApple OSS Distributions T_ASSERT_POSIX_SUCCESS(error, "sysctlbyname"); 24*bbb1b6f9SApple OSS Distributions T_LOG("%lld asyncs in %lld ns (%g us/async)", count, nsecs, 25*bbb1b6f9SApple OSS Distributions (nsecs / 1e3) / count); 26*bbb1b6f9SApple OSS Distributions } 27