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
// this program tries to measure a producer/consumer latency when | |
// the consumer thread may be in deep idle states. | |
// | |
// illumos only for now, sorry. | |
// | |
// run like `./wakeup_lat 20 22 park 200` to measure | |
// core 20 waking core 22, 200 times | |
use std::sync::{Arc, Condvar, Mutex}; | |
use std::sync::atomic::Ordering; |
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
//! # hey! you're curious about the characteristics of reading various MSRs? me too! | |
//! | |
//! this reads a few registers (TSC, AMD RAPL core and package power) 2M times and reports a bit | |
//! about the adventure. you need root wherever you run it. runs on linux (need the `msr` module | |
//! loaded) or illumos. | |
//! | |
//! you probably want to bind this to a single CPU when run. if you don't, it might work | |
//! reasonably, or if it's task-switched between cores while running, core-specific MSRs (RAPL core | |
//! power) will have nonsense skew. | |
//! |
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
#include <assert.h> | |
#include <stdio.h> | |
#include <sys/mman.h> | |
#include <sys/types.h> | |
#include <fcntl.h> | |
int main() { | |
int fd = open("doesnotexist", O_CREAT); | |
assert(fd > 0); | |
void* map = mmap(NULL, 65536, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); |
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
use std::io::Write; | |
use std::process::Command; | |
extern "C" { | |
fn mprotect(addr: *const u8, len: usize, prot: u32) -> u32; | |
} | |
fn main() { | |
let mut args = std::env::args(); | |
let _ = args.next(); |
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
0x00000000: 48895c2408 : mov qword [rsp + 0x8], rbx | |
0x00000005: 48896c2410 : mov qword [rsp + 0x10], rbp | |
0x0000000a: 4889742418 : mov qword [rsp + 0x18], rsi | |
0x0000000f: 57 : push rdi | |
0x00000010: 4154 : push r12 | |
0x00000012: 4155 : push r13 | |
0x00000014: 4883ec20 : sub rsp, 0x20 | |
0x00000018: 4885c9 : test rcx, rcx | |
0x0000001b: 0f844b040c00 : jz 0xc044b | |
0x00000021: f6410602 : test byte [rcx + 0x6], 0x2 |
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
#! /bin/bash | |
asn1=$(echo -e "\x30\x13\x02\x01\x05\x16\x0e\x41\x6e\x79\x62\x6f\x64\x79\x20\x74\x68\x65\x72\x65\x3f") | |
#asn2=$(echo -e "\x00\x01\x02\x03") | |
asn2="" | |
offset=0 | |
# while [ $offset -lt ${#asn1} ]; do | |
# curr=${asn1:offset:1} | |
# printf "$offset: %02x\n" \'$curr |
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
/* | |
* if you need more memory, add some to your program with this cool trick | |
*/ | |
#include <errno.h> | |
#include <fcntl.h> | |
#include <inttypes.h> | |
#include <stddef.h> | |
#include <stdio.h> | |
#include <sys/mman.h> |
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
trait Person { | |
fn greeting(&self) -> StateOfMind; | |
fn name(&self) -> &'static str; | |
} | |
struct Ixi { } | |
struct Katie { } | |
#[derive(Debug)] | |
enum StateOfMind { |
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
#include <signal.h> | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <sys/ucontext.h> | |
#include <stdint.h> | |
void interpret(char op) { | |
printf("interpreting %02x\n", op); | |
} |
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
trait Person { | |
fn greeting(&self) -> StateOfMind; | |
fn name(&self) -> &'static str; | |
} | |
struct Ixi { } | |
struct Katie { } | |
#[derive(Debug)] | |
enum StateOfMind { |
NewerOlder