Microsoft PowerPoint APUE(Intro).ppt

Similar documents
Microsoft PowerPoint - chap1 [호환 모드]

chap7.key

Microsoft PowerPoint - chap4 [호환 모드]

<4D F736F F F696E74202D2034C5D8BDBAC6AEC6C4C0CFC0D4C3E2B7C2312E505054>

歯9장.PDF

PowerPoint 프레젠테이션

Microsoft PowerPoint - chap13-입출력라이브러리.pptx

Microsoft PowerPoint - 제11강 파일 처리

PowerPoint 프레젠테이션


6주차.key

PowerPoint 프레젠테이션

금오공대 컴퓨터공학전공 강의자료

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx

슬라이드 1

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D>

Microsoft PowerPoint 웹 연동 기술.pptx

Microsoft PowerPoint - chap11-1.ppt [호환 모드]

Microsoft PowerPoint - [2009] 02.pptx

<C0CCBCBCBFB52DC1A4B4EBBFF82DBCAEBBE7B3EDB9AE2D D382E687770>

DE1-SoC Board

Microsoft PowerPoint Predicates and Quantifiers.ppt

PowerPoint Template

untitled

강의10

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과

슬라이드 1

PCServerMgmt7

C 언어 프로그래밊 과제 풀이

Microsoft PowerPoint UNIX Shell.ppt

제1장 Unix란 무엇인가?


Microsoft PowerPoint - Chap14_FileAccess.pptx

13 주차문자열의표현과입출력

C Programming

11장 포인터

Microsoft PowerPoint - chap11.ppt [호환 모드]

10.

PowerPoint 프레젠테이션

0. 표지에이름과학번을적으시오. (6) 1. 변수 x, y 가 integer type 이라가정하고다음빈칸에 x 와 y 의계산결과값을적으시오. (5) x = (3 + 7) * 6; x = 60 x = (12 + 6) / 2 * 3; x = 27 x = 3 * (8 / 4

MPLAB C18 C

Microsoft PowerPoint - 09_(C_Programming)_(Korean)_File_Processing

제1장 Unix란 무엇인가?

PowerPoint 프레젠테이션

GNU/Linux 1, GNU/Linux MS-DOS LOADLIN DOS-MBR LILO DOS-MBR LILO... 6

제12장 파일 입출력

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202839C1D6C2F7207E203135C1D6C2F >

설계란 무엇인가?

Microsoft PowerPoint - 10_C_Language_Text_Files

No Slide Title

PowerPoint 프레젠테이션

Microsoft PowerPoint - Lesson13.pptx

BMP 파일 처리

PowerPoint 프레젠테이션

제1장 Unix란 무엇인가?

윤성우의 열혈 TCP/IP 소켓 프로그래밊

<4D F736F F F696E74202D D20B9AEC0DABFAD2C20BDBAC6AEB8B2B0FA20C6C4C0CF20C0D4C3E2B7C2>

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf("hihi\n"); } warning: conflicting types for functiona

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C D616E2E637070>

hlogin2

11장 포인터

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 -

KEY 디바이스 드라이버

본 강의에 들어가기 전

Microsoft PowerPoint - ch09_파이프 [호환 모드]

2009년 상반기 사업계획

Sena Technologies, Inc. HelloDevice Super 1.1.0

untitled

PowerPoint 프레젠테이션

1217 WebTrafMon II

슬라이드 1

T100MD+

(72) 발명자 이동희 서울 동작구 여의대방로44길 10, 101동 802호 (대 방동, 대림아파트) 노삼혁 서울 중구 정동길 21-31, B동 404호 (정동, 정동상 림원) 이 발명을 지원한 국가연구개발사업 과제고유번호 부처명 교육과학기술부

PowerPoint 프레젠테이션

컴파일러

2013년 1회 정보처리산업기사 실기.hwp

Chapter_06

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074>

Microsoft PowerPoint APUE(File InO).pptx

Solaris Express Developer Edition

본문01

금오공대 컴퓨터공학전공 강의자료

Microsoft PowerPoint - Lecture 4-1 Linux File Environment.ppt [호환 모드]

untitled

Microsoft PowerPoint - C프로그래밍-chap15.ppt [호환 모드]

Microsoft PowerPoint - 27.pptx

PowerPoint 프레젠테이션

Microsoft PowerPoint - chap-03.pptx

2. GCC Assembler와 AVR Assembler의차이 A. GCC Assembler 를사용하는경우 i. Assembly Language Program은.S Extension 을갖는다. ii. C Language Program은.c Extension 을갖는다.

윤성우의 열혈 TCP/IP 소켓 프로그래밊

OCW_C언어 기초

<4D F736F F F696E74202D20C1A632C0E520C7C1B7CEB1D7B7A5B0B3B9DFB0FAC1A4>

Microsoft PowerPoint 세션.ppt

Microsoft PowerPoint - Lesson2.pptx

C 프로그램의 기본

슬라이드 제목 없음

6.24-9년 6월

untitled

PowerPoint 프레젠테이션

Microsoft PowerPoint - polling.pptx

Transcription:

컴퓨터특강 () [Ch. 1 & Ch. 2] 2006 년봄학기 문양세강원대학교컴퓨터과학과 APUE 강의목적 UNIX 시스템프로그래밍 file, process, signal, network programming UNIX 시스템의체계적이해 시스템프로그래밍능력향상 Page 2 1

APUE 강의동기 UNIX 는인기있는운영체제 서버시스템 ( 웹서버, 데이터베이스서버 ) 공학및상업용으로응용되고있음 연구개발용으로도많이사용됨 ( 특히, Sun의경우학교 ( 미국등 ) 에서애용함 ) Linux: PC를위한무료 OS 시스템프로그래밍 OS 지원을이용한프로그래밍 Unix 시스템호출사용 file, process, IPC, networking, DBMS, compiler, groupware, debugger, Page 3 UNIX 의특징 단순하고이식성이좋다 MIT MULTICS에반대해서 C 언어로작성 (Portable한특징을가짐 ) 다중사용자다중프로세스 (multi user, multi process) 운영체제 여러사용자가동시에사용할수있다. 여러프로그램이동시에실행될수있다. 관리자인 Super-User가있다. 쉘프로그래밍 (Shell Programming) 유틸리티프로그램과파이프라인메커니즘이용 ( 예 : $ who sort) MS-DOS의 batch file과비슷하다. Page 4 2

UNIX 시스템구조 Hardware CPU, Memory, Disk, Peripherals Kernel Kernel Process Management File Management Memory Management Device management System Call The programmer's functional interface to the UNIX kernel Commands, Utilities, Application programs Kernel services using library routines or system calls Hardware UNIX Kernel System call Commands, Utilities, Applications Page 5 시스템호출 (System Calls) (1/2) Process Process Process System call interface File Management IPC Process Management Page 6 3

시스템호출 (System Calls) (2/2) Application programs talk to the operating systems via system calls. The programmer's functional interface to the UNIX kernel. User Process fgetc(), fscanf() User space Kernel space System call Library trap routine call dispatch Kernel read() rdwr() readi(), writei() Page 7 User Mode vs. Kernal User process result=open( file.txt, O_RDONLY); User code Kernel Address of kernel close() Address of kernel open() Address of kernel write() open(char *name, int mode) { <Place parameters in registers> <Execute trap instruction, switching to kernel code > <Return result of system call> C runtime library kernel code for open() { <Manipulate kernel data>... <Return to user code> Kernel system call code Page 8 4

System Calls & Library Functions (1/2) System Calls Well defined entry points directly into the kernel Documented in section 2 of the UNIX man pages (/usr/man/man2) 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() Page 9 System Calls & Library Functions (2/2) application code user process C library functions system calls kernel kernel hardware (hard disk ) Page 10 5

C I/O Library Functions 표준입력함수 (standard input function) scanf(), getchar() 표준출력함수 (standard output function) printf(), putchar() 표준파일입력함수 fscanf(), fgets(), fgetc() 표준파일출력함수 fprintf(), fputs(), fputc() Page 11 파일입출력 (1/2) 파일입출력과정 파일열기, 읽기 / 쓰기, 파일닫기 파일열기 : fopen #include <stdio.h> FILE *fp; fp=fopen(" 파일이름 ", " 입출력방식 "); 입출력방식 r: 읽기전용 w: 쓰기전용 a: 추가 (append) 수록 r+: 읽기쓰기겸용 w+: 쓰기읽기겸용 a+: 읽기추가겸용 Page 12 6

파일입출력 (2/2) 파일입력함수 fscanf(), fgets(), fgetc() 열린파일에서내용을읽어들이는함수 파일출력함수 fprintf(), fputs(), fputc() 열린파일에내용을기록하는함수 파일닫기 fclose() Page 13 파일출력예제 (fgets.c) // 키보드에서문자를입력받아파일에출력하는예제 #include <stdio.h> main() { FILE *fp; int c; fp = fopen(./test.txt","w"); // 쓰기전용으로 c = getchar(); // 키보드로부터입력받은문자의 ASCII 코드반환 while(c!=. ) { //. 가아니면. fputc(c, fp); //fp가가리키는파일에문자 c저장 c = getchar(); // 키보드로부터문자를읽어 c에저장 fclose(fp); Page 14 7

파일입출력예제 (fcopy.c) // 파일 (fgets.c) 에서읽어들여파일 (test.txt) 에출력하는함수 #include <stdio.h> void main() { FILE *fp; FILE *fp_write; char buffer[100];// 데이터를임시로저장하기위한배열 fp=fopen("fgets.c","r"); fp_write=fopen("test.txt","w"); if(fp==null) printf("file not found"); /* 최대길이가 100인문자열을 fp가가리키는파일에서읽어서 buffer에저장후 fp_write가가리키는파일에 buffer 내용기록 */ while(fgets(buffer, 100, fp)!=null) fputs(buffer, fp_write); fclose(fp); Page 15 시스템프로그래밍준비 에디터 We already knew vi. 컴파일러 We can use gcc. Thanks to 양기운 / 박기덕 디버거 You should learn either gdb or dbx. make We already learned about make and Makefile. Page 16 8