Sunday, December 5, 2010

몸에 익히고 싶은, 그러나 잘 안 익혀지는 emacs 단축키/function 모음

광활한 emacs의 세상. 그리고 그 emacs의 단축키 중에 지금은 잘 쓰지 않지만, 앞으로는 잘 쓰게 되길 바라는 기능들이 꽤 많다. 여기에다 정리해놓는다.

Bookmark 관련
C-x r m (bookmark-set)
C-x r b (bookmark-jump)

Text editing 관련
M-q (fill-paragraph)

Saturday, October 16, 2010

ubuntu 내가 하는 세팅

ubuntu에서 내가 따로 하는 세팅 모음. 각종 dot files는 포함하지 않음.

차후 생각나는대로 업데이트 됨.

gnome-terminal
 - Edit ▸ Keyboard Shortcuts, deselect "Enable all menu access keys"

package install
sudo apt-get install emacs libboost-dev

remove applications from application indicators
/usr/share/indicators/messages/applications

thunderbird
install firetray, toggle word wrap, gnome integration

~/.ssh/config  setting
Host my_alias
HostKeyAlias mojah
Hostname xx.xxx.xx.xx
User username
Port xxxx

Tuesday, September 14, 2010

리눅스(우분투)의 init이 하는 일들

Ubuntu의 upstart 0.6.5 버전을 기준으로 한다.

1. 자기가 맨 처음 실행된 애가 아니면(pid != 1) telinit을 실행시킨다.
2. setsid()로 새로운 session을 시작한다.
3. system_setup_console에서는 tcsetattr()을 이용해 tty를 설정하고, file descriptor를 모두 /dev/null에 연결시킨다. 여기서 tty설정을 통해 특수키 등을 설정할 수 있다.
4. PATH를 bin과 sbin등의 디렉토리로 설정한다.
5. proc과 sys를 mount한다.

6. 여기부터 NIH 라이브러리가 사용된다. Ubuntu에서는 apt-get source libnih-dbus-dev를 통해 받을 수 있다.

참고로 NihOption은 getopt_long에서 쓰이는 struct option과 비슷한 역할을 한다. (restart는 이 구조체를 이용해 setting된다.)

7. SIGSEGV, SIGABRT (둘 다 crash), SIGCHLD, SIGALRM(둘 다 handling만, no response) 에 대한 handler를 등록한다.
8. reboot() syscall에 RB_DISABLE_CAD를 건네줌으로써 Ctrl+Alt+Del 를 누르면 init에게 SIGINT가 건네지도록 한다.
9. SIGWINCH, SIGPWR, SIGHUP, SIGUSR1에 대한 핸들러를 등록한다. (SIGHUP은 configuration reload, USR1은 d-bus reconnection에 대한 시그널)
10.  nih_child_add_watch를 통해 다른 프로세스가 exit, kill등을 하는 경우 detect한다.
11. polling하는 loop에서 불려질 event_poll을 등록한다.
12. configuration directory(/etc/init) 또는 file(/etc/init.conf)를 등록하고 configuration을 reload한다.
13. dbus를 통해 연락할 server를 열고 connect시와 disconnect시에 사용될 callback을 저장한다. 서버의 주소는 unix:abstract=/com/ubuntu/upstart 이다.
13-1. control_bus_open은 fail한다고 하니 넘어가자.
14. system log에 로그하기 위해 openlog를 부른다.
15. STARTUP_EVENT를 만들어 event queue에 등록시키고 nih_main_loop_interrupt()를 부른다
16. main loop은 event를 /etc/init에 저장된 configuration대로 event-driven loading을 해준다.

Friday, July 9, 2010

Linearizability vs. Serializability

Linearizability: a correctness condition for concurrent objects
 
A concurrent computation is linearizable if it is equivalent to a legal sequential computation
 - local property : objects are linearizable => system is linearizable
 - nonblocking property :  process invoking totally defined operations never forced to wait => better concurrency

From wikipedia:

A history is linearizable if:
  • its invocations and responses can be reordered to yield a sequential history
  • that sequential history is correct according to the sequential definition of the object
  • if a response preceded an invocation in the original history, it must still precede it in the sequential reordering (distinction from serializability)

Tuesday, May 11, 2010

영문 리눅스에서 어플리케이션의 한글 정렬 및 한글관련 동작 등이 이상할 때

우분투 등의 리눅스 배포판에서 한글로 언어를 설정해 쓰다보면 미관상이나 번역상의 문제가 있어 기본 언어는 영어로 설정한 채 쓰고 있습니다. 하지만 이렇게 하니 어플리케이션을 쓰는데 이상하게 한글과 관련된 정렬(sort) 작업 등에서 문제가 생기더군요. 음악 재생 프로그램인 Rhythmbox에서는 한글로 된 가수 이름을 클릭하면 아무 일도 벌어지지 않을 때가 있습니다. (소스를 들여보니 대부분의 한글로 된 이름들을 같은 이름으로 인식해 생기는 일이더군요. g_utf8_collate_key라는 함수가 locale에 따라 달리 동작하더군요.)

특히 정렬의 문제라면 LC_COLLATE라는 환경 변수의 문제일 가능성이 매우 큽니다. 제 경우에는 우분투 10.4를 쓰고 있는데, /etc/default/locale에

LC_COLLATE="ko_KR.UTF-8"

줄을 추가하고 재부팅하니 제대로 동작하더군요.