2004년 3월 29일 월요일

POSIX thread

fatal signal(segmentation fault, seg bug)시에는 모든 thread가 다 같이 죽어야 한다.

signal vector = signal handler
모든 thread는 모두 같이 stop, start, signal handler 공유
(SSTOP SCOUNT)

Implementation들은 POSIX 표준을 잘 지키지 않음

join : 한 thread가 죽을 때까지 기다림.
        (기다려 주지 않으면 부모가 죽을 때 같이 죽음)
detach : thread가 죽을 때 알아서 resource를 free함 (join할 필요없음)

join의 문제점
1. there is no wait any.
    (가장 먼저 끝나는 thread 1개만 기다리기 같은 일은 할 수 없다.)
2. 먼저 join한 thread부터 resource가 free되게 됨.

reentrant하면 thread safe하다.
(thread safe해도 reentrant하지 않을 수 있다.)

reentrant : signal받고 재진입해도 됨.
thread safe : signal받고 재진입시에는 문제가 생김

thread safe는 thread local storage를 사용해서 구현가능.
(예. PHP TSRM)

댓글 없음:

댓글 쓰기