http://richard.giliam.net/?p=20
가장 쉬운 예시

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka3540.html
그 다음 쉬운 예시

http://www.ethernut.de/en/documents/arm-inline-asm.html
위랑 비슷하긴 한데 조금 다른 예시


http://vada.skku.ac.kr/ClassInfo/comp-arch/SoC-arch/%B8%F0%B5%E205_%C7%C1%B7%CE%BC%BC%BC%AD_%BC%B3%B0%E8_%BD%C7%BD%C0_I.pdf
그 외에 추가로 반드시 알아야 할 내용들 (문법들이나 기타 등등)
아 한글이다... 그래서 좋음


기타 x86 예제

kernel vdso에 있는 파일

vdso_test.c

104 asm (
105     "".text"\n"
106     "".global _start"\n"
107         "".type _start,@function"\n"
108         ""_start:"\n\t"
109         ""mov %rsp,%rdi"\n\t"
110         ""jmp c_main""
111     );
112 

'devel > man & example' 카테고리의 다른 글

#define 문자열 치환 및 합치기  (0) 2012.07.15
strstr  (0) 2012.01.28
thread starvation  (0) 2011.12.09
scanf에서 fflush(stdin) 사용 안하고 \n 파싱해서 없애기  (2) 2011.11.27
function pointer  (0) 2009.11.24
Posted by 쵸코케키
$ make configure-host
Configuring in ./libiberty
configure: creating cache ./config.cache
checking whether to enable maintainer-specific portions of Makefiles... no
checking for makeinfo... makeinfo
checking for perl... perl
checking build system type... i686-pc-cygwin
checking host system type... i686-pc-cygwin
checking for i686-pc-cygwin-ar... ar
checking for i686-pc-cygwin-ranlib... ranlib
checking for i686-pc-cygwin-gcc... gcc
checking for C compiler default output file name... a.exe
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... .exe
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking how to run the C preprocessor... gcc -E
checking whether gcc supports -W... yes
checking whether gcc supports -Wall... yes
checking whether gcc supports -Wwrite-strings... yes
checking whether gcc supports -Wc++-compat... yes
checking whether gcc supports -Wstrict-prototypes... yes
checking whether gcc supports -pedantic ... yes
checking whether gcc and cc understand -c and -o together... yes
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... no
checking for a BSD-compatible install... /usr/bin/install -c
checking for sys/file.h... yes
checking for sys/param.h... yes
checking for limits.h... yes
checking for stdlib.h... (cached) yes
checking for malloc.h... yes
checking for string.h... (cached) yes
checking for unistd.h... (cached) yes
checking for strings.h... (cached) yes
checking for sys/time.h... yes
checking for time.h... yes
checking for sys/resource.h... yes
checking for sys/stat.h... (cached) yes
checking for sys/mman.h... yes
checking for fcntl.h... yes
checking for alloca.h... yes
checking for sys/pstat.h... no
checking for sys/sysmp.h... no
checking for sys/sysinfo.h... yes
checking for machine/hal_sysinfo.h... no
checking for sys/table.h... no
checking for sys/sysctl.h... no
checking for sys/systemcfg.h... no
checking for stdint.h... (cached) yes
checking for stdio_ext.h... no
checking for process.h... yes
checking for sys/prctl.h... no
checking for sys/wait.h that is POSIX.1 compatible... yes
checking whether time.h and sys/time.h may both be included... yes
checking whether errno must be declared... no
checking size of int... 4
checking for a 64-bit type... uint64_t
checking for intptr_t... yes
checking for uintptr_t... yes
checking for ssize_t... yes
checking for pid_t... yes
checking for library containing strerror... none required
checking for asprintf... yes
checking for atexit... yes
checking for basename... yes
checking for bcmp... yes
checking for bcopy... yes
checking for bsearch... yes
checking for bzero... yes
checking for calloc... yes
checking for clock... yes
checking for ffs... yes
checking for getcwd... yes
checking for getpagesize... yes
checking for gettimeofday... yes
checking for index... yes
checking for insque... yes
checking for memchr... yes
checking for memcmp... yes
checking for memcpy... yes
checking for memmem... yes
checking for memmove... yes
checking for mempcpy... yes
checking for memset... yes
checking for mkstemps... yes
checking for putenv... yes
checking for random... yes
checking for rename... yes
checking for rindex... yes
checking for setenv... yes
checking for snprintf... yes
checking for sigsetmask... no
checking for stpcpy... yes
checking for stpncpy... yes
checking for strcasecmp... yes
checking for strchr... yes
checking for strdup... yes
checking for strncasecmp... yes
checking for strndup... yes
checking for strrchr... yes
checking for strstr... yes
checking for strtod... yes
checking for strtol... yes
checking for strtoul... yes
checking for strverscmp... no
checking for tmpnam... yes
checking for vasprintf... yes
checking for vfprintf... yes
checking for vprintf... yes
checking for vsnprintf... yes
checking for vsprintf... yes
checking for waitpid... yes
checking for setproctitle... no
checking whether alloca needs Cray hooks... no
checking stack direction for C alloca... -1
checking for vfork.h... no
checking for fork... yes
checking for vfork... yes
checking for working fork... yes
checking for working vfork... (cached) yes
checking for _doprnt... no
checking for sys_errlist... yes
checking for sys_nerr... yes
checking for sys_siglist... no
checking for external symbol _system_configuration... no
checking for __fsetlocking... no
checking for canonicalize_file_name... yes
checking for dup3... yes
checking for getrlimit... yes
checking for getrusage... yes
checking for getsysinfo... no
checking for gettimeofday... (cached) yes
checking for on_exit... yes
checking for psignal... no
checking for pstat_getdynamic... no
checking for pstat_getstatic... no
checking for realpath... yes
checking for setrlimit... yes
checking for sbrk... yes
checking for spawnve... yes
checking for spawnvpe... yes
checking for strerror... yes
checking for strsignal... yes
checking for sysconf... yes
checking for sysctl... no
checking for sysmp... no
checking for table... no
checking for times... yes
checking for wait3... yes
checking for wait4... yes
checking whether basename is declared... no
checking whether ffs is declared... yes
checking whether asprintf is declared... yes
checking whether vasprintf is declared... yes
checking whether snprintf is declared... yes
checking whether vsnprintf is declared... yes
checking whether calloc is declared... yes
checking whether getenv is declared... yes
checking whether getopt is declared... yes
checking whether malloc is declared... yes
checking whether realloc is declared... yes
checking whether sbrk is declared... yes
checking whether strverscmp is declared... no
checking whether canonicalize_file_name must be declared... no
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for getpagesize... (cached) yes
checking for working mmap... no
checking for working strncmp... yes
configure: updating cache ./config.cache
configure: creating ./config.status
config.status: creating Makefile
config.status: creating testsuite/Makefile
config.status: creating config.h
config.status: executing default commands
Configuring in ./intl
configure: creating cache ./config.cache
checking whether make sets $(MAKE)... yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether NLS is requested... no
checking for msgfmt... no
checking for gmsgfmt... :
checking for xgettext... no
checking for msgmerge... no
checking for i686-pc-cygwin-gcc... gcc
checking for C compiler default output file name... a.exe
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... .exe
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking build system type... i686-pc-cygwin
checking host system type... i686-pc-cygwin
checking for i686-pc-cygwin-ranlib... ranlib
checking for library containing strerror... none required
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for off_t... yes
checking for size_t... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for getpagesize... yes
checking for working mmap... no
checking whether we are using the GNU C Library 2.1 or newer... no
checking whether integer division by zero raises SIGFPE... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unsigned long long... yes
checking for inttypes.h... yes
checking whether the inttypes.h PRIxNN macros are broken... no
checking for ld used by GCC... /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe
checking if the linker (/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe) is GNU ld... yes
checking for shared library run path origin... done
checking argz.h usability... yes
checking argz.h presence... yes
checking for argz.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking nl_types.h usability... no
checking nl_types.h presence... no
checking for nl_types.h... no
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for unistd.h... (cached) yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking for feof_unlocked... no
checking for fgets_unlocked... no
checking for getc_unlocked... yes
checking for getcwd... yes
checking for getegid... yes
checking for geteuid... yes
checking for getgid... yes
checking for getuid... yes
checking for mempcpy... yes
checking for munmap... yes
checking for putenv... yes
checking for setenv... yes
checking for setlocale... yes
checking for stpcpy... yes
checking for strcasecmp... yes
checking for strdup... yes
checking for strtoul... yes
checking for tsearch... yes
checking for __argz_count... yes
checking for __argz_stringify... yes
checking for __argz_next... yes
checking for __fsetlocking... no
checking for iconv... yes
checking how to link with libiconv... -liconv
checking for iconv declaration... install-shextern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
checking for nl_langinfo and CODESET... yes
checking for LC_MESSAGES... yes
checking for bison... bison
checking version of bison... 2.4.2, ok
checking whether NLS is requested... no
checking whether to use NLS... no
checking for aclocal... aclocal
checking for autoconf... autoconf
checking for autoheader... autoheader
configure: updating cache ./config.cache
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.intl
config.status: creating config.h
config.status: executing default-1 commands
Configuring in ./bfd
configure: creating cache ./config.cache
checking build system type... i686-pc-cygwin
checking host system type... i686-pc-cygwin
checking target system type... x86_64-pc-linux-gnu
checking for i686-pc-cygwin-gcc... gcc
checking for C compiler default output file name... a.exe
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... .exe
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for library containing strerror... none required
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for i686-pc-cygwin-ar... ar
checking for i686-pc-cygwin-ranlib... ranlib
checking for i686-pc-cygwin-gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe
checking if the linker (/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... nm
checking the name lister (nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 8192
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe option to reload object files... -r
checking for i686-pc-cygwin-objdump... objdump
checking how to recognize dependent libraries... file_magic ^x86 archive import|^x86 DLL
checking for i686-pc-cygwin-ar... (cached) ar
checking for i686-pc-cygwin-strip... no
checking for strip... strip
checking for i686-pc-cygwin-ranlib... (cached) ranlib
checking command to parse nm output from gcc object... ok
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -DDLL_EXPORT -DPIC
checking if gcc PIC flag -DDLL_EXPORT -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe) supports shared libraries... yes
checking dynamic linker characteristics... Win32 ld.exe
checking how to hardcode library paths into programs... immediate
checking whether a program can dlopen itself... yes
checking whether a statically linked program can dlopen itself... yes
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
Setting warning flags = -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether to install libbfd... no
checking whether NLS is requested... no
checking whether NLS is requested... no
checking for msgfmt... no
checking for gmsgfmt... :
checking for xgettext... no
checking for msgmerge... no
checking size of long long... 8
checking size of void *... 4
checking size of long... 4
checking alloca.h usability... yes
checking alloca.h presence... yes
checking for alloca.h... yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking for stdlib.h... (cached) yes
checking time.h usability... yes
checking time.h presence... yes
checking for time.h... yes
checking for unistd.h... (cached) yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking sys/file.h usability... yes
checking sys/file.h presence... yes
checking for sys/file.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for sys/stat.h... (cached) yes
looking for a compliant stdint.h in stdint.h, checking for uintmax_t... yes
checking for uintptr_t... yes
checking for int_least32_t... yes
checking for int_fast32_t... yes
checking for uint64_t... yes
checking what to include in bfd_stdint.h... stdint.h (already complete)
checking whether time.h and sys/time.h may both be included... yes
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking whether string.h and strings.h may both be included... yes
checking for fcntl... yes
checking for getpagesize... yes
checking for setitimer... yes
checking for sysconf... yes
checking for fdopen... yes
checking for getuid... yes
checking for getgid... yes
checking for fileno... yes
checking for strtoull... yes
checking whether basename is declared... no
checking whether ftello is declared... yes
checking whether ftello64 is declared... no
checking whether fseeko is declared... yes
checking whether fseeko64 is declared... no
checking whether ffs is declared... yes
checking whether free is declared... yes
checking whether getenv is declared... yes
checking whether malloc is declared... yes
checking whether realloc is declared... yes
checking whether stpcpy is declared... yes
checking whether strstr is declared... yes
checking whether snprintf is declared... yes
checking whether vsnprintf is declared... yes
checking for library containing zlibVersion... no
checking linker --as-needed support... yes
checking for gcc version with buggy 64-bit support... no
checking for ftello... yes
checking for ftello64... no
checking for fseeko... yes
checking for fseeko64... no
checking for fopen64... no
checking size of off_t... 8
checking file_ptr type... BFD_HOST_64_BIT
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for getpagesize... (cached) yes
checking for working mmap... no
checking for madvise... yes
checking for mprotect... yes
configure: updating cache ./config.cache
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating bfd-in3.h
config.status: creating po/Makefile.in
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing default-1 commands
config.status: executing bfd_stdint.h commands
config.status: executing default commands
Configuring in ./opcodes
configure: creating cache ./config.cache
checking build system type... i686-pc-cygwin
checking host system type... i686-pc-cygwin
checking target system type... x86_64-pc-linux-gnu
checking for i686-pc-cygwin-gcc... gcc
checking for C compiler default output file name... a.exe
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... .exe
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for library containing strerror... none required
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for i686-pc-cygwin-gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for i686-pc-cygwin-ar... ar
checking for i686-pc-cygwin-ranlib... ranlib
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe
checking if the linker (/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... nm
checking the name lister (nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 8192
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe option to reload object files... -r
checking for i686-pc-cygwin-objdump... objdump
checking how to recognize dependent libraries... file_magic ^x86 archive import|^x86 DLL
checking for i686-pc-cygwin-ar... (cached) ar
checking for i686-pc-cygwin-strip... no
checking for strip... strip
checking for i686-pc-cygwin-ranlib... (cached) ranlib
checking command to parse nm output from gcc object... ok
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -DDLL_EXPORT -DPIC
checking if gcc PIC flag -DDLL_EXPORT -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe) supports shared libraries... yes
checking dynamic linker characteristics... Win32 ld.exe
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
Setting warning flags = -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror
checking whether to enable maintainer-specific portions of Makefiles... no
checking whether to install libbfd... no
checking whether NLS is requested... no
checking whether NLS is requested... no
checking for msgfmt... no
checking for gmsgfmt... :
checking for xgettext... no
checking for msgmerge... no
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking for stdlib.h... (cached) yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking whether basename is declared... no
checking whether stpcpy is declared... yes
checking linker --as-needed support... yes
configure: updating cache ./config.cache
configure: creating ./config.status
config.status: creating Makefile
config.status: creating po/Makefile.in
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing default-1 commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
Configuring in ./binutils
configure: creating cache ./config.cache
checking build system type... i686-pc-cygwin
checking host system type... i686-pc-cygwin
checking target system type... x86_64-pc-linux-gnu
checking for i686-pc-cygwin-gcc... gcc
checking for C compiler default output file name... a.exe
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... .exe
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for library containing strerror... none required
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for i686-pc-cygwin-gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe
checking if the linker (/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... nm
checking the name lister (nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 8192
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe option to reload object files... -r
checking for i686-pc-cygwin-objdump... objdump
checking how to recognize dependent libraries... file_magic ^x86 archive import|^x86 DLL
checking for i686-pc-cygwin-ar... ar
checking for i686-pc-cygwin-strip... no
checking for strip... strip
checking for i686-pc-cygwin-ranlib... ranlib
checking command to parse nm output from gcc object... ok
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -DDLL_EXPORT -DPIC
checking if gcc PIC flag -DDLL_EXPORT -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe) supports shared libraries... yes
checking dynamic linker characteristics... Win32 ld.exe
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
Setting warning flags = -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror
checking for bison... bison -y
checking for flex... flex
checking lex output file root... lex.yy
checking lex library... -lfl
checking whether yytext is a pointer... yes
checking whether NLS is requested... no
checking whether NLS is requested... no
checking for msgfmt... no
checking for gmsgfmt... :
checking for xgettext... no
checking for msgmerge... no
checking whether to enable maintainer-specific portions of Makefiles... no
checking for i686-pc-cygwin-ranlib... (cached) ranlib
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking sys/file.h usability... yes
checking sys/file.h presence... yes
checking for sys/file.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for sbrk... yes
checking for utimes... yes
checking for setmode... yes
checking for getc_unlocked... yes
checking for strcoll... yes
checking for mkstemp... yes
checking for mkdtemp... yes
checking for library containing frexp... none required
checking for time_t in time.h... yes
checking for time_t in sys/types.h... yes
checking for a known getopt prototype in unistd.h... yes
checking for utime.h... yes
checking whether fprintf is declared... yes
checking whether stpcpy is declared... yes
checking whether strstr is declared... yes
checking whether sbrk is declared... yes
checking whether getenv is declared... yes
checking whether environ is declared... yes
checking whether getc_unlocked is declared... yes
checking whether snprintf is declared... yes
checking whether vsnprintf is declared... yes
checking for library containing zlibVersion... no
checking iconv.h usability... yes
checking iconv.h presence... yes
checking for iconv.h... yes
checking for ld used by GCC... /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe
checking if the linker (/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe) is GNU ld... yes
checking for shared library run path origin... done
checking for iconv... yes
checking how to link with libiconv... -liconv
checking for iconv declaration... install-shextern size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
configure: updating cache ./config.cache
configure: creating ./config.status
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating po/Makefile.in
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing default-1 commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
Configuring in ./etc
configure: creating cache ./config.cache
checking for a BSD-compatible install... /usr/bin/install -c
configure: updating cache ./config.cache
configure: creating ./config.status
config.status: creating Makefile
Configuring in ./gas
configure: creating cache ./config.cache
checking build system type... i686-pc-cygwin
checking host system type... i686-pc-cygwin
checking target system type... x86_64-pc-linux-gnu
checking for i686-pc-cygwin-gcc... gcc
checking for C compiler default output file name... a.exe
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... .exe
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for library containing strerror... none required
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for i686-pc-cygwin-gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe
checking if the linker (/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... nm
checking the name lister (nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 8192
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe option to reload object files... -r
checking for i686-pc-cygwin-objdump... objdump
checking how to recognize dependent libraries... file_magic ^x86 archive import|^x86 DLL
checking for i686-pc-cygwin-ar... ar
checking for i686-pc-cygwin-strip... no
checking for strip... strip
checking for i686-pc-cygwin-ranlib... ranlib
checking command to parse nm output from gcc object... ok
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -DDLL_EXPORT -DPIC
checking if gcc PIC flag -DDLL_EXPORT -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe) supports shared libraries... yes
checking dynamic linker characteristics... Win32 ld.exe
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
Setting warning flags = -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror
checking whether byte ordering is bigendian... no
checking for bison... bison -y
checking for flex... flex
checking lex output file root... lex.yy
checking lex library... -lfl
checking whether yytext is a pointer... yes
checking whether NLS is requested... no
checking whether NLS is requested... no
checking for msgfmt... no
checking for gmsgfmt... :
checking for xgettext... no
checking for msgmerge... no
checking whether to enable maintainer-specific portions of Makefiles... no
checking for string.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for memory.h... (cached) yes
checking for strings.h... (cached) yes
checking for unistd.h... (cached) yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking for sys/types.h... (cached) yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking time.h usability... yes
checking time.h presence... yes
checking for time.h... yes
checking for sys/stat.h... (cached) yes
checking whether compiling a cross-assembler... yes
checking for working alloca.h... yes
checking for alloca... yes
checking for inline... inline
checking for unlink... yes
checking for sbrk... yes
checking for working assert macro... yes
checking whether declaration is required for errno... no
checking for a known getopt prototype in unistd.h... yes
checking whether declaration is required for environ... no
checking whether declaration is required for ffs... no
checking whether declaration is required for free... no
checking whether declaration is required for malloc... no
checking whether declaration is required for sbrk... no
checking whether declaration is required for strstr... no
checking whether mempcpy is declared... yes
checking whether vsnprintf is declared... yes
checking for library containing zlibVersion... no
checking for struct tm.tm_gmtoff in time.h... no
checking for struct stat.st_mtim.tv_sec in sys/stat.h... yes
checking for struct stat.st_mtim.tv_nsec in sys/stat.h... yes
configure: updating cache ./config.cache
configure: creating ./config.status
config.status: creating .gdbinit
config.status: creating Makefile
config.status: creating doc/Makefile
config.status: creating po/Makefile.in
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing default-1 commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
config.status: executing default commands
Configuring in ./gprof
configure: creating cache ./config.cache
checking build system type... i686-pc-cygwin
checking host system type... i686-pc-cygwin
checking target system type... x86_64-pc-linux-gnu
checking for i686-pc-cygwin-gcc... gcc
checking for C compiler default output file name... a.exe
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... .exe
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for library containing strerror... none required
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking for i686-pc-cygwin-gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe
checking if the linker (/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... nm
checking the name lister (nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 8192
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe option to reload object files... -r
checking for i686-pc-cygwin-objdump... objdump
checking how to recognize dependent libraries... file_magic ^x86 archive import|^x86 DLL
checking for i686-pc-cygwin-ar... ar
checking for i686-pc-cygwin-strip... no
checking for strip... strip
checking for i686-pc-cygwin-ranlib... ranlib
checking command to parse nm output from gcc object... ok
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -DDLL_EXPORT -DPIC
checking if gcc PIC flag -DDLL_EXPORT -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe) supports shared libraries... yes
checking dynamic linker characteristics... Win32 ld.exe
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking for setmode... yes
checking whether NLS is requested... no
checking whether NLS is requested... no
checking for msgfmt... no
checking for gmsgfmt... :
checking for xgettext... no
checking for msgmerge... no
checking whether to enable maintainer-specific portions of Makefiles... no
checking sys/gmon_out.h usability... no
checking sys/gmon_out.h presence... no
checking for sys/gmon_out.h... no
checking for a known getopt prototype in unistd.h... yes
checking for library containing fabs... none required
Setting warning flags = -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror
configure: updating cache ./config.cache
configure: creating ./config.status
config.status: creating Makefile
config.status: creating po/Makefile.in
config.status: creating gconfig.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing default-1 commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
Configuring in ./ld
configure: creating cache ./config.cache
checking build system type... i686-pc-cygwin
checking host system type... i686-pc-cygwin
checking target system type... x86_64-pc-linux-gnu
checking for i686-pc-cygwin-gcc... gcc
checking for C compiler default output file name... a.exe
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... .exe
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for library containing strerror... none required
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether to enable maintainer-specific portions of Makefiles... no
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
Setting warning flags = -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Werror
checking for i686-pc-cygwin-gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether we are using the GNU C++ compiler... no
checking whether CC accepts -g... no
checking dependency style of CC... gcc3
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe
checking if the linker (/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... nm
checking the name lister (nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 8192
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking for /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe option to reload object files... -r
checking for i686-pc-cygwin-objdump... objdump
checking how to recognize dependent libraries... file_magic ^x86 archive import|^x86 DLL
checking for i686-pc-cygwin-ar... ar
checking for i686-pc-cygwin-strip... no
checking for strip... strip
checking for i686-pc-cygwin-ranlib... ranlib
checking command to parse nm output from gcc object... ok
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -DDLL_EXPORT -DPIC
checking if gcc PIC flag -DDLL_EXPORT -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../../i686-pc-cygwin/bin/ld.exe) supports shared libraries... yes
checking dynamic linker characteristics... Win32 ld.exe
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... /lib/cpp
configure: error: in `/usr/src/binutils-2.21.53-2/ld':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details.
Makefile:6968: recipe for target `configure-ld' failed
make: *** [configure-ld] Error 1

64bit OS 만들기 시작하자마자 난관에 봉착...........


cygwin setup가서 g++ 컴파일러를 설치해주니 잘 진행된다

http://www.linuxquestions.org/questions/linux-software-2/configure-error-c-preprocessor-lib-cpp-fails-sanity-check-124961/

멍청한놈!ㅠㅠㅠ

Posted by 쵸코케키
~/Desktop/starvation.c.html
#include <stdio.h>
#include <string.h>
#include <pthread.h>

void* thread_main1(void*);
void* thread_main2(void*);

pthread_mutex_t MUTEX = PTHREAD_MUTEX_INITIALIZER;

char buf[255];
int length;

int main()
{

	pthread_t id[5];
	pthread_create(&id[0],NULL,thread_main1,NULL);
	pthread_create(&id[1], NULL, thread_main2, NULL);


	pthread_join(id[1], NULL);
	pthread_join(id[0], NULL);




return 0;

}

void* thread_main1(void* arg)
{
int i;
for(i=10; i>0 ; i--)
{
	pthread_mutex_lock(&MUTEX);
	printf("thread#1 Locked %d  %s\n",i, buf);
	pthread_mutex_unlock(&MUTEX);
	sleep(1);
}
}

void* thread_main2(void* arg)
{

int j;
for(j=10; j>0; j--)
{
	pthread_mutex_lock(&MUTEX);
	printf("thread#2 Lock %d\n",j);
	length = scanf("%[^\n]%*c",buf);
	pthread_mutex_unlock(&MUTEX);
	sleep(1);
}
}
배운거랑 다르게 막상 플그램을 만들다보면 전혀 눈치를 못 챈다

일부로 buf 변수라는 critical section을 만들고 출력과 입력이 동일한 변수를 사용하게 만들었다
그리고 서로 자원을 가지고 경쟁하도록 했으며 자원을 사용할 때는 lock을 걸어서 이상이 없도록 했다
상식적으로 scanf를 통해서 입력 받는 i/o타임이 buf에서 읽어서 출력하는 부분보다 클테니까
thread_main2는 한 두번 정도 실행되고 thread_main1이 주욱 실행 되거나
너한번 나한번, 기타 등등 뭐 그런 형식으로 진행 될 것 같았다
여기 까지는 아무런 문제가 없어보인다
그런데 실제로 프로그램을 돌려보니 예상 했던 것과는 결과가 다르게 나왔다

thread_main2만 줄창 실행되더라
즉 thread_main2가 락을 풀자마자 다시 락을 또 걸고 자원을 독점해버리는 것이었다
으...스케쥴 정책이 도대체 어떻게 되어있길래 이런 결과가 나오는건지

그런데 더 웃긴건 집에서 해보니 정상적으로 퐁당퐁당으로 되더라
애초에 race condition을 가정하고 만들긴 했는데 컴퓨터에 따라서 독점이냐 아니면 적당히냐가 완전히 달랐다

진짜 큰 교훈이 되었다 테스트 환경 c2d 5x00 vmplayer ubuntu 10.04 LTS, i3 2100 ubuntu 11.10


'devel > man & example' 카테고리의 다른 글

strstr  (0) 2012.01.28
arm inline assembly  (0) 2011.12.24
scanf에서 fflush(stdin) 사용 안하고 \n 파싱해서 없애기  (2) 2011.11.27
function pointer  (0) 2009.11.24
sprintf int to ascii  (0) 2009.11.08
Posted by 쵸코케키

http://stackoverflow.com/questions/6083045/scanf-n-skips-the-2nd-input-but-n-does-not-why
http://in.answers.yahoo.com/question/index?qid=20110318044732AAaBz8P

위 두 링크에서 배웠습니다


scanf로 입력 받을 때 매번 \n을 fflush(stdin)으로 빼버리는 것도 뭔가 좀 걸리적 거리기도 하고
성능상 불 이익이 있을 것 같은 느낌이 들어서 좀 찾아봤습니다

재미있는 좋은 팁을 얻었네요

1. scanf의 포맷팅을 미리 char*형으로 선언해놓기
2. *지시자
3. [^]xor 용법


char* fmt = "%[^\n]%*c";

char str1, str2;
scanf(fmt, &str1);
scanf(fmt, &str2);


해설
1. 키보드로 입력한다
2. stdin이라는 일종의 버퍼(메모리)로 값이 들어간다
3. scanf 함수가 이제 그녀석을 차례로 순서대로 읽기 시작한다
쉽게 이해를 해보자면 stdin은 일종의 배열로 scanf는 pointer로 루프문 탐색을 시작한다고 보면 된다

4. []는 그 안에 있는 것만 받고 싶습니다 하는 그런거라 보면 된다

5. ^는 xor연산이다
다르면 1이고 같으면 무조건 0이다
그런고로 \n과 같은 값이면(\n도 일종의 숫자값이다) 0을 넘기고
다르면 1을 넘긴다 즉 2진 연산을 통해서 \n만 걸러낸다고 보면 된다

즉 %[^\n] 는 scanf가 stdin에 입력된 글자 한자 한자를 살펴보면서 \n인가 체크 하고
\n이 아닌놈만 읽어낸다는 의미이다


6. \n을 제외한 나머지 글자들은 모두 읽히고 \n은 그대로 stdin에 남아있게 된다

7. *는 걍 포인터 버려라는 의미이다
즉 scanf는 stdin에 혼자 남아있는 \n을 읽긴 읽는데 *때문에 걍 버린다
8. 끝
그런고로 fflush(stdin)을 사용할 필요 없이 그냥 *제한자로 간단히 처리가 되어버렸다

'devel > man & example' 카테고리의 다른 글

arm inline assembly  (0) 2011.12.24
thread starvation  (0) 2011.12.09
function pointer  (0) 2009.11.24
sprintf int to ascii  (0) 2009.11.08
C++ , C File OUTPUT e.g.  (0) 2008.12.02
Posted by 쵸코케키

2011. 9. 8. 16:36 devel/etc

HTML STYLE COLOR

Posted by 쵸코케키

책을 읽다 보니 stateless라는 이야기가 나왔다
분명 예전에는 명확히 알고 있던 내용이었는데 설명을 해보려니 가물가물 해서 다시 정리해 보았다

HTTP - Stateless Protocol
Stateless?
def.
In computing, a stateless protocol is a communications protocol that treats each request as an independent transaction that is unrelated to any previous request so that the communication consists of independent pairs of requests and responses. A stateless protocol does not require the server to retain session information or status about each communications partner for the duration of multiple requests.

Advantages and Disadvantages
The stateless design simplifies the server design because there is no need to dynamically allocate storage to deal with conversations in progress. If a client dies in mid-transaction, no part of the system needs to be responsible for cleaning the present state of the server.

A disadvantage of statelessness is that it may be necessary to include additional information in every request, and this extra information will need to be interpreted by the server.


e.g.
An example of a stateless protocol is HTTP.[1] The protocol provides no means of storing a user's data between requests. As a work-around, HTTP Servers implement various session management methods,[2] typically utilizing a unique identifier in a cookie or parameter that allows the server to track requests originating from the same client.

Contrast this with a traditional FTP server that conducts an interactive session with the user. During the session, a user is provided a means to be authenticated and set various variables (working directory, transfer mode), all stored on the server as part of the user's state.

정말 간결하다 역시 위키쨔응...고맙습니다


state를 사용한다면 client와 server 사이의 state 동기화를 검증하는 복잡한 메커니즘이 요구됨
물론 state는 필요함 하지만 http의 용도를 생각해 볼 때 프로토콜단에서 해줄 필요는 없다 이런 내용인듯


출처 :
http://en.wikipedia.org/wiki/Stateless_protocol
http://www.ibm.com/developerworks/kr/library/wa-state/index.html    - 한글 그런데 번역투라 읽기 힘듬
http://www.ibm.com/developerworks/web/library/wa-state/   - 영문

Posted by 쵸코케키

2011. 5. 4. 19:19 devel/개념

TCP vs UDP

갑자기 궁금했다
난데없이 말이다

그래서 찾아보니 바로 1페이지에 명확하게 나오더라
http://www.diffen.com/difference/TCP_vs_UDP


으메 이정도면 감동이다
Posted by 쵸코케키

2010. 6. 22. 01:14 devel/etc

c++ int to string

#include <iostream>
#include <sstream>
using namespace std;

 


int main(){

int i = 5;
std::string s;
std::stringstream out;
out << i;
s = out.str();
cout << s;


 return 0;
}

'devel > etc' 카테고리의 다른 글

64비트 멀티코어 OS 원리와 구조  (0) 2011.12.10
HTML STYLE COLOR  (0) 2011.09.08
Visual Studio 2005, 2008 에서 OPEN GL 사용하기  (0) 2010.05.16
Makefile 쉬운 예제  (1) 2009.10.17
윤드림훃의 주옥같은 글  (0) 2009.10.17
Posted by 쵸코케키



Visual Studio 2005
http://mtrockcs.wordpress.com/2007/07/14/running-opengl-on-visual-studio-2005/



Visual Studio 2008
http://tempvariable.blogspot.com/2008/02/installing-freeglut-on-visual-studio.html



씹새들...
일부로 OPEN GL 쓰기 짜증나게 하려고 이런 짓을 한다


Visual Studio 2010에서도 과연 바뀌었을까?
ㄲㄲㄲㄲㄲ

'devel > etc' 카테고리의 다른 글

HTML STYLE COLOR  (0) 2011.09.08
c++ int to string  (0) 2010.06.22
Makefile 쉬운 예제  (1) 2009.10.17
윤드림훃의 주옥같은 글  (0) 2009.10.17
Debug Mode - Enable  (0) 2009.01.02
Posted by 쵸코케키

Function Pointer
system programming 과목 시간에 thread programming을 했음에도 불구하고
function pointer가 필수적인 부분이 거의 없었다 덕분에 참 익숙치가 못하다


Def
void (*pfunc)(void*)
()연산자의 사용이 가능함 덕분에 함수를 변수처럼 사용이 가능함


e.g.
int t1(char* str){
strcat(str,"temp");
return (strlen(str));
}

 

int (*pFunc)(const char* str); //Declare function pointer variable

int main(){
char buf[500];
strcpy(buf,"xxxx");
pFunc = t1;
printf("%d",pFunc(buf));
}

응용으로 pFunc만 실행해도 다른 함수 실행이 가능

typedef int (*pFunc)(void*, void*);
이렇게 선언을 하면 pFunc variable은 이제 하나의 독립된 변수형으로 동작하게 되는 것임

이를테면 pFunc newFuncPtrVariable;
int temp = newFuncPtrVariable("void* argument1", "void* argument2");
이런 구현이 가능

- 참고 redwiki 


위의 별 볼일 없는 내용보다 훨씬 좋은 정보가 있는 링크

http://www.newty.de/fpt/fpt.html

'devel > man & example' 카테고리의 다른 글

thread starvation  (0) 2011.12.09
scanf에서 fflush(stdin) 사용 안하고 \n 파싱해서 없애기  (2) 2011.11.27
sprintf int to ascii  (0) 2009.11.08
C++ , C File OUTPUT e.g.  (0) 2008.12.02
String Parsing  (0) 2008.05.25
Posted by 쵸코케키

블로그 이미지
chocokeki
쵸코케키

공지사항

Yesterday
Today
Total

달력

 « |  » 2024.5
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

최근에 올라온 글

최근에 달린 댓글

글 보관함