Gentoo install on Virtualbox

I had never installed Gentoo before, so I tried following the Gentoo Handbook. I realized that the Japanese version wasn’t updated. Environment uname -a: Linux debian 3.13-1-amd64 #1 SMP Debian 3.13.7-1 (2014-03-25)x86_64 GNU/Linux Virtualbox 4.3.6 1. About Installing Gentoo Linux Simple, cutting-edge meta-distribution Can build the entire system from scratch, use precompiled packages, Or even half-and-half is OK 2. Choosing the Right Installation Media Used http://mirrors.stuhome.net/gentoo/releases/x86/autobuilds/current-iso/install-x86-minimal-20140401.iso Gentoo install CD is a bootable CD containing a standalone Gentoo environment install-x86-minimal-<release>....

April 6, 2014

Scheme REPL and Garbage Collection

REPL An ordinary REPL. Still connecting via pipes as before. It worked when I fed in each S-expression typed at the top level. Disassemble I added a command called (disasm ..). You can check the disassembled results like this. >>(disasm (+ 1 2 3)) === code === 0 0x12000002 ;FRAME 1 0x0000003c ;15 2 0x25000002 ;CONSTNUM 3 0x0000000c ;3 4 0x13000002 ;ARGUMEMT 5 0x25000002 ;CONSTNUM 6 0x00000008 ;2 7 0x13000002 ;ARGUMEMT 8 0x25000002 ;CONSTNUM 9 0x00000004 ;1 10 0x13000002 ;ARGUMEMT 11 0x03000002 ;REFER_GLOBAL 12 0x094bf2f3 ;+ 13 0x15000002 ;APPLY 14 0x0000000c ;3 15 0x27000002 ;DISASM 16 0x00000002 ;HALT Garbage Collection I implemented and embedded Cheney’s copy GC....

March 7, 2014

Writing a Scheme VM in C

Object Representation I use two types (vm_data type and vm_obj struct). The vm_data type contains primitive types, constants, and references to objects. Since conservative GC seems difficult, I decided to include tags within one word. I determine by the lower bits. I simply typedef intptr_t vm_data; Integer ....00 Upper 30 bits represent signed integer Character .00000 Upper 8 bits represent true .00101 false .01001 nil .01101 undefined .10101 Box ....10 Reference to vm_data vm_obj ....

February 28, 2014

3imp Traditional Macros and Bytecode Conversion

Traditional Macros I didn’t touch the VM and only modified the compiler. During macro expansion and definition, I added and referenced entries in the macro table. Although the namespace is different from top-level variables, I think this is fine… So now I can freely extend things like let and begin as follows. When I have time, I’d like to add other macro systems too. (define-macro let (lambda (binds . bodies) (cons (append (list 'lambda (map (lambda (x) (car x)) binds)) bodies) (map (lambda (x) (cadr x)) binds)))) (let ((a 10)) (+ a 1)) Making Bytecode Cooler The previous bytecode was like the one below, with a structure that chains the next instruction....

February 18, 2014

3imp Top-level Variables and Primitive Functions

I implemented the top-level variables and primitive functions described in 3imp 4.7. Top-level Variables Two implementation approaches were mentioned. The first method is to put everything into the display closure when creating the closure, like free variables so far. It’s supposed to be simple, but I didn’t feel like doing it, so I rejected it. If we do this, naturally all display closures will bloat, and we’ll get into the story of boxes being referenced from various places…...

February 15, 2014

3imp 4.1 Stack-Based

This is a memo for chapter 4.1 of 3imp. A simple example of scheme with first-class functions, continuations, and tail-call optimization removed. Registers a: accumulator, used for general purposes x: next instruction e: frame of one outer scope s: stack top Call Frame Static link (pushed last) 1st argument : : last argument next expression (return address) Dynamic link (pushed last) Instructions Since there are no continuations, there is no conti,nuate....

February 13, 2014

3imp Heap-based VM

This is a memo after reading 3imp up to chapter 3. I wrote something Scheme-like before, so I wanted to make something better. 3imp is a helpful paper that concretely introduces three types of Scheme implementations: heap-based, stack-based, and string-based. I’ll particularly write down the workings of the heap-based VM in chapter 3. Compiler Scheme code -> Compiler -> Intermediate code -> Execute on VM The flow is like this, so first we create a compiler from Scheme code to intermediate code....

February 6, 2014

Bare Metal Programming on Raspberry Pi

0. Introduction I’ll write a simple boot program with the goal of running “hello world” on real hardware. Since I have a Raspberry Pi that a friend gave me and it’s just sitting around, it seems like a good toy to play with. However, I’m mostly referencing http://wiki.osdev.org/ARM_RaspberryPi_Tutorial_C, so if you want detailed information, please read the original. The first half is preparation of the emulator and cross compiler. I’ve tried to make it so that everything works if you copy and paste....

January 13, 2014

2013 Year in Review

Happy New Year. A bit late, but let me look back on 2013. unix v6 reading group Once I could borrow the key from the receptionist, I was all set Held about 7 times What about the 8th? Will people come… Security Camp Created a security module using LSM with Kumao-san and Chubachi-san It remains incomplete Kernel vm Invited by Naota-san Helped a little with operations (more like a hindrance) Next time onwards… Google Bootcamp The thing with marshmallows on spaghetti mixi challenge Played with Kamonegi-san on a mixi-like SNS kc3 There was a scary brainfucker mruby reading group Symbol table part The p Class....

January 4, 2014

((Writing a Scheme-like interpreter))

I wrote a Scheme-like interpreter called jellyfish. It’s available here. However, it’s my own implementation, so it doesn’t comply with RnRS. Scheme seems to be a standard for self-made interpreters, but I feel there are surprisingly few articles explaining it. Here, I’d like to briefly describe its implementation method. I’m assuming readers who have written a brainfuck interpreter and want to write a slightly more advanced custom interpreter (not limited to Scheme)....

December 24, 2013

Compiling Vim from Source

I’m still using neocomplecache.vim, so I wanted to migrate to neocomplete.vim soon. After some research, I found that it requires vim with lua support. This example also includes python support. I could have used a package manager, but since I had never compiled vim from source before, I decided to give it a try. $ brew install mercurial $ mkdir /usr/local/vim-7.4 $ cd /usr/local/src $ hg clone https://vim.googlecode.com/hg/ vim $ cd vim/src $ ....

November 19, 2013

How to play with pdp11

When doing V6 code reading, I think it would be efficient to know how to use the pdp11 emulator simh and the cross-compiler, so here’s a summary. What we’re doing is: Use a cross-compiler to create an a.out-pdp11 format executable file for pdp11. Run it with simh to check the memory and register contents. (Boot by assigning the executable file to simh’s virtual disk.) Note that pdp11 is basically written in octal....

November 16, 2013

Debian Package Memo

For now # display xrandr xrandr --output VGA1 -- mode 1280x1024 --right-of HDMI2 xrandr --output HDMI2 -- mode 1920x1080 # xfce apt-get install xfce4 apt-get install xfce4-goodies # ime apt-get install ibus-anthy apt-get install ibus-mozc ibus-setup # flash # add /etc/apt/sources.list # deb ftp://ftp.debian.org/debian stable main contrib non-free apt-get update apt-get install flashplugin-nonfree # git apt-get install git git config --global user.name "bobuhiro11" git config --global user.email "hogehoge@hoge.com" ssh-keygen # vim # for python support apt-get install vim-gnome # skype # download from http://www....

November 1, 2013

Presentation Tool rabbit

Can create presentations and output PDF Markdown or RD JPEG and PNG can be embedded directly $ gem install rabbit $ rabbit-2.1.1/lib/rabbit/theme # List of themes $ rabbit sample.rd # Execute $ rabbit -p -o sample.pdf sample.rd # PDF output # To run with it without system install. # % ruby -I./lib bin/rabbit -f sample/rabbit-implementation.rd # $Id$ = 第4回 UNIX V6 読書会 : subtitle 6章 シグナルの話 : author @bobuhiro11 : institution : theme clear-blue = PDP11/40 * ((*16bit*)) CPU (1Word = 16bit) * 物理メモリ((*256KB*))(2^18) * 18bitのアドレス * 仮想メモリ((*64KB*))(2^16) * 16bitのアドレス = PSW 15-14 現在のモード(00:カーネル 11:ユーザ) 13-12 以前のモード(00:カーネル 11:ユーザ) 5-7 プロセッサ優先度 4 トラップビット 3 Nフラグ 2 Zフラグ 1 Vフラグ 0 Cフラグ

November 1, 2013

Thread Synchronization in Java

Methods of synchronization and precautions to prevent deadlock. Things that have the following mechanisms are called synchronization primitives (such as semaphores and monitors). Exclusive access to shared resources Thread wait/wakeup processing Monitor Java uses a mechanism called monitor as a synchronization primitive. A monitor wraps data to be shared between threads in methods, etc., makes it readable/writable only from inside those methods, and ensures only one thread can enter at a time....

October 25, 2013

Memo of Ruby Implementations

MRI(Matz’s Ruby Implementation) Implemented in C Original implementation From 1.9.x onwards, incorporates YARV mruby Lightweight version, for embedded systems JRuby Implemented in Java, runs on JVM Interpreter, JIT compilation (default), AOT compilation Can call Java from JRuby and JRuby from Java IronRuby Runs on .NET Can use .NET libraries MacRuby Before 0.5 uses YARV, after that uses LLVM JIT compilation, AOT compilation Runs on OSX Rubinius Mostly implemented in Ruby JIT compilation (AOT compilation to machine code is not possible?...

October 24, 2013

GCM - Google Cloud Messaging

I was forced to use GCM, so here are my notes. GCM is a mechanism/service for sending push notifications from a server to Android apps. It was made public on June 26, 2012. Before that, it was implemented using C2DM. This is a simple sample, but I’ll keep it as a memo. It’s available here. Partially quoted from http://developer.android.com/google/gcm/index.html and http://www.kotemaru.org/2013/07/28/android-push-message.html. Mechanism Let’s call Google’s server the GCM server Let’s call our own server the self-server First, obtain the device ID (registration ID) from the GCM server....

October 22, 2013

Security Camp 2013

August 21, 2013

Converting Markdown to HTML with vim

Download and extract Markdown 1.0.1 from http://daringfireball.net/projects/markdown/. Move “Markdown.pl” to “/usr/local/bin”. To enable utf8 support, add “use utf8;” at the beginning of “Markdown.pl”. To use it from vim, add the following code to “.vimrc”. nmap \md :%!/usr/local/bin/Markdown.pl --html4tag Done. Write markdown text in vim and press “\md” to convert to HTML. Reference: http://net.tutsplus.com/tutorials/other/vim-essential-plugin-markdown-to-html

April 30, 2013

HenTai - Transfer Admission Experience Stories

...

April 28, 2013