안드로이드/포팅2013. 2. 4. 15:59

쉽게 요약하자면 C library가 고작 pthread_cancle지원하자고 너무 커지기 때문에 바이오닉 C에서는 지원 안한단다. 대신 pthread_cleanup_push()와 pthread_cleanup_pop()은 지원하니까 적절히 사용하자.

pthread_cancel():

   pthread_cancel() will *not* be supported in Bionic, because doing this would
   involve making the C library significantly bigger for very little benefit.

   Consider that:

     - A proper implementation must insert pthread cancellation checks in a lot
       of different places of the C library. And conformance is very difficult
       to test properly.

     - A proper implementation must also clean up resources, like releasing
       memory, or unlocking mutexes, properly if the cancellation happens in a
       complex function (e.g. inside gethostbyname() or fprintf() + complex
       formatting rules). This tends to slow down the path of many functions.

     - pthread cancellation cannot stop all threads: e.g. it can't do anything
       against an infinite loop

     - pthread cancellation itself has short-comings and isn't very portable
       (see http://advogato.org/person/slamb/diary.html?start=49 for example).

   All of this is contrary to the Bionic design goals. If your code depends on
   thread cancellation, please consider alternatives.

   Note however that Bionic does implement pthread_cleanup_push() and
   pthread_cleanup_pop(), which can be used to handle cleanups that happen when
   a thread voluntarily exits through pthread_exit() or returning from its
   main function.

Posted by code cat
프로그래밍/C++2013. 2. 2. 20:32

예를 들어 c에서 라이브러리로 제공되는 함수가 있다고 하면 c++에서 그냥 c 함수 부르듯이 하면 알 수 없는 link error를 뿜는다.  

어?   분명히 제대로 적었는데... 하고 헤매일텐데, 이것은 syntax error나 라이브러리 링크가 제대로 안되서 그런 것이 아니라, symbol 이름 안 맞아서 그렇다.  이럴 땐, c++ 에서

extern "C" 함수선언

이렇게 해주면 된다.

Posted by code cat

local git에 commit한 뒤, local source control에서만 지우고 싶을 때는(물론 remote 저장소로 업로드가 안되어 있어야겠지)


git rm --cached file_name


으로 지우면 된다.

Posted by code cat
리눅스/커널2013. 1. 13. 14:41

priority inversion :

현상:

높은 우선 순위의 태스크가 접근하려고 하는 공유자원을 낮은 우선 순의의 태스크가  이미 사용하고 있을 때, 중간 우선 순위에 해당하는 태스크가 수행되어 상위 우선 태스크를 수행하지 못하게 되는 현상


해결 방법:

낮은 우선 순위의 태스크의 우선 순위를 높은 우선 순위로 올려서 높은 우선 순위로 수행되게 하고 공유 자원을 시스템에 반환하도록 하면 그 후 높은 우선 순위의 태스크가 수행되게 된다.


뮤텍스관련 해결 방법

priority inheritance protocol: 뮤텍스를 획득한 낮은 우선 순위 태스크의 우선 순위를 임시로 뮤텍스를 요청한 높은 우선 순위 태스크의 우선 순위 값과 같게 오려준다.  변경된 태스크의 우선 순위는 뮤텍스 반환 동시에 본래의 값으로 돌아간다.

ceiling priority protocol: 태스크가 뮤텍스를 획득할 때 태스크의 우선 순위를 해당 뮤텍스를 사용할 가능성이 있는 태스크 중 가장 높은 우선 순위를 가진 태스크의 우선 순위로 변경한다.  뮤텍스가 반환될 때 태스크의 우선 순위는 본래 값으로 돌아간다.


'리눅스 > 커널' 카테고리의 다른 글

[안드로이드][커널]Unknown symbol _GLOBAL_OFFSET_TABLE_  (0) 2013.08.09
Kernel Oops의 Taint 종류  (0) 2013.07.25
monolithic vs microkernel  (0) 2013.01.13
VFS(1) -구조체-  (0) 2012.12.08
VFS(1) -추상적 레이어-  (0) 2012.12.08
Posted by code cat
리눅스/커널2013. 1. 13. 12:58

출처:  http://en.wikipedia.org/wiki/File:OS-structure2.svg



'리눅스 > 커널' 카테고리의 다른 글

Kernel Oops의 Taint 종류  (0) 2013.07.25
[OS] priority inversion 해결방법  (0) 2013.01.13
VFS(1) -구조체-  (0) 2012.12.08
VFS(1) -추상적 레이어-  (0) 2012.12.08
make menuconfig 시에 원하는 옵션 찾아보기  (0) 2012.11.30
Posted by code cat