Skip to content

Instantly share code, notes, and snippets.

View paranlee's full-sized avatar
🐧
Run RISC-V run!

Paran Lee paranlee

🐧
Run RISC-V run!
View GitHub Profile
@paranlee
paranlee / perf_event_template.c
Created November 9, 2021 04:23 — forked from teqdruid/perf_event_template.c
Template for using perf_event
/*
============================================================================
Name : branch_mispred.c
Author : John Demme
Version : Mar 21, 2011
Description : A template for perf_event. Requires Linux 2.6.32 or higher
============================================================================
*/
#define _GNU_SOURCE
@paranlee
paranlee / Makefile
Last active March 26, 2023 16:24 — forked from laoar/mmap_zcopy
An example of kernel space to user space zero-copy via mmap and character device, and also the comparing mmap with read/write.
all: kernel_modules
obj-m := kernel_zerocopy_mmap.o
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
%.ko: %.o
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) $@
@paranlee
paranlee / Makefile
Created March 23, 2022 04:07 — forked from mawenbao/Makefile
googletest simple example
# Makefile for gtest examples
GOOGLE_TEST_LIB = gtest
GOOGLE_TEST_INCLUDE = /usr/local/include
G++ = g++
G++_FLAGS = -c -Wall -I $(GOOGLE_TEST_INCLUDE)
LD_FLAGS = -L /usr/local/lib -l $(GOOGLE_TEST_LIB) -l pthread
OBJECTS = main.o string-compare.o
@paranlee
paranlee / install-dbgsym.sh
Last active March 24, 2022 06:23 — forked from NLKNguyen/Ubuntu install kernel -dbgsym
Ubuntu - Install Debug Symbol Package (-dbgsym) for the current Linux kernel
codename=$(lsb_release -cs)
sudo tee /etc/apt/sources.list.d/ddebs.list << EOF
deb http://ddebs.ubuntu.com/ ${codename} main restricted universe multiverse
# deb http://ddebs.ubuntu.com/ ${codename}-security main restricted universe multiverse
deb http://ddebs.ubuntu.com/ ${codename}-updates main restricted universe multiverse
deb http://ddebs.ubuntu.com/ ${codename}-proposed main restricted universe multiverse
EOF
sudo apt-get update
@paranlee
paranlee / arm64-on-Win10-x64.md
Last active July 9, 2024 01:26 — forked from billti/arm64-on-Win10.md
ARM64 Linux on Win10 x64

Below are the steps to get an ARM64 version of Ubuntu running in the QEMU emulator on Windows 10.

Install QEMU

Install for Windows from choco package manager

choco install qemu --version=2021.5.5 -confirm
PS D:\arm64-ubuntu2004\qemu> qemu-system-aarch64 --help
@paranlee
paranlee / main.rs
Created May 19, 2022 13:04 — forked from Sherlock-Holo/main.rs
io_uring test
use std::collections::HashMap;
use std::fs::File;
use std::future::Future;
use std::io::Error;
use std::io::IoSliceMut;
use std::io::Result;
use std::marker::PhantomData;
use std::os::unix::io::AsRawFd;
use std::os::unix::io::RawFd;
use std::pin::Pin;
@paranlee
paranlee / 0test.zig
Created May 19, 2022 13:05 — forked from andrewrk/0test.zig
test whether closing an fd which is being waited on in epoll_wait causes the wait to wake up (it doesn't)
const std = @import("std");
pub fn main() !void {
const epollfd = blk: {
const rc = std.os.linux.epoll_create1(std.os.linux.EPOLL_CLOEXEC);
const err = std.os.linux.getErrno(rc);
if (err != 0) return error.EpollCreateFailed;
break :blk @intCast(i32, rc);
};
defer std.os.close(epollfd);
// Test case for OP_SPLICE short read issue. Most systems may require the open
// file limit to be raised (4096, which is probably still within the hard limit,
// should be enough).
//
// This tries to read from a file called '20k', which I generated with the
// following:
// `dd if=/dev/random of=20k bs=1k count=20`
#define _GNU_SOURCE
#include <errno.h>
@paranlee
paranlee / io_uring-echo-server.c
Created May 19, 2022 14:02 — forked from MarcoF1/io_uring-echo-server.c
io_uring-echo-server
/**/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/resource.h>
@paranlee
paranlee / download.py
Created May 19, 2022 14:46 — forked from alexliang1975/download.py
download source code which powered by Trac's Browse source
#!/usr/env python
import urllib2
from HTMLParser import HTMLParser
import os
def downloadFile(url, filename):
u = urllib2.urlopen(url+'?format=txt')
localFile = open(filename, 'w')