Linux API/linux2016. 12. 20. 21:10

머라도 하나씩 직접해보자 ㅜㅜ


[링크 : http://www.joinc.co.kr/w/Site/system_programing/Book_LSP/ch08_IPC]

'Linux API > linux' 카테고리의 다른 글

linux kernel governor 관련 코드  (0) 2018.04.17
linux shared memory 관련  (0) 2016.12.22
pthread detach while  (0) 2016.12.20
fd <-> fp 변환  (0) 2016.10.07
shared memory - linux/IPC  (0) 2016.06.28
Posted by 구차니
Linux API/linux2016. 12. 20. 20:58

쓰레드 보다보니

공부는 해냐하는데 끄응 ㅜㅜ


암튼 쓰레드를 분리하면 자식 스레드가 종료시 자원을 반납하지만

분리할 쓰레드가 무한루프 돌면

메모리 누수로 이어지는 듯


프로세스는 종료되었고 그럼 프로세스로서 cpu를 할당받진 않을테나

해당 쓰레드가 공유하던 메모리만 붕 떠버리려나?


[링크 : http://www.joinc.co.kr/w/Site/system_programing/Book_LSP/ch07_Thread]

[링크 : http://stackoverflow.com/.../how-can-i-kill-a-pthread-that-is-in-an-infinite-loop-from-outside-that-loop]

[링크 : http://stackoverflow.com/questions/25655706/how-to-terminate-or-stop-a-detached-thread-in-c]

'Linux API > linux' 카테고리의 다른 글

linux shared memory 관련  (0) 2016.12.22
linux ipc  (0) 2016.12.20
fd <-> fp 변환  (0) 2016.10.07
shared memory - linux/IPC  (0) 2016.06.28
메시지 큐 - ipc  (0) 2016.06.28
Posted by 구차니
embeded/Cortex-M4 Ti2016. 12. 20. 10:49

my Ti 계정 있어야 함

진즉에 검색해볼걸 그랬나...


SW-DK-TM4C123G-2.1.3.156.exeDK-TM4C123GL Kit Software60168K

[링크 : http://software-dl.ti.com/tiva-c/SW-TM4C/latest/index_FDS.html]



소스 기본 골격 자체는 lm3s1968이랑 차이가 없네

    //
    // Check to see if Hibernation module is already active, which could mean
    // that the processor is waking from a hibernation.
    //
    if(HibernateIsActive())
    {
        //
        // Read the status bits to see what caused the wake.
        //
        ui32Status = HibernateIntStatus(0);
        HibernateIntClear(ui32Status);

        //
        // If the wake is due to button or RTC, then read the first location
        // from the battery backed memory, as the hibernation count.
        //
        if(ui32Status & (HIBERNATE_INT_PIN_WAKE | HIBERNATE_INT_RTC_MATCH_0))
        {
            HibernateDataGet(&ui32HibernateCount, 1);
        }
    }

    //
    // Enable the Hibernation module.  This should always be called, even if
    // the module was already enabled, because this function also initializes
    // some timing parameters.
    //
    HibernateEnableExpClk(ROM_SysCtlClockGet());

    //
    // If the wake was not due to button or RTC match, then it was a reset.
    //
    if(!(ui32Status & (HIBERNATE_INT_PIN_WAKE | HIBERNATE_INT_RTC_MATCH_0)))
    {
        //
        // Configure the module clock source.
        //
        HibernateClockConfig(HIBERNATE_OSC_LOWDRIVE);

        //
        // Wait a couple of seconds in case we need to break in with the
        // debugger.
        //
        SysTickWait(3 * 100);

        //
        // Allow time for the crystal to power up.  This line is separated from
        // the above to make it clear this is still needed, even if the above
        // delay is removed.
        //
        SysTickWait(15);
    }

    //
    // Clear and enable the RTC and set the match registers to 5 seconds in the
    // future. Set both to same, though they could be set differently, the
    // first to match will cause a wake.
    //
    HibernateRTCSet(0);
    HibernateRTCEnable();
    HibernateRTCMatchSet(0, 5);

    //
    // Set wake condition on pin or RTC match.  Board will wake when 5 seconds
    // elapses, or when the button is pressed.
    //
    HibernateWakeSet(HIBERNATE_WAKE_PIN | HIBERNATE_WAKE_RTC);

    //
    // Request hibernation.
    //
    HibernateRequest();


'embeded > Cortex-M4 Ti' 카테고리의 다른 글

tm4c hibernate module 초기화 무한루프  (2) 2017.01.10
tivaware swd debug / semihosting  (0) 2017.01.10
tm4c rtc trim...  (0) 2016.11.23
tm4c rtc 빨라...  (0) 2016.11.02
tm4c hibernate module 초기화 관련..  (0) 2016.11.01
Posted by 구차니

시위할때 계란 던지지 말라고 그런걸지도?

비싼데 어떻게 던지겠어 훗?

이런 심정이 반영된 결과?


[링크 : http://v.media.daum.net/v/20161219152203036]




+

개인적인 추측이지만..

이러다가 내년이면 우리나라 에서 닭이 멸종할지도

Posted by 구차니
Programming/C Win32 MFC2016. 12. 19. 09:18

심심해서 만든 로또 프로그램에 정렬기능 추가

qsort()는 첨 써보네..

일단 compare 함수에서 캐스팅 하는 부분을 잘 해주면...

범용으로 쓸수 있을려나? 무리일려나?


int compare (const void *first, const void *second)

{

    if (*(unsigned char*)first > *(unsigned char*)second)

        return 1;

    else if (*(unsigned char*)first < *(unsigned char*)second)

        return -1;

    else 

        return 0;

}


void CLottoDlg::OnButton1() 

{

// TODO: Add your control notification handler code here

int idx;

unsigned char flag[45];

unsigned char genval = 0;

CString *strarray[42] =

{

&m_edit1,&m_edit2,&m_edit3,&m_edit4,&m_edit5,&m_edit6,

&m_edit7,&m_edit8,&m_edit9,&m_edit10,&m_edit11,&m_edit12,

&m_edit13,&m_edit14,&m_edit15,&m_edit16,&m_edit17,&m_edit18,

&m_edit19,&m_edit20,&m_edit21,&m_edit22,&m_edit23,&m_edit24,

&m_edit25,&m_edit26,&m_edit27,&m_edit28,&m_edit29,&m_edit30,

&m_edit31,&m_edit32,&m_edit33,&m_edit34,&m_edit35,&m_edit36,

&m_edit37,&m_edit38,&m_edit39,&m_edit40,&m_edit41,&m_edit42

};


unsigned char row[42];

memset(flag, 0x00, sizeof(unsigned char) * 45);

srand(time(NULL));


for(idx = 0 ;idx < 30;idx++)

{

do

{

genval = rand() % 45;

}

while(flag[genval] != 0);

flag[genval] = 1;

row[idx] = genval;

}


for(idx = 0; idx < 5; idx++)

{

qsort(row + (idx * 6), 6, sizeof(char), compare);

}


for(idx = 0; idx < 30; idx++)

{

strarray[idx]->Format("%d",row[idx] + 1);

}


UpdateData(FALSE);


lotto.zip


'Programming > C Win32 MFC' 카테고리의 다른 글

MFC HTTP GET/POST  (0) 2017.03.02
win32 http 인증 관련  (0) 2017.02.28
MFC UpdateData()  (0) 2016.12.16
윈도우에서 dll 동적 라이브러리 사용하기  (0) 2016.04.04
가변 매크로 __VA_ARGS__  (0) 2016.03.18
Posted by 구차니
embeded/raspberry pi2016. 12. 16. 15:08

테스트 해보니.. maxcpus는 작동하지 않는듯


# replace N with the number of cores you want to keep using

maxcpus=N 

[링크 : http://raspberrypi.stackexchange.com/questions/32562/how-to-make-the-raspberry-pi-consume-less-power]


arm_freq Frequency of the ARM CPU in MHz. The default value is 700.

core_freq Frequency of the GPU processor core in MHz. It has an impact on CPU performance, since it drives the L2 cache. The default value is 250.

sdram_freq Frequency of the SDRAM in MHz. The default value is 400.


gpu_freq Sets core_freq, h264_freq, isp_freq, and  v3d_freq together. The default value is 250.

h264_freq Frequency of the hardware video block in MHz. The default value is 250.

isp_freq Frequency of the image sensor pipeline block in MHz. The default value is 250.

v3d_freq Frequency of the 3D block in MHz. The default value is 250.


arm_freq_min Minimum value of arm_freq used for dynamic frequency clocking. The default value is 700.

core_freq_min Minimum value of core_freq used for dynamic frequency clocking. The default value is 250.

sdram_freq_min Minimum value of sdram_freq used for dynamic frequency clocking. The default value is 400.


[링크 : https://www.raspberrypi.org/documentation/configuration/config-txt.md]

[링크 : http://raspberrypi.stackexchange.com/questions/23442/raspberry-pi-b-cpu-clock-manipulation]

[링크 : http://raspberrypi.stackexchange.com/questions/41517/low-enery-consumption-kernel]


+

길어서 cpu 1,2,3은 삭제

$ cpufreq-info

cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009

Report errors and bugs to cpufreq@vger.kernel.org, please.

analyzing CPU 0:

  driver: BCM2835 CPUFreq

  CPUs which run at the same hardware frequency: 0 1 2 3

  CPUs which need to have their frequency coordinated by software: 0 1 2 3

  maximum transition latency: 355 us.

  hardware limits: 600 MHz - 900 MHz

  available frequency steps: 600 MHz, 900 MHz

  available cpufreq governors: conservative, ondemand, userspace, powersave, performance

  current policy: frequency should be within 600 MHz and 900 MHz.

                  The governor "ondemand" may decide which speed to use

                  within this range.

  current CPU frequency is 600 MHz.


$ cat /boot/config.txt

#uncomment to overclock the arm. 700 MHz is the default.

#arm_freq=800

arm_freq_min=300


길어서 cpu 1,2,3은 삭제


$ cpufreq-info

cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009

Report errors and bugs to cpufreq@vger.kernel.org, please.

analyzing CPU 0:

  driver: BCM2835 CPUFreq

  CPUs which run at the same hardware frequency: 0 1 2 3

  CPUs which need to have their frequency coordinated by software: 0 1 2 3

  maximum transition latency: 355 us.

  hardware limits: 300 MHz - 900 MHz

  available frequency steps: 300 MHz, 900 MHz

  available cpufreq governors: conservative, ondemand, userspace, powersave, performance

  current policy: frequency should be within 300 MHz and 900 MHz.

                  The governor "ondemand" may decide which speed to use

                  within this range.

  current CPU frequency is 300 MHz.

  cpufreq stats: 300 MHz:16.33%, 900 MHz:83.67%  (7)


$ cat /boot/config.txt

arm_freq=600

arm_freq_min=100


$ cpufreq-info

cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009

Report errors and bugs to cpufreq@vger.kernel.org, please.

analyzing CPU 0:

  driver: BCM2835 CPUFreq

  CPUs which run at the same hardware frequency: 0 1 2 3

  CPUs which need to have their frequency coordinated by software: 0 1 2 3

  maximum transition latency: 355 us.

  hardware limits: 100.0 MHz - 600 MHz

  available frequency steps: 100.0 MHz, 600 MHz

  available cpufreq governors: conservative, ondemand, userspace, powersave, performance

  current policy: frequency should be within 100.0 MHz and 600 MHz.

                  The governor "ondemand" may decide which speed to use

                  within this range.

  current CPU frequency is 600 MHz.

  cpufreq stats: 100.0 MHz:0.00%, 600 MHz:100.00% 


테스트 해보니.. 0.04W 감소 월(30일)기준 28.8W 절약... 이라고 해야하나?

100MHz 1.70W -> 1.66W

Posted by 구차니
Programming/C Win32 MFC2016. 12. 16. 13:03

심심해서 오랫만에 짜본 초 허접 로또번호 생성 ㅋㅋㅋ

DDX 통해서 값 교환은 처음인가.. 어색하네?


아무튼 class wizard로 변수 연결해주다가 귀찮아서

소스에서 DDX 부분에 손봐서는 변수는 연결했는데

값이 안나오길래 검색해보니 UpdateData()라는 함수 발견


msdn은 설명이 어려운데

true 면은 컨트롤에서 연결된 변수로 값을 가져오고(UI쪽에서 끌어오기)

false 면은 연결된 변수의 값을 컨트롤러 넘겨준다(UI쪽으로 넘겨주기)


void CLottoDlg::OnButton1() 

{

// TODO: Add your control notification handler code here

int idx;

unsigned char flag[45];

unsigned char genval = 0;

CString *strarray[42] =

{

&m_edit1,&m_edit2,&m_edit3,&m_edit4,&m_edit5,&m_edit6,

&m_edit7,&m_edit8,&m_edit9,&m_edit10,&m_edit11,&m_edit12,

&m_edit13,&m_edit14,&m_edit15,&m_edit16,&m_edit17,&m_edit18,

&m_edit19,&m_edit20,&m_edit21,&m_edit22,&m_edit23,&m_edit24,

&m_edit25,&m_edit26,&m_edit27,&m_edit28,&m_edit29,&m_edit30,

&m_edit31,&m_edit32,&m_edit33,&m_edit34,&m_edit35,&m_edit36,

&m_edit37,&m_edit38,&m_edit39,&m_edit40,&m_edit41,&m_edit42

};


memset(flag, 0x00, sizeof(unsigned char) * 45);

srand(time(NULL));


for(idx = 0 ;idx < 42;idx++)

{

do

{

genval = rand() % 45;

}

while(flag[genval] != 0);

flag[genval] = 1;


strarray[idx]->Format("%d",genval + 1);

}


UpdateData(FALSE);


[링크 : http://lazypaul.tistory.com/232]

[링크 : https://msdn.microsoft.com/ko-kr/library/t9fb9hww.aspx]

'Programming > C Win32 MFC' 카테고리의 다른 글

win32 http 인증 관련  (0) 2017.02.28
MFC / stdlib / qsort example  (0) 2016.12.19
윈도우에서 dll 동적 라이브러리 사용하기  (0) 2016.04.04
가변 매크로 __VA_ARGS__  (0) 2016.03.18
#import ?  (0) 2015.12.21
Posted by 구차니
embeded/odroid2016. 12. 15. 21:21

odorid u3

eMMC 8GB + SD 16GB

100M 랜선 연결 idle 1.95W

랜선빼고 1.72W (-0.23W)

SD 카드는 영향을 주지 않음(내장형 SD)


USB 키보드 0.17W

USB 마우스 0.53W


평균 2W 먹음(idle)

2W * 24 * 30 = 1440W = 1.4KW



---

번외

라즈베리 파이

lan / hdmi 연결 안함  1.70W

lan만 연결 1.93W


hdmi 연결 하고 부팅 1.76W

hdmi + lan 2.01W

hdmi 연결부팅 후 hdmi 제거 1.76W


Posted by 구차니
Posted by 구차니
프로그램 사용/u-boot2016. 12. 14. 17:41

nand 자체를 초기화 하는 명령어

배드 섹터 넘쳐 날때 해주면 초기화 하는데

생겨나는건 여전...


# nand scrub


NAND scrub: device 0 whole chip

Warning: scrub option will erase all factory set bad blocks!

         There is no reliable way to recover them.

         Use this command only for testing purposes if you

         are sure of what you are doing!


Really scrub this NAND flash? <y/N>

Erasing at 0xffe0000 -- 100% complete.

OK 


[링크 : http://www.stlinux.com/howto/NAND/clean]

[링크 : http://damduc.tistory.com/317]

'프로그램 사용 > u-boot' 카테고리의 다른 글

uboot filesize 환경변수  (0) 2016.11.17
tftpd-hpa  (0) 2016.11.08
ubuntu 12.04 xinetd/tftpd 느린 이유  (0) 2016.11.08
uboot bootargs 기본값 설정하기  (0) 2015.02.09
uboot 메모리 관련 명령어  (0) 2015.01.08
Posted by 구차니