1 / 17

Linux/UNIX Programming APUE (Introduction) 문양세 강원대학교 IT 대학 컴퓨터과학전공

Linux/UNIX Programming APUE (Introduction) 문양세 강원대학교 IT 대학 컴퓨터과학전공. APUE 강의 목적. APUE (Introduction). Linux/Unix 시스템 프로그래밍 파일 , 프로세스 , 시그널 (signal), 네트워크 프로그래밍 Linux/Unix 시스템의 체계적 이해 시스템 프로그래밍 능력 향상. APUE 강의 동기. APUE (Introduction). Linux/Unix 는 인기 있는 운영체제

vita
Télécharger la présentation

Linux/UNIX Programming APUE (Introduction) 문양세 강원대학교 IT 대학 컴퓨터과학전공

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. Linux/UNIX Programming APUE (Introduction) 문양세 강원대학교 IT대학 컴퓨터과학전공

  2. APUE 강의 목적 APUE (Introduction) • Linux/Unix 시스템 프로그래밍 • 파일, 프로세스, 시그널(signal), 네트워크 프로그래밍 • Linux/Unix 시스템의 체계적 이해 • 시스템 프로그래밍 능력 향상

  3. APUE 강의 동기 APUE (Introduction) • Linux/Unix는 인기 있는 운영체제 • 서버 시스템(웹 서버, 데이터베이스 서버) • 공학 및 상업용으로 응용되고 있음 • 연구 개발 용으로도 많이 사용됨 • 최근 임베디드 시스템,모바일 디바이스, 클라우드 시스템에 많이 활용되고 있음 • 시스템 프로그래밍 • OS 자원을 이용한 프로그래밍 • Linux/Unix 시스템 호출 사용 • 파일, 프로세스, IPC, 네트워킹, … • DBMS, compiler, groupware, debugger, …

  4. Linux/Unix 시스템 구조 APUE (Introduction) • Hardware • CPU, Memory, Disk, Peripherals • Kernel • Kernel • Process Management • File Management • Memory Management • Device management • System Call • The programmer's functional interface to the Linux/Unix kernel • Commands, Utilities, Application programs • Kernel services using library routines or system calls

  5. 시스템 호출 (System Calls) (1/2) APUE (Introduction) Process Process Process System call interface File Management IPC Process Management

  6. 시스템 호출 (System Calls) (2/2) APUE (Introduction) Application programs talk to the operating systems via system calls. The programmer's functional interface to the Linux/UNIX kernel.

  7. User Mode vs. Kernal APUE (Introduction) Kernel User process Address of kernel close() Address of kernel open() result=open(“file.txt”, O_RDONLY); Address of kernel write() User code open(char *name, int mode) { <Place parameters in registers> <Execute trap instruction, switching to kernel code > <Return result of system call> } kernel code for open() { <Manipulate kernel data> . . . <Return to user code> } Kernel system call code C runtime library

  8. System Calls & Library Functions (1/2) APUE (Introduction) • System Calls • Well defined entry points directly into the kernel • Documented in the Linux/Unix man pages • Look like C functions which can be called from a user's program– just need to include the appropriate header • 예) read(), write() • Library Functions • The library function is often more elaborate than the system call, and usually invokes the system call (System call 보다는 좀 더 사용하기 쉽고 편리하게 제작) • 예) fprintf(), fscanf()

  9. application code user process C library functions system calls kernel kernel hardware (hard disk…) System Calls & Library Functions (2/2) APUE (Introduction)

  10. C I/O Library Functions APUE (Introduction) • 표준 입력 함수 (standard input function) • scanf(), getchar() • 표준 출력 함수 (standard output function) • printf(), putchar() • 표준 파일 입력 함수 • fscanf(), fgets(), fgetc() • 표준 파일 출력 함수 • fprintf(), fputs(), fputc()

  11. 파일 입출력 (1/2) APUE (Introduction) • 파일 입출력 과정 • 파일 열기, 읽기/쓰기, 파일 닫기 • 파일 열기: fopen #include <stdio.h>   FILE    *fp; fp=fopen("파일 이름", "입출력방식"); • 입출력 방식 • r: 읽기 전용 • w: 쓰기 전용 • a: 추가(append) 수록 • r+: 읽기쓰기겸용 • w+: 쓰기읽기겸용 • a+: 읽기추가겸용

  12. 파일 입출력 (2/2) APUE (Introduction) • 파일 입력 함수 • fscanf(), fgets(), fgetc() • 열린 파일에서 내용을 읽어 들이는 함수 • 파일 출력 함수 • fprintf(), fputs(), fputc() • 열린 파일에 내용을 기록하는 함수 • 파일 닫기 • fclose()

  13. 파일 출력 예제 (fgets.c) (1/2) APUE (Introduction)

  14. 파일 출력 예제 (fgets.c) (2/2) APUE (Introduction)

  15. 파일 입출력 예제 (fcopy.c) (1/2) APUE (Introduction)

  16. 파일 입출력 예제 (fcopy.c) (2/2) APUE (Introduction)

  17. We already knew “vi”. We may use “cc” or “gcc” You should learn either “gdb” or “dbx”. We already learned about “make” and “Makefile”. 시스템 프로그래밍 준비 APUE (Introduction) 에디터 컴파일러 디버거 make

More Related