1/* 2 * testthreadcall.cpp 3 * testkext 4 * 5 */ 6 7#define ABSOLUTETIME_SCALAR_TYPE 8 9#include "testthreadcall.h" 10 11#include <kern/thread_call.h> 12 13#define super IOService 14OSDefineMetaClassAndStructors(testthreadcall, super); 15 16extern "C" { 17 18static void thread_call_test_func(thread_call_param_t param0, 19 thread_call_param_t param1); 20 21} 22 23bool 24testthreadcall::start( IOService * provider ) 25{ 26 boolean_t ret; 27 uint64_t deadline; 28 29 IOLog("%s\n", __PRETTY_FUNCTION__); 30 31 if (!super::start(provider)) { 32 return false; 33 } 34 35 IOLog("Attempting thread_call_allocate\n"); 36 tcall = thread_call_allocate(thread_call_test_func, this); 37 IOLog("thread_call_t %p\n", tcall); 38 39 tlock = IOSimpleLockAlloc(); 40 IOLog("tlock %p\n", tlock); 41 42 clock_interval_to_deadline(5, NSEC_PER_SEC, &deadline); 43 IOLog("%d sec deadline is %llu\n", 5, deadline); 44 45 ret = thread_call_enter_delayed(tcall, deadline); 46 47 return true; 48} 49 50static void thread_call_test_func(thread_call_param_t param0, 51 thread_call_param_t param1) 52{ 53 testthreadcall *self = (testthreadcall *)param0; 54 55 IOLog("thread_call_test_func %p %p\n", param0, param1); 56 57 IOSimpleLockLock(self->tlock); 58 IOSimpleLockUnlock(self->tlock); 59 60#if 1 61 IOSimpleLockLock(self->tlock); 62#else 63 IOSimpleLockUnlock(self->tlock); 64#endif 65} 66