#include <mach/mach.h>
#include <mach/mach_vm.h>
-static void* loop(__attribute__ ((unused)) void *arg) {
+static void*
+loop(__attribute__ ((unused)) void *arg)
+{
while (1) {
-
}
}
-static int run_additional_threads(int nthreads) {
+static int
+run_additional_threads(int nthreads)
+{
for (int i = 0; i < nthreads; i++) {
pthread_t pthread;
int err;
-
+
err = pthread_create(&pthread, NULL, loop, NULL);
if (err) {
return err;
return 0;
}
-static int allocate_and_wire_memory(mach_vm_size_t size) {
+static int
+allocate_and_wire_memory(mach_vm_size_t size)
+{
int err;
task_t task = mach_task_self();
mach_vm_address_t addr;
- if (size <= 0)
+ if (size <= 0) {
return 0;
+ }
err = mach_vm_allocate(task, &addr, size, VM_FLAGS_ANYWHERE);
if (err != KERN_SUCCESS) {
return 0;
}
-int main(int argc, char *argv[]) {
+int
+main(int argc, char *argv[])
+{
int nthreads = 0;
int err;
mach_vm_size_t wired_mem = 0;
if (argc > 2) {
wired_mem = (mach_vm_size_t)strtoul(argv[2], NULL, 10);
}
-
+
err = allocate_and_wire_memory(wired_mem);
if (err) {
return err;