안드로이드/포팅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
프로그래밍/C++2013. 1. 1. 02:20

class DefaultDevice : public Device {

public:

DefaultDevice() :

ui(new DefaultUI) {

}

...


1. base class 생성자 호출


2. 생성자가 실행되기 전에 초기화 실행

- 상수(const) 멤버 변수 와 같은 경우 변경이 불가능하나,  이런 방식을 통해 변경 시킬 수 있다.

- 클래스 멤버인 reference 를 초기화 시키는 경우


'프로그래밍 > C++' 카테고리의 다른 글

[c++] expected unqualified-id before string constant  (0) 2013.05.11
C++에서 C 함수 사용하기  (0) 2013.02.02
cout , endl 의 원리  (0) 2012.04.28
Android Framework 분석을 위한 C++ 4일차  (0) 2012.04.26
[C++] Smart Pointer  (0) 2012.04.25
Posted by code cat
리눅스/커널2012. 12. 8. 11:28

VFS는 다음과 같은 구조체들이 있다.

  • 특정 파일 시스템을 표현하는 superblock 구조체
  • 특정 파일을 표현하는 inode 구조체
  • 특정 디렉터리와 경로를 표현하는 dentry 구조체
  • 프로세스와 관련해 열린 파일 구조체

눈여겨 보아야 할 점은 리눅스커널에서는 디렉터리 자체도 파일로 취급을 한다.

또한 위의 객체 따른 여러가지 operation 구조체들이 있는데 다음과 같다.

  • super_operations
  • inode_operations
  • dentry_operations
  • file operation

이들 operation 구조체들은 각 VFS구조들에 대해 함수 포인터의 구조체로 구현되어 있다.

그 밖에 구조체들에는

  • registered 된 파일 시스템을 표현하는 file_syste_type 구조체
  • 마운트 포인트를 알리는 vfsmount 구조체
  • 프로세스와 관련해 열린 파일을 표현하는 file_struct, fs_struct, namespace 구조체

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

[OS] priority inversion 해결방법  (0) 2013.01.13
monolithic vs microkernel  (0) 2013.01.13
VFS(1) -추상적 레이어-  (0) 2012.12.08
make menuconfig 시에 원하는 옵션 찾아보기  (0) 2012.11.30
initarray_cache vs arraycache_init  (0) 2012.10.21
Posted by code cat
리눅스/커널2012. 12. 8. 10:46

리눅스 커널은 많은 서브 시스템에 Virtaul Fiel System(이하 VFS) 이라는 파일 시스템 인터페이스를 유저공간 프로그램에 제공한다.

 

VFS는 open(), read(), write(), close()같은 시스템콜들이 특정 파일 시스템에 의존하지 않도록 설계되었는데, 이는 커널의 low-level 파일 시스템 interface에서 범용 인터페이스 방식으로  제공하기에 가능하다.  이 범용 인터페이스 방식은 일종의 추상적 개념이라고 할 수 있다.  즉 VFS는 최소단의 기본 동작에 대해서 추상적 인터페이스와 그에 필요한 자료 구조를 정의하고, 세부 구현등에 대해서는 파일 시스템에 알아서 맞추라고 한다.

쉽게 말해, VFS는 갑이고, 파일 시스템은 을이다.

 

VFS(갑) : 이게 이번에 우리가 필요한 사항이고요, 단가 알아서 맞추시고요.

파일시스템(을): 이런 ㅆ.. 네.

 

웃자고 한 거고, 사실은 저렇게 추상적인 개념을 제공함으로써 유저공간 프로그램들은 어떤 파일시스템이 어떻게, 예를 들어 read() 를 구현했는지 어떻게 동작했는지 상관안하고, read를 호출할 수 있는 것이다.

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

monolithic vs microkernel  (0) 2013.01.13
VFS(1) -구조체-  (0) 2012.12.08
make menuconfig 시에 원하는 옵션 찾아보기  (0) 2012.11.30
initarray_cache vs arraycache_init  (0) 2012.10.21
BYTES_PER_WORD  (0) 2012.10.15
Posted by code cat
리눅스/커널2012. 11. 30. 19:45

커널에서 make menuconfig으로 컴파일 설정 시에 원하는 옵션이 어디에 있는지 모르겠다면, /를 누르면 CONFIG_로 search 할 수 있게 된다.

 

몰랐는데, 아니까 너무 편하다!!!!

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

VFS(1) -구조체-  (0) 2012.12.08
VFS(1) -추상적 레이어-  (0) 2012.12.08
initarray_cache vs arraycache_init  (0) 2012.10.21
BYTES_PER_WORD  (0) 2012.10.15
Newton-Raphson technique  (0) 2012.10.15
Posted by code cat
카테고리 없음2012. 11. 24. 19:31

출처: ??

 


&item1.list 은  item1의 list 주소값 - offset(struct item.list) 은 struct item 내의 list의 옵셋

즉 list1 의 시작 주소값이 나옴

Posted by code cat