Presentation is loading. Please wait.

Presentation is loading. Please wait.

고급 시스템 프로그래밍 제1장 소개 창병모 숙명여대 컴퓨터과학과.

Similar presentations


Presentation on theme: "고급 시스템 프로그래밍 제1장 소개 창병모 숙명여대 컴퓨터과학과."— Presentation transcript:

1 고급 시스템 프로그래밍 제1장 소개 창병모 숙명여대 컴퓨터과학과

2 강의 목적 시스템 프로그래밍 Unix 시스템의 체계적 이해 고급 시스템 프로그래밍 능력 향상
file, process, network programming Unix 시스템의 체계적 이해 고급 시스템 프로그래밍 능력 향상

3 동기 시스템 프로그래밍 OS 지원을 이용한 프로그래밍 Unix 시스템 호출 사용 파일 관리 소프트웨어 네트워크 관련 소프트웨어
file, process, IPC, networking, … 파일 관리 소프트웨어 네트워크 관련 소프트웨어 DBMS, compiler, groupware, debugger, …

4 Unix 운영체제 1970년대 벨 연구소의 켄 톰슨, 데니스 리치가 개발 다양한 버전 특징 유닉스 시스템의 개념
오늘날의 유닉스 시스템은 AT&T를 비롯한 여러 회사들과 버클리대학(UCB) 등 비영리 단체들이 개발한 다양한 버전 특징 다양한 시스템 사이에서 서로 이식할 수 있음 다중 사용자 및 다중 작업을 지원 유닉스 시스템의 개념 일반 텍스트 파일 명령줄 인터프리터 계층적인 파일 시스템 장치 및 특정한 형식의 프로세스 간 통신을 파일로 취급 등.

5 Unix 족보

6 유닉스 종류와 특성 Unix 1970년에 AT&T의 벨 연구소에서 개발한 운영체제로 처음에는 중형 컴퓨터에 사용하도록 고안
여러 가지 유틸리티가 공개되면서 일반 사용자들에 확산 특징 다중 사용자, 다중 작업 처리 가능 프로그램 개발이 쉬운 운영체제 대부분 통신 서비스 프로그램은 Unix를 기반으로 하고 있음

7 유닉스 종류와 특성 Linux 1991년 핀란드의 대학생이었던 리누스 토발즈(Linus Benedict Torvalds, 1969~ )에 의해 만들어진 운영체제 개인 컴퓨터용 UNIX에 해당 특징 프로그램 소스코드가 공개돼 있어 프로그래머가 원하는 대로 특정기능 추가 가능 어느 플랫폼에도 포팅(porting)이 가능 무료 종류 레드햇(radhat), 데비안(debian), 슬렉웨어(slackware) 등

8 유닉스 종류와 특성 Mac OS Apple 컴퓨터의 매킨토시 계열 개인용 컴퓨터나 워크스테이션용 운영체제로 개인용 컴퓨터에 GUI를 처음으로 도입 1984년에 처음으로 세상에 선을 보인 이후로 거듭 발전 현재 새로운 Mac OS X 특징 문서편집이나 그래픽분야에서 많은 사랑을 받고 있음 Apple의 스마트폰인 iphon과 디지털 미디어 재생기인 ipod touch에도 내장되어 사용

9 유닉스 종류와 특성 Solaris Unix 계열의 운영체제 중 하나 Linux보다 훨씬 먼저 출시가 된 상용 운영체제 특징
처음에는 SUN에서 제작한 스팍(Sparc) CPU를 사용한 기종에서만 사용되는 전용 운영체제로 전문가들이 주로 사용 인텔 아키텍처의 대량 보급으로 인하여 인텔용 Solaris도 출시 됨

10 유닉스 종류와 특성 모바일 운영체제 현재 세계시장에 공급되는 범용으로 사용되는 모바일 운영체제 모바일 운영체제들의 특징
Windows Mobile, Symbian, Falm, BlackBerry, Linux 등 모바일 운영체제들의 특징 MS사의 Windows Mobile과 Nokia의 Symbian 등은 사용하는데 편리함 Apple, MS 등은 좀 더 많은 개발자와 사용자들에게 API를 제공함 Linux는 아예 모든 것을 공개 Linux를 기반으로 모바일 운영체제 리모(LiMo) 안드로이드(Android)

11 시스템 프로그래밍 소개

12 The System architecture of UNIX
Hardware CPU, Memory, Disk, Peripherals 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

13 시스템 호출 Process System call interface File Management IPC
Process Management

14 시스템 호출 시스템 인터페이스 역할 Application programs talk to the operating system via system calls Programmer’s functional interface to the UNIX kernel

15 사용자 모드/커널 Kernel User process open(char *name, int mode) {
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

16 시스템 호출 요약 파일 관련 시스템 호출 프로세스 관련 시스템 호출 시그널 관련 시스템 호출 IPC 관련 시스템 호출
open(), close(), read(), write(), dup(), seek(), … 프로세스 관련 시스템 호출 fork(), exec(), exit(), wait(), getpid(), getppid(), … 시그널 관련 시스템 호출 signal(), alarm(), kill(), sleep(), … IPC 관련 시스템 호출 pipe(), socket(), …

17 시스템 호출과 C 라이브러리 함수

18 시스템 호출과 라이브러리 함수 시스템 호출(System Calls) C 라이브러리 함수(Library Functions)
Unix 커널에 서비스 요청하는 호출 UNIX man의 Section 2에 설명되어 있음 C 함수처럼 호출될 수 있음. C 라이브러리 함수(Library Functions) C 라이브러리 함수는 보통 시스템 호출을 포장해 놓은 함수 보통 내부에서 시스템 호출을 함

19 시스템 호출과 라이브러리 함수 application code user process C library functions
system calls kernel kernel hardware (harddisk…)

20 C Standard I/O Library 1975년에 Dennis Ritchie에 의해 작성
많은 OS 상에 구현됨 ANSI C Standard Library 버퍼 할당(Buffer allocation) 최적 크기 단위로 I/O를 수행 디스크 I/O 횟수 최소화 스트림(Stream) 열린 파일을 스트림이라고 한다. 문자의 흐름으로 파일 입출력을 다룬다

21 C 프로그래밍 개발 도구

22 컴파일러 gnu c compiler 실행 파일 지정 컴파일 실행 gcc sample.c a.out
gcc –o sample sample.c sample

23 다중 모듈 프로그램 여러 개의 파일로 구성된 프로그램 #include <stdio.h> reverse.h
void reverse(); /* 선언 */ reverse.c #include <stdio.h> #include “reverse.h” void reverse(char *before, char *after) { int i, j, len; len = strlen(before); for (j = len-1, i=0; j>=0; j--, i++) after[i] = before[j]; after[len] = NULL; }

24 다중 모듈 프로그램 main1.c gcc –c reverse.c main1.c
#include <stdio.h> #include “reverse.h” main() { char str[100]; reverse(“cat”, str); printf(“reverse (\”cat\”) = %s\n”, str); reverse(“noon”, str); printf(“reverse (\”noon\”) = %s\n”, str); } gcc –c reverse.c main1.c gcc –o main1 reverse.o main1.o main1

25 디버거 gdb gdb 기능 컴파일 gdb 실행파일 단일 단계 이동(single stepping) 정지점(breakpoint)
변수 접근 및 수정 함수 탐색 추적(tracing) 컴파일 gcc –g 옵션을 이용하여 컴파일 gdb 실행파일 help

26 gdb 명령어 break [file:]function run [arglist] bt print expr c next step
Set a breakpoint at [file:]function run [arglist] Start program bt Backtrace: display the program stack. print expr c Continue running program next Execute next line (after stopping); step over any function calls in the line. step Execute next line; step into any function calls in the line. quit

27 DDD on Linux Data Display Debugger (DDD) Graphical gdb on Linux

28 The File Dependency System Make
Why do we use make ? gcc "reverse.c" gcc -o main1 reverse.o , main1.o … to produce a new version gcc -o main2 reverse.o , main2.o … to produce a new version We want to update files automatically based on dependency rules  make [ -f makefile] - updates files based on a series of dependency rules in "make file". - If no option is specified, the name "makefile" is assumed.

29 The File Dependency System Make
make files consist of make rules targetList: dependencyList commandList targetList a list of target files dependencyList a list of files that the files in targetList depend on a list of commands that reconstructs the target files from the dependency files.

30 The File Dependency System Make
main1: main1.o reverse.o gcc main1.o reverse.o -o main1 main1.o : main1.c reverse.h gcc -c main1.c reverse.o : reverse.c reverse.h gcc -c reverse.c Figure : make dependency tree main1 main1.o reverse.o main1.c reverse.h reverse.c reverse.h


Download ppt "고급 시스템 프로그래밍 제1장 소개 창병모 숙명여대 컴퓨터과학과."

Similar presentations


Ads by Google