2 ** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
8 #include <sys/syscalls.h>
9 #include <newos/errors.h>
18 printf("my thread id is %d\n", _kern_get_current_thread_id());
20 printf("writing to invalid page\n");
21 *(int *)0x30000000 = 5;
24 printf("doing some region tests\n");
31 region
= _kern_vm_create_anonymous_region("foo", &ptr
, REGION_ADDR_ANY_ADDRESS
,
32 16*4096, REGION_WIRING_LAZY
, LOCK_RW
);
33 printf("region = 0x%x @ 0x%x\n", region
, (unsigned int)ptr
);
34 region2
= _kern_vm_clone_region("foo2", &ptr2
, REGION_ADDR_ANY_ADDRESS
,
35 region
, REGION_NO_PRIVATE_MAP
, LOCK_RW
);
36 printf("region2 = 0x%x @ 0x%x\n", region2
, (unsigned int)ptr2
);
38 _kern_vm_get_region_info(region
, &info
);
39 printf("info.base = 0x%x info.size = 0x%x\n", (unsigned int)info
.base
, (unsigned int)info
.size
);
41 _kern_vm_delete_region(region
);
42 _kern_vm_delete_region(region2
);
43 printf("deleting both regions\n");
47 printf("doing some commitment tests (will only be proper on 256MB machines)\n");
53 region
= _kern_vm_create_anonymous_region("large", &ptr
, REGION_ADDR_ANY_ADDRESS
,
54 200*1024*1024, REGION_WIRING_LAZY
, LOCK_RW
);
56 printf("error %d creating large region\n", region
);
58 printf("region = 0x%x @ 0x%x\n", region
, (unsigned int)ptr
);
61 printf("pausing for 5 seconds...\n");
63 region2
= _kern_vm_create_anonymous_region("large2", &ptr2
, REGION_ADDR_ANY_ADDRESS
,
64 64*1024*1024, REGION_WIRING_LAZY
, LOCK_RW
);
66 printf("error %d creating large region\n", region2
);
67 if(region2
== ERR_VM_WOULD_OVERCOMMIT
)
68 printf("good, it failed because of overcommitting\n");
70 printf("region2 = 0x%x @ 0x%x\n", region2
, (unsigned int)ptr2
);
73 printf("pausing for 5 seconds...\n");
75 printf("deleting both regions\n");
76 _kern_vm_delete_region(region
);
77 _kern_vm_delete_region(region2
);
82 // create a couple of big regions and time it
87 printf("running some timing tests on region creation/deletion.\n");
88 printf("you'll want to make sure serial debugging is off or the test will take forever,\n");
89 printf(" use the scroll lock key to toggle it on or off.\n");
90 printf("pausing for 2 seconds...\n");
93 t
= _kern_system_time();
94 region
= _kern_vm_create_anonymous_region("large", &ptr
, REGION_ADDR_ANY_ADDRESS
,
95 64*1024*1024, REGION_WIRING_LAZY
, LOCK_RW
);
96 t
= _kern_system_time() - t
;
98 printf("took %d microseconds to create large region (lazy wiring)\n", (int)t
);
100 t
= _kern_system_time();
101 _kern_vm_delete_region(region
);
102 t
= _kern_system_time() - t
;
104 printf("took %d microseconds to delete it (with no pages allocated)\n", (int)t
);
106 t
= _kern_system_time();
107 region
= _kern_vm_create_anonymous_region("large", &ptr
, REGION_ADDR_ANY_ADDRESS
,
108 64*1024*1024, REGION_WIRING_WIRED
, LOCK_RW
);
109 t
= _kern_system_time() - t
;
111 printf("took %d microseconds to create large region (wired)\n", (int)t
);
113 t
= _kern_system_time();
114 _kern_vm_delete_region(region
);
115 t
= _kern_system_time() - t
;
117 printf("took %d microseconds to delete it (with all allocated)\n", (int)t
);
121 printf("vmtest: exiting w/return code %d\n", rc
);