]>
git.saurik.com Git - apple/xnu.git/blob - tests/perf_exit_proc.c
7 #include <mach/mach_vm.h>
10 loop(__attribute__ ((unused
)) void *arg
)
18 run_additional_threads(int nthreads
)
20 for (int i
= 0; i
< nthreads
; i
++) {
24 err
= pthread_create(&pthread
, NULL
, loop
, NULL
);
34 allocate_and_wire_memory(mach_vm_size_t size
)
37 task_t task
= mach_task_self();
38 mach_vm_address_t addr
;
44 err
= mach_vm_allocate(task
, &addr
, size
, VM_FLAGS_ANYWHERE
);
45 if (err
!= KERN_SUCCESS
) {
46 printf("mach_vm_allocate returned non-zero: %s\n", mach_error_string(err
));
49 err
= mach_vm_protect(task
, addr
, size
, 0, VM_PROT_READ
| VM_PROT_WRITE
);;
50 if (err
!= KERN_SUCCESS
) {
51 printf("mach_vm_protect returned non-zero: %s\n", mach_error_string(err
));
54 host_t host_priv_port
;
55 err
= host_get_host_priv_port(mach_host_self(), &host_priv_port
);
56 if (err
!= KERN_SUCCESS
) {
57 printf("host_get_host_priv_port retruned non-zero: %s\n", mach_error_string(err
));
60 err
= mach_vm_wire(host_priv_port
, task
, addr
, size
, VM_PROT_READ
| VM_PROT_WRITE
);
61 if (err
!= KERN_SUCCESS
) {
62 printf("mach_vm_wire returned non-zero: %s\n", mach_error_string(err
));
70 main(int argc
, char *argv
[])
74 mach_vm_size_t wired_mem
= 0;
77 nthreads
= (int)strtoul(argv
[1], NULL
, 10);
80 wired_mem
= (mach_vm_size_t
)strtoul(argv
[2], NULL
, 10);
83 err
= allocate_and_wire_memory(wired_mem
);
88 err
= run_additional_threads(nthreads
);