C, C++2011. 9. 18. 17:25
반응형


visual studio 2008/2010 을 대상으로한 색 모음(color scheme)입니다.
 사용 방법은
  1. *.settings 파일을 다운로드 받는다.
     다운로드시, 임의의 경로가 아닌 자신의 계정에서 접근이 가능한 경로에 넣어 둔다.
     (필자는 studio-style 경로등을 만들어서 넣어둠)
 2. visual studio menu 중 tools / import and export  settings 를 선택하여 설정 정보를
    import 한다. 이때 기존 사용 환경 정보를 백업하는 것도 가능하다.
 3. 대부분 일단 import 한 정보에다가 추가 변경 설정을 할 것이므로, *.settings 파일은 후에
    별도의 자신만의 이름으로 설정하여 재사용하는 것이 좋다.

012


반응형
Posted by Jay Two
C, C++2011. 7. 31. 23:02
반응형
 

츌처 : http://www.scriptol.com/programming/history.php

 

C (1973, AT&T, Dennis Ritchie, Ken Thompson, Brian Kernighan…) – B 와 BCPL 의 계승자



 

  • 포인터(pointer) 기능을 계승하였다. (Bcpl 과 B 는 integer pointer를 사용한다.)
  • int i, char b 등의 자료형(data type)은 C 에서 만들어진 것이다. (Bcpl 는 근대 스크립트 언어(php 등)처럼 자료형이 없다.)
  • 연산자 += 는 algol 68 에서 온것이다. (하지만 c에서는 =+ 로 사용한다.)
  • Bcpl 에서, 블록(block) 정의는 (* 와 *) 사이 에, 주석(comments)은 /* 와 */ 사이에, sub-expressions 은 ( 와 ) 사이에 둘러 싸여 있다. C 언어는 간단히 { 와 } 로만 정의한다.
  • union 과 캐스트(cast)는 Algol 68 에서 온 것이다.
  • 증감 연산자( ++ ) 는 B 언어에서 온 것이다.
  • 키워드 include 는 PL/I 에서 온 것이다.
  • preprocessor 는 1973 년에 신규 구현되었다.

 

 

 

반응형
Posted by Jay Two
C, C++2011. 7. 28. 12:48
반응형
반응형
Posted by Jay Two
C, C++2011. 7. 16. 14:06
반응형
손쉽게 gnu glibc 의 버전을 확인하는 예제이다. 
반응형
Posted by Jay Two
C, C++2011. 7. 12. 00:10
반응형

 

http://www.freak-search.com/en/thread/790540/tzset_locks_in_linux_after_fork

 

 

"mike

10.08.2010 - 01:43


I've got an issue with an application I've developed that uses a

combination of threads (pthreads) and fork()'d processes.

 

In short, my parent process has a handful of threads that run to

perform various tasks; when a new request comes into the parent

process, it forks off a new child to handle the request; one of the

first things the child does is initiate a library that has a date

class that calls tzset().

 

My parent process also logs the requests from a thread, which writes

the date to the log using localtime_r(), which also calls tzset().

 

The problem, is that one of out every x child processes fork()'d

simply hangs at a lock in tzset() when the library is initialized.

 

I've reproduced this by creating a very simple test program, that

simply calls tzset() over and over from a thread, while it forks, and

then calls tzset() in the child process- I can get it to hang almost

immediately.

 

and this only seems to happen on my Linux machines (CentO/S 5.5)- my

FreeBSD (8.0) runs my test program file, without any locks.

 

So my question is: if I fork() while tzset() is holding a lock in the

parent process, will the lock get copied to the child process locked?

Is this a known result? is

here a way around this?

 

Test program, which is just a super simple version of what I see in my

real app, and gdb output below, which is when I attached to a child

process that had hung.

 

Mike

 

#include <stdlib.h>

#include <stdio.h>

#include <time.h>

#include <unistd.h>

#include <signal.h>

#include <pthread.h>

 

static void* setter(void*)

{

while(1)

{

tzset();

}

 

return NULL;

}

 

int main(void)

{

pthread_t thread;

pthread_create(&thread, NULL, &setter, NULL);

 

signal(SIGCHLD, SIG_IGN);

 

while(1)

{

switch( fork() )

{

case 0:

{

fprintf(stderr, "CHILD >> tzset()\n");

tzset();

exit(1);

}

break;

 

case -1:

{

fprintf(stderr, ">> failed to fork() \n");

}

break;

 

default:

{

;

}

}

 

usleep(1000);

}

 

return 0;

}

 

Reading symbols from /home/mike/thr/test...done.

Attaching to program: /home/mike/thr/test, process 8397

Reading symbols from /lib64/libpthread.so.0...(no debugging symbols

found)...done.

[Thread debugging using libthread_db enabled]

Loaded symbols for /lib64/libpthread.so.0

Reading symbols from /usr/lib64/libstdc++.so.6...(no debugging symbols

found)...done.

Loaded symbols for /usr/lib64/libstdc++.so.6

Reading symbols from /lib64/libm.so.6...(no debugging symbols

found)...done.

Loaded symbols for /lib64/libm.so.6

Reading symbols from /lib64/libgcc_s.so.1...(no debugging symbols

found)...done.

Loaded symbols for /lib64/libgcc_s.so.1

Reading symbols from /lib64/libc.so.6...(no debugging symbols

found)...done.

Loaded symbols for /lib64/libc.so.6

Reading symbols from /lib64/ld-linux-x86-64.so.2...(no debugging

symbols found)...done.

Loaded symbols for /lib64/ld-linux-x86-64.so.2

0x0000003512cdfade in __lll_lock_wait_private () from /lib64/libc.so.6

(gdb) bt

#0 0x0000003512cdfade in __lll_lock_wait_private () from /lib64/

libc.so.6

#1 0x0000003512c8d20b in _L_lock_1920 () from /lib64/libc.so.6

#2 0x0000003512c8d0f1 in tzset () from /lib64/libc.so.6

#3 0x0000000000400811 in main () at test.cpp:32

(gdb) info threads

* 1 Thread 0x2ab3c2e9dbb0 (LWP 8397) 0x0000003512cdfade in

__lll_lock_wait_private () from /lib64/libc.so.6

반응형
Posted by Jay Two
C, C++2011. 1. 8. 19:59
반응형

 MapReducde는 구글이 제안한 분산 처리를 위한 개발 모델입니다. 조엘은 소프트웨어를 넘어서 에서도 소개되기도 한 이 방법은 대용량 자료의 분산 처리에 유용한 구조입니다.

 이미 하둡 등의 프레임워크가 많이 나와 있으며, 미래의 컴퓨터 언어는 이런 처리를 기본 사양으로 제공해 줄 가능성이 높습니다. 물론 기존의 컴퓨터 언어도 미래형 언어로 변신하려면 이런 기능을 끌어 안아야 할 것입니다.
 그런데 Qt 쪽에도 이런 기능이 있는가 하는 것을 찾아 보다 보니 QtConcurrent 가 있습니다. 주 대상은 멀티코어 프로그램 개발이 필요한 경우에 저수준 인터페이스의 지원을 넘어서, 고수준의 인터페이스 제공을 목적으로 하고 있습니다.

 하지만, 향후 함수형 언어의 사용을 지향하는 MapReduce 모델과 객체지향 기반 모델인 Qt를 융합하는 방향이 어떻게 될 지는 노키아(201x)의 향후 방향을 계속 지켜봐야 할 것입니다. [본문 초안은 2011년에 작성되었습니다.]
 아래는 필자가 작성한 예제이며, 듀얼코어 CPU라면 한번에 두 개까지만의 쓰레드가 실행됨을 확인할 수 있을 것입니다. 물론 두 개의 쓰레드는 듀얼코어에서 사용하기 가장 이상적인 쓰레드 개수입니다.
 예제 실행을 원하면 Nokia Qt 사이트에서 LGPL 지원하는 Qt SDK 를 받아서, 콘솔 예제를 실행해 보면 됩니다.
  



반응형
Posted by Jay Two
C, C++2010. 9. 9. 22:28
반응형

''const pointer의 member function 호출은 const 형만 가능하다'

class  ConstTest
{
private: int a;
public: ConstTest() { a = 10; }
public:
    int get_const() const { return a; } /// 함수 선언과 정의 모두에 const가 필요함.
    int get() { return a; }
};

void test( const ConstTest* pConst, ConstTest* pNonConst )
{
    int ret1 = pConst->get_const(); /// OK
    int ret2 = pConst->get(); /// COMPILE ERROR

    int ret3 = pNonConst->get_const(); /// OK
    int ret4 = pNonConst->get(); /// OK
}

int main(int argc, _TCHAR* argv[])
{
    ConstTest ct1, ct2;
    test( &ct1, &ct2 );
    return 0;
}
반응형
Posted by Jay Two
C, C++2010. 5. 4. 22:38
반응형

반응형
Posted by Jay Two