This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"sort" | |
"time" | |
_ "unsafe" | |
"golang.org/x/sys/unix" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Given a test pattern (number in base10), for each digit D starting from the right, | |
* spawn D threads to burn cpu in separate dynamically allocated executable pages, | |
* sleep for user-configurable delay, cancel all threads and revert executable pages | |
* to PROT_NONE. | |
* | |
* Example for pattern 432: | |
* spawn 2 threads, sleep, cancel/mprotect, sleep, spawn 3 threads, sleep, cancel/mprotect.. | |
* | |
* The addresses used for the executable mappings are of the form: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ./map 987 2 | |
Reserved 0x2000000000 bytes at 0x10000000000 | |
PID: 1237837 | |
Code len: 40 | |
Page size: 4096 | |
=== ARGS: | |
Test pattern: 987 | |
Delay: 2 | |
Page gap: 1 |