Skip to content

Instantly share code, notes, and snippets.

View cwshu's full-sized avatar

Jim Shu cwshu

  • Hsinchu, Taiwan
View GitHub Profile

KVM ARM paper

  • trap-and-emulate: 虛擬化重要觀念
    • 可以跟傳統 OS 的 system call 做比較
    • external interrupt, CPU exception(trap), and software interrupt
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#!/usr/bin/env python3
import sys
import ctypes
ctypes.cdll.LoadLibrary('libc.so.6')
libc = ctypes.CDLL('libc.so.6')
def main():
if len(sys.argv) != 3:
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import sys
import subprocess as sp
import os
# Please modify EFLOW_BASE_DIR to eflow repository root dir if you move this script to other directory.
EFLOW_BASE_DIR = ".."
@cwshu
cwshu / pshared_mutex.c
Created June 26, 2016 11:28
有 bug 的 process shared mutex
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#!/usr/bin/env python3
PACMAN_QL = './pacman_Ql'
FIND = './find'
PAC_STR="""acl /home/susu/rootfs/test1/usr/
acl /home/susu/rootfs/test1/usr/bin/
"""
FIND_STR="""/home/susu/rootfs/test1/
/home/susu/rootfs/test1/opt
1. Template shouldn't use primitive type
- primitive type to class: boolean => Boolean, int => Integer
- e.g. ArrayList<Integer>, List<Integer>, Map<String, Double>
2. string join
- Java8 has StringJoiner: https://docs.oracle.com/javase/8/docs/api/java/util/StringJoiner.html
- [bef Java8] for loop + StringBuilder(fast string concat): http://stackoverflow.com/a/15837355
num_of_matrix = int(input())
matrix_list = []
for matrix_idx in range(num_of_matrix):
matrix_list.append(matrix_idx)
matrix_row_size = int(input())
for row_idx in range(matrix_row_size):
current_row = input().split()