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