Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F4914298
mprotector.c
dougm (Doug Moore)
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
dougm
Jul 26 2019, 4:37 AM
2019-07-26 04:37:42 (UTC+0)
Size
753 B
Referenced Files
None
Subscribers
None
mprotector.c
View Options
#include
<sys/mman.h>
#include
<sys/time.h>
#include
<stdlib.h>
#include
<stdio.h>
enum
{
MAX_MAPS
=
16384
,
PAGE_SIZE
=
4096
};
int
main
(
int
argc
,
const
char
*
argv
[])
{
void
*
mapping
;
struct
timeval
beg
,
end
;
struct
timezone
tz
=
{
0
,
0
};
enum
{
GIGA
=
1
<<
20
,
PAGE
=
1
<<
12
};
mapping
=
mmap
(
0
,
GIGA
,
PROT_WRITE
,
MAP_ALIGNED
(
14
)
|
MAP_ANON
,
-1
,
0
);
int
i
;
for
(
i
=
0
;
i
<
GIGA
;
i
+=
2
*
PAGE
)
mprotect
(
mapping
+
i
,
PAGE
,
PROT_NONE
);
gettimeofday
(
&
beg
,
&
tz
);
mprotect
(
mapping
,
GIGA
,
PROT_WRITE
);
gettimeofday
(
&
end
,
&
tz
);
end
.
tv_sec
-=
beg
.
tv_sec
;
end
.
tv_usec
-=
beg
.
tv_usec
;
if
(
end
.
tv_usec
<
0
)
{
end
.
tv_usec
+=
1000000
;
end
.
tv_sec
--
;
}
printf
(
"time %ld.%ld
\n
"
,
(
long
)
end
.
tv_sec
,
(
long
)
end
.
tv_usec
);
return
0
;
}
File Metadata
Details
Attached
Mime Type
text/x-c
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2070855
Default Alt Text
mprotector.c (753 B)
Attached To
Mode
D20814: Make entry simplification one-way
Attached
Detach File
Event Timeline
Log In to Comment