728x90

IPC : pipe, named pipe, semaphore, message queue, shared memory, futex, socket


Futex : fast userspace mutex(Spinlock 방식)

- 장점 : 빠름 (sleep 대신 while), 

            lock이 user space에 있기 때문에 접근성이 좋음(공유 메모리나 Thread 및           Process간 공유 가능)

- 단점 : 기본적으로 loop를 계속 돌고 있기 때문에 core수가 뒷받침되어야 한다. 

           (single core에서는 소용 없음.)


pthread mutex vs pthread spinlock

Pasted from <http://www.alexonlinux.com/pthread-mutex-vs-pthread-spinlock> 



Pselect()

int pselect(int nfds, fd_set *readfds, fd_set *writefds,

           fd_set *exceptfds, const struct timespec *timeout,

           const sigset_t *sigmask);

• pselect는 struct timespec 구조체 사용한다. timespec 구조체를 사용함으로써        나노초까지 세밀하게 조정할 수 있게 되었다.


struct timespec {

    long    tv_sec;         /* seconds */

    long    tv_nsec;        /* nanoseconds */

};

• pselect 는 Linux(:12) 커널 2.6.16에 추가되었다. 이전에는 glibc에서 애뮬레이트한
          함수가 제공되었으나 버그를 가지고 있었다.

• sigmask를 사용해서 시그널을 블럭시킬 수 있다. select의 경우 수행되는 도중에         시그널에 의한 인터럽트가 발생하게 되면, race condition 혹은 무한 블록킹         상태에 놓일 수 있었다. pselect를 사용하면 이러한 문제를 제거할 수 있다. 


Pasted from <http://www.joinc.co.kr/modules/moniwiki/wiki.php/man/2/select> 

Pselect가 select와 다른 점

- Nano sec단위로 사용하므로 이론적으로는 타이머 해상도가 정밀하나 실전에서는
        micro sec단위도 안정적으로 제공하지 못한다.

- Timeout parameter를 변경하지 않는다. 사용할 때마다 timeout을 다시 설정할
        필요가 없음

- Signal parameter가 추가됨(sigmask) : signal 을 차단함.




Select() : 동기식 다중 입출력 제공
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>

Int select (int n,
                  fd_set *readfds,
                   fd_set *writefds,
                   fd_set *execptfds,
                   struct timeval *timeout);

FD_CLR(int fd, fd_set *set);       /* delete FD */
FD_ISSET(int fd, fd_set *set);    /* select의 결과에 해당 fd가 있는지 */
FD_SET(int fd, fd_set *set);      /* add FD*/
FD_ZERO(fd_set *set);


#include <sys/time.h>
Struct timeval {
             long tv_sec;    /* sec */
             long tv_usec;  /* micro sec */
};

Poll() : select를 보완 (fd set을 하나로 통일)
#include <sys/poll.h>
Int poll (struct pollfd *fds, unsigned int nfds, int timeout);

#include <sys/poll.h>
Struct pollfd {
            int fd;
            short events;   /* 감시 대상 요청 */
            short revents; /* returned event */
}

Events:
POLLIN : Data other than high-priority data may be read without blocking.
POLLRDNORM : Normal data may be read without blocking.
POLLRDBAND : Priority data may be read without blocking.
POLLPRI : High-priority data may be read without blocking.
POLLOUT : Normal data may be written without blocking.
POLLWRNORM : Equivalent to POLLOUT.
POLLWRBAND : Priority data may be written.
POLLERR : An error has occurred on the device or stream. This flag is only valid in the revents bitmask; it shall be ignored in the events member.
POLLHUP : The device has been disconnected. This event and POLLOUT are mutually-exclusive; a stream can never be writable if a hangup has occurred. However, this event and POLLIN, POLLRDNORM, POLLRDBAND, or POLLPRI are not mutually-exclusive. This flag is only valid in the revents bitmask; it shall be ignored in the events member.
POLLNVAL : The specified fd value is invalid. This flag is only valid in the revents member; it shall ignored in the events member.

Ppoll() : pselect 처럼 만든 것, 나노초 단위, sigmask 제공, linux 전용
#define _GNU_SOURCE
#include <sys/poll.h>
Int ppoll (struct pollfd *fds,
                  nfds_t nfds,
                  const struct timespec *timeout,
                  const sigset_t *sigmask);

Poll과 select 비교

oll 

select 

매개변수에 +1(fd+1)이 필요없다 

 

fd의 숫자가 큰 경우 select보다 효율적 

fd_set값이 크면 비효율적이다. bitmask를 모두 검사하며 특히 bit가 분산된 경우 더욱 비효율적이다 

 

 매번 set을 초기화해야 한다.(FD_ZERO)

 

 이식성을 높이기 위해 timeout parameter(timeval)를 매번 초기화 해야함

Pselect() 사용할 경우 초기화 안해도

 몇몇 UNIX에서는 poll을 지원하지 않는다

 이식성이 높다

 

 microsecond단위까지는 timeout resolution이 더 좋다

Pasted from <http://bluelimn.tistory.com/entry/2-epoll-select-poll>

 





728x90

'Programming > linux왕초보' 카테고리의 다른 글

fork  (0) 2015.05.26
Linux SSD 최적화  (0) 2015.04.17
fflush, fileno  (0) 2015.04.07
[Linux] stream write  (0) 2015.03.26
linux filesystem 사용 용량 확인  (0) 2015.03.18
Example syntax for Secure Copy (scp) : scp사용법  (0) 2014.04.02
tar 분할압축/풀기  (0) 2014.03.20
slang_rs_export_foreach.cpp Error: ParamName  (0) 2014.02.26
printk : kernel log 설정  (0) 2013.11.19
[Linux] Top 명령어 사용법  (0) 2013.11.08
728x90

https://source.android.com/source/building-devices.html


Building fastboot and adb

$make fastboot adb

out/host/linux-x86/bin$ ls fastboot



fastboot mode on target device

Booting into fastboot mode


DeviceKeys
hammerheadPress and hold both Volume Up and Volume Down, then press and hold Power
floPress and hold Volume Down, then press and hold Power
debPress and hold Volume Down, then press and hold Power
mantaPress and hold both Volume Up and Volume Down, then press and hold Power
makoPress and hold Volume Down, then press and hold Power
grouperPress and hold Volume Down, then press and hold Power
tilapiaPress and hold Volume Down, then press and hold Power
phantasmPower the device, cover it with one hand after the LEDs light up and until they turn red
maguroPress and hold both Volume Up and Volume Down, then press and hold Power
toroPress and hold both Volume Up and Volume Down, then press and hold Power
toroplusPress and hold both Volume Up and Volume Down, then press and hold Power
pandaPress and hold Input, then press Power
wingrayPress and hold Volume Down, then press and hold Power
crespoPress and hold Volume Up, then press and hold Power
crespo4gPress and hold Volume Up, then press and hold Power




find ID for target device

$ ./fastboot devices



Unlock bootloader

$ fastboot oem unlock


Upload all image

 $ cd ./framework
 $ fastboot flashall


Upload each image

$ cd out/target/product/manta

 $ fastboot flash boot boot.img
 $ fastboot flash system system.img
 $ fastboot flash userdata userdata.img
 $ fastboot flash recovery recovery.img


done!!




************************************

On Nexus 10, after unlocking the bootloader, the internal storage is left unformatted and must be formatted with

$ fastboot format cache
$ fastboot format userdata


Cleaning up when adding proprietary binaries

In order to make sure that the newly installed binaries are properly taken into account after being extracted, the existing output of any previous build needs to be deleted with

$ make clobber


728x90
728x90

Can't locate Switch.pm in @INC (you may need to install the Switch module) (@INC contains: /etc/perl /usr/local/lib/perl/5.18.2 /usr/local/share/perl/5.18.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.18 /usr/share/perl/5.18 /usr/local/lib/site_perl .) at external/webkit/Source/WebCore/make-hash-tools.pl line 23. BEGIN failed--compilation aborted at external/webkit/Source/WebCore/make-hash-tools.pl line 23. make: * [out/target/product/generic/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/html/DocTypeStrings.cpp] Error 2



Solve

$sudo apt-get install libswitch-perl


I have solve this, actually i was using 14.04LTS for android 4.2jellybean source code. In 14.04LTS have to install the switch module. Below is the procedure to install

1:use below command and configure as automatic $cpan App::cpanminus

2:install switch $cpanm Switch

Note:By using these two commands that problem solved in my Ubuntu 14.04LTS....



ref : http://stackoverflow.com/questions/23314652/cant-locate-switch-pm

thank you stackoverflow

728x90
728x90

make iso_img TARGET_PRODUCT=android_x86 

하면서 만난 에러들 처리


Error : 

Notice file: frameworks/base/libs/androidfw/NOTICE -- out/host/linux-x86/obj/NOTICE_FILES/src//lib/libandroidfw.a.txt

Notice file: system/core/libutils/NOTICE -- out/host/linux-x86/obj/NOTICE_FILES/src//lib/libutils.a.txt

Notice file: system/core/libcutils/NOTICE -- out/host/linux-x86/obj/NOTICE_FILES/src//lib/libcutils.a.txt

Notice file: system/core/liblog/NOTICE -- out/host/linux-x86/obj/NOTICE_FILES/src//lib/liblog.a.txt

prebuilts/tools/gcc-sdk/gcc: line 40: prebuilts/tools/gcc-sdk/../../gcc/linux-x86/host/i686-linux-glibc2.7-4.6/bin/i686-linux-gcc: No such file or directory


solution :
$ apt-get install build-essential

$ apt-get install g++-multilib


$ apt-get install git gnupg flex bison gperf zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 u-boot-tools minicom libncurses5-dev uuid-dev:i386 liblzo2-dev:i386


apt-get install 하는 도중에 다시 다음과 같은 에러를 만남

Error : 

E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_3.13.0-30.54_amd64.deb  404  Not Found [IP: 91.189.88.153 80]


E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_3.13.0-30.54_i386.deb  404  Not Found [IP: 91.189.88.153 80]


solution :

  $ vi /etc/apt/sources.list

- deb http://security.ubuntu.com/ubuntu trusty-security main restrict

+ deb http://security.ubuntu.com/ubuntu trusty-security main

   $ apt-get update


   $ apt-get install git gnupg flex bison gperf zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 u-boot-tools minicom libncurses5-dev uuid-dev:i386 liblzo2-dev:i386


다시 다음과 같은 Error를 만남
Error :

target Export Resources: framework-res (out/target/common/obj/APPS/framework-res_intermediates/package-export.apk)

/bin/bash: jar: command not found

make: *** [out/target/common/obj/APPS/framework-res_intermediates/package-export.apk] Error 127


solution:
 $ sudo update-alternatives --install "/usr/bin/jar" "jar" "/usr/local/java/jdk1.7.0_60/bin/jar" 1;
 $ sudo update-alternatives --set jar /usr/local/java/jdk1.7.0_60/bin/jar;

Error :

libpng warning: Ignoring attempt to set cHRM RGB triangle with zero area

libcore/libdvm/src/main/java/java/lang/Enum.java:150: error: ordinal has private access in Enum

        return ordinal - o.ordinal;


solution : 
https://android.googlesource.com/platform/libcore/+/9c8864d39704b3d264ef9dfbdc1bfcfd8f1b6bb9%5E!/#F0

149     public final int compareTo(E o) {
-150         return ordinal - o.ordinal;
+150         return ordinal - o.ordinal();
151     }

Error : 
File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
make: *** [out/target/product/x86/obj/GYP/shared_intermediates/templates/org/chromium/base/ActivityState.java] Error 1

solution : 
  $ vi ~/.bashrc
added following lines in end
JAVA_HOME=/usr/lib/jvm/jdk1.7.0
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH

  $ source ~/.bashrc

Error : 
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.util.ExceptionWithContext
at com.android.dex.util.ExceptionWithContext.withContext(ExceptionWithContext.java:45)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:377)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:139)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:94)
at com.android.dx.command.dexer.Main.processClass(Main.java:682)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
at com.android.dx.command.dexer.Main.access$600(Main.java:78)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
at com.android.dx.command.dexer.Main.processOne(Main.java:596)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
at com.android.dx.command.dexer.Main.run(Main.java:230)
at com.android.dx.command.dexer.Main.main(Main.java:199)
at com.android.dx.command.Main.main(Main.java:103)
Caused by: java.lang.NullPointerException
at com.android.dx.cf.code.ConcreteMethod.<init>(ConcreteMethod.java:87)
at com.android.dx.cf.code.ConcreteMethod.<init>(ConcreteMethod.java:75)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:277)
... 15 more
...while processing <init> (Lcom/android/internal/telephony/gsm/GSMPhone;)V
...while processing com/android/internal/telephony/gsm/GSMPhone$1.class

1 error; aborting

solution : 
java가 맞지 않는 것 같으니 guide 대로 다시 설치해보자
  $ sudo apt-get install openjdk-7-jdk
   개선사항 없음

source build/envsetup.sh
export ARCH=x86
lunch android_x86-eng


728x90

+ Recent posts