Skip to content

Instantly share code, notes, and snippets.

=erl_crash_dump:0.1
Thu Sep 20 17:39:12 2012
Slogan: init terminating in do_boot ()
System version: Erlang R15B02 (erts-5.9.2) [source] [64-bit] [smp:2:2] [async-threads:0] [hipe] [kernel-poll:false]
Compiled: Tue Sep 4 09:58:49 2012
Taints:
Atoms: 6665
=memory
total: 9102952
processes: 1259392
@xjia1
xjia1 / gist:4076899
Created November 15, 2012 06:04
Reading List @ SG

Academic Papers

Kilim Ultra-lightweight Threads (4)

  • Kilim: Isolation-Typed Actors for Java (A Million Actors, Safe Zero-Copy Communication) (kilim_ecoop08.pdf)
    • Slides: kilim-google.pdf
  • A Thread of One’s Own (thread_of_ones_own.pdf)
  • The Problem with Threads (EECS-2006-1.pdf)

Program Synthesis (?)

@xjia1
xjia1 / gist:4413725
Last active September 2, 2022 20:09
Interesting CS Courses
@xjia1
xjia1 / etalk.erl
Last active December 10, 2015 12:38
-module(etalk).
-export[start/2, acceptor/1].
start(Port, NumWorkers) ->
Opts = [binary, {active, false}],
case gen_tcp:listen(Port, Opts) of
{ok, ListenSock} ->
start_acceptors(NumWorkers, ListenSock),
inet:port(ListenSock)
; {error, Reason} ->
@xjia1
xjia1 / parsec.c
Created January 4, 2013 10:15
Try parser combinators in C
// Try parser combinators in C
#include <stdio.h>
#include <stdlib.h>
struct token
{
const char *text;
};
struct token_list
@xjia1
xjia1 / CostOfLocksThreaded.java
Last active December 10, 2015 20:48
The cost of locks
import java.util.concurrent.atomic.AtomicLong;
public class CostOfLocksThreaded {
private static class Incr extends Thread {
private static long a;
public static void initialize() { a = 0; }
public static long get() { return a; }
private long incr() { return ++a; }
public void run() {
@xjia1
xjia1 / tcbench.hs
Created January 9, 2013 13:27
Thread creation benchmark in Haskell
import Control.Concurrent
import Control.Concurrent.Chan
import System.Environment
import System.Exit
import System.Time
main = getArgs >>= start
start [s1,s2] = do
stopCh <- newChan
@xjia1
xjia1 / tcbenchnb.erl
Last active December 10, 2015 22:08
The idea is to create M x N threads, and measure the time cost for every N threads created. After a thread is created, it sends a message to let the main process continue, and finishes execution.
-module(tcbenchnb).
-export([start/2, init/2, thread/1]).
start(Total_Rounds, Step) ->
spawn(?MODULE, init, [Total_Rounds, Step]).
init(Total_Rounds, Step) ->
Start_Time = os:timestamp(),
create_threads(0, 0, Total_Rounds, Step, Start_Time).
@xjia1
xjia1 / sigtest.sml
Created May 30, 2013 11:38
Standard ML Signature Usage
$ sml
Standard ML of New Jersey v110.67 [built: Wed Apr 10 22:39:58 2013]
- use "sigtest.sml";
[opening sigtest.sml]
[autoloading]
[library $SMLNJ-BASIS/basis.cm is stable]
[autoloading done]
signature MYLIST =
sig
type 'a T
@xjia1
xjia1 / int-sqrt.rb
Last active December 20, 2015 18:18
Computing the integer square root of n
k = 0
j = 1
m = 1
while m <= n
k = k + 1
j = j + 2
m = m + j
end
# the answer is in k