1 / 7

How “ printf ()” is working?

How “ printf ()” is working?. Jungsik Yoon NML. GIST 2009. 11. 25. 디바이 스 드라이버. 응용프로그 램. 응용프로그 램. 디바이스 드라이버. 인터페이스. 하드웨어. 디바이스 드라이버. 하드웨어. 초기 운영 체제. 인터페이스가 추가된 OS 구조. 리눅스 디바이스 드라이버 구성. 응용프로그 램. User Space. 시스템 호출 인터페이 스. Kernel Space. 가상 파일 시스템 (VFS). 버퍼 캐시. 네트워크 시스템.

Download Presentation

How “ printf ()” is working?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. How “printf()” is working? Jungsik Yoon NML. GIST 2009. 11. 25

  2. 디바이스 드라이버 응용프로그램 응용프로그램 디바이스 드라이버 인터페이스 하드웨어 디바이스 드라이버 하드웨어 초기 운영 체제 인터페이스가 추가된 OS 구조

  3. 리눅스 디바이스 드라이버 구성 응용프로그램 User Space 시스템 호출 인터페이스 Kernel Space 가상 파일 시스템 (VFS) 버퍼 캐시 네트워크 시스템 문자 디바이스 드라이버 블록 디바이스 드라이버 네트워크 디바이스 드라이버 Hardware 하드웨어

  4. 함수의 호출 관계 응용 프로그램 시스템 호출 가상 파일 시스템 <linux/fs.h> 디바이스 드라이버 sys_open( ) owner open close read write ioctl lock dev_open( ) open( ) close( ) read( ) write( ) sys_close( ) dev_close( ) sys_read( ) dev_read( ) sys_write( ) dev_write( )

  5. 응용프로그램  시스템 콜 인터페이스 • C 코드 #include<unistd.h> int main (void) { write(1, “Hello, world\n”, 14); return 0; } 로우레벨 출력 함수인 sys_write( ) 호출 표준 출력(stdout) 문자열 길이 • write() 함수는 저수준 출력함수이므로 printf()에 비해서 사용하기 불편하지만, 기능이 단순해서생성되는 코드가 단순해서 이해하기 쉬움 • 첫 번째 인자는 출력할 핸들을 의미0 – 표준 입력 (stdin)1 - 표준 출력 (stdout)2 – 표준 에러 (stderr) • write( )는 EAX, EBX, ECX, EDX 등의 레지스터에 각 인자를 차례대로 저장한뒤, 시스템 콜을 위해 인터럽트 0x80을 발생 시킴.

  6. con’t • EAX에 지정된 값으로 시스템 콜 인터페이스가 호출 되며, 이 경우 sys_write( ) 시스템 호출 번호인 4가 EAX에 저장. • system_call( )함수는 sys_call_table을 참조해서4번째에 해당하는 sys_write( )를 호출.* sys_call_table은 2.6 커널의 경우, arch/i386/kernel/syscall_table.S에 지정되어 있음.

  7. 응용프로그램 시스템 호출 가상 파일 시스템 (VFS) 버퍼 캐시 네트워크 시스템 문자 디바이스 드라이버 블록 디바이스 드라이버 네트워크 디바이스 드라이버 하드웨어

More Related