슬라이드 1

Size: px
Start display at page:

Download "슬라이드 1"

Transcription

1 프로세스 (Process) (2) Chapter #9

2 강의목차 Process 관련시스템호출 Simple Shell Session Unix System Programming 2

3 프로세스정보 프로세스 ID 정보 프로세스정보 (1) PID(Process ID) 프로세스에할당되는유일한 ID( 정수값 ) PPID(Parent Process ID) 부모프로세스 ID PGID(Porcess Group ID) 하나의로긴쉘을부모프로세스로갖는프로세스그룹 ID 프로세스우선순위 (Process Priority) 실행가능한프로세스사이의스케줄링우선순위 0 : 제일높은우선순위 ~ 127: 제일낮은우선순위 프로세스우선순위변경 - nice 명령어 / nice() 시스템호출 프로세스의 cpu 사용시간 프로세스명령어실행시간 + 시스템실행시간 Unix System Programming 3

4 프로세스정보 (2) 프로세스정보 ( 계속 ) 사용자 ID 실사용자 (Real User) ID 프로세스를생성한사용자 ID / 프로세스를생성한쉘의사용자 ID fork() 시스템호출시에부모프로세스에서자신프로세스로계승 유효사용자 (Effective User) ID 그룹 ID 파일생성또는접근권한, 시스템콜실행권한등을검사할때에사용되는사용자 ID 보통실사용자 ID가유효사용자 ID가된다 접근모드중에 setuid가설정된프로그램의경우, 프로그램의소유자 ID가유효사용자 ID가된다 ( 예 ) /bin/passwd 실그룹 (Real Group) ID 유효그룹 (Effective Group) ID Unix System Programming 4

5 프로세스정보 (3) 프로세스정보 ( 계속 ) # ps el more Unix System Programming 5

6 프로세스정보 (4) 프로세스식별자 (Process ID) 관리 #include <sys/types.h> #include <unistd.h> pid_t getpid(void) pid_t getppid(void) pid_t getpgid(pid_t pid) pid_t getpgrp(void) // 현재프로세스의프로세스 ID 얻기 // 현재프로세스의부모프로세스 ID 얻기 // 현재프로세스의프로세스그룹 ID 얻기 // 현재프로세스의프로세스그룹 ID 얻기 /* 현재프로세스의프로세스 ID, 부모프로세스 ID 그리고프로세스그룹 ID 를반환한다 */ pid_t setpgid(pid_t pid, pid_t pgid) // 현재프로세스의프로세스그룹 ID 설정 pid_t setpgrp(void) // 현재프로세스의프로세스그룹 ID 설정 /* 정상종료되면 0 을반환하고, 에러인경우에는 -1 를반환한다. errno 에에러를나타내는값을설정한다. ( 참고 ) setpgrp = setpgid(0, 0) */ Unix System Programming 6

7 프로세스정보 (5) 프로세스의사용자식별자정보얻기 #include <sys/types.h> #include <unistd.h> uid_t getuid(void) gid_t getgid(void) uid_t geteuid(void) gid_t getegid(void) // 현재프로세스의실사용자 ID 얻기 // 현재프로세스의실그룹 ID 얻기 // 현재프로세스의유효사용자 ID 얻기 // 현재프로세스의유효그룹 ID 얻기 /* 에러가발생하지않으며, uid_t, gid_t 타입은 int 타입과같음 */ Unix System Programming 7

8 프로세스정보 (6) 프로세스의사용자식별자정보설정 #include <sys/types.h> #include <unistd.h> int setuid(uid_t uid) // 현재프로세스의실사용자 ID 설정 int setgid(gid_t gid) // 현재프로세스의실그룹 ID 설정 int seteuid(uid_t uid) // 현재프로세스의유효사용자 ID 설정 int setegid(gid_t gid) // 현재프로세스의유효그룹 ID 설정 int setreuid(uid_t ruid, uid_t euid) // 현재프로세스의실사용자및유효사용자 ID 설정 int setregid(gid_t rgid, gid_t egid) // 현재프로세스의실그룹및유효그룹 ID 설정 Unix System Programming 8

9 프로세스정보 (7) 아래의조건에따라읽기전용파일을생성하는프로그램을작성하고실사용자와유효사용자의관계를확인하라. 1. 실사용자와유효사용자의 ID를출력한다. 2. fopen() 함수를사용하여파일접근의성공과실패를검사한다. 3. setuid 함수를이용하여실사용자와유효사용자가동일하게만든다 를반복한다. 실험은다음단계로한다. 1. 프로그램을실행하고출력을관측한다. 2. 그룹멤버가프로그램을수행할수있도록접근허가를수정하여그룹멤버로하여금프로그램을수행시킨다. 3. set-user-id 비트를설정하고그룹멤버로하여금프로그램을수행시킨다. Unix System Programming 9

10 #include <stdio.h> int main(int argc, char *argv[]) { FILE *fp ; char line[256]; int uid; 프로세스정보 (8) if(argc <2) { fprintf(stderr,"usage: %s file_name\n",argv[0]); exit(1); printf("initially uid=%d and euid%d\n",getuid(), geteuid()); fp = fopen(argv[1],"r"); if(fp = NULL) { fprintf(stderr,"first open of %s failed",argv[1]); exit(2); else { printf("first open successful:\n"); while(fgets(fp,line,255)!=null) fputs(stdout,line); fclose(fp); Unix System Programming 10

11 프로세스정보 (9) setuid(uid = getuid()); printf("after setuid(%d):\n uid=%d and euid=%d\n",uid, getuid(), geteuid()); fp = fopen(argv[1], "r"); if(fp == NULL) { fprintf(stderr,"second open of %s failed",argv[1]); exit(3); else { printf("second open successful:\n"); while(fgets(line,255,fp)!= NULL) fputs(line,stdout); fclose(fp); return 0; Unix System Programming 11

12 프로세스정보 (10) 아래주어진옵션 (option) 에따라프로세스의정보를출력하는프로그램을작성하라. 옵션 (option) 의분해에는 getopt함수를사용한다. -i : 사용자 (user) 와그룹 (group) 의실사용자및유효사용자 ID를다음의함수를사용하여출력한다. -s : setpgrp() 함수를이용하여프로세스를새로운그룹에포함시킨다 -p : 프로세스, 부모프로세스, 그룹프로세스 ID를다음함수를이용하여출력한다. Unix System Programming 12

13 프로세스정보 (11) -p : 프로세스, 부모프로세스, 그룹프로세스 ID 를다음함수를이용하여출력한다. -u : ulimit() 함수를호출하여프로세스의크기에대한값을출력한다. -Unewlimit: ulimit() 함수를이용하여프로세스크기에대한값을새로설정한다. Unix System Programming 13

14 프로세스정보 (12) #include <stdio.h> #define GET_FSLIM1 #define SET_FSLIM2 extern char *optarg; extern int optind; int main(int argc, char *argv[]) { int getopt(), c; long ulimit(), atol(); static char options[] = "ispuu:"; if(argc < 2) fprintf(stderr,"usage: %s [-i] [-s] [-p] [-u] [-Unewulimit]\n", argv[0]); while((c=getopt(argc,argv,options))!= EOF) switch(c) { case 'i': printf("real userid = %d\n",getuid()); printf("effective userid = %d\n",geteuid()); printf("real groupid = %d\n",getgid()); printf("effective groupid = %d\n",getegid()); break; Unix System Programming 14

15 프로세스정보 (13) ulimit\n"); case 's': (void) setpgrp(); break; case 'p': printf("process number = %d\n",getpid()); printf("parent process number = %d\n",getppid()); printf("group process number = %d\n",getpgrp()); case 'U': if(ulimit(set_fslim,atol(optarg)) == -1) fprintf(stderr,"must be super-user to increase break; case 'u': printf("ulimit = %ld\n",ulimit(get_fslim,0l)); break; return 0; Unix System Programming 15

16 프로세스정보 (14) 프로세스의우선순위변경 #include <sys/types.h> #include <unistd.h> int nice(int inc) // 현재프로세스의우선순위변경 /* int inc : 우선순위를나타내는정수값 */ /* 정상종료되면 0 을반환하고, 에러인경우에는 -1 를반환한다. errno 에에러를나타내는값을설정한다. */ nice 시스템콜을호출한프로세스의 nice 값에 inc 값을더하여우선순위를변경한다 inc에음수를지정하여우선순위를높일수있으나, 슈퍼유저만가능함 Unix System Programming 16

17 프로세스정보 (15) 프로세스의 CPU 사용시간정보 #include <sys/types.h> #include <unistd.h> clock_t times(struct tms *buf) /* struct tms *buf : 프로세스소비시간정보 */ /* 정상종료되면 0 을반환하고, 에러인경우에는 -1 를반환한다. errno 에에러를나타내는값을설정한다. */ tms 구조체에는다음의정보를정의한다 사용자시간 : 프로세스가명령어실행에사용한 CPU 시간 시스템시간 : 프로세스를위해시스템이사용한 CPU 시간 자식프로세스의사용자시간 : 끝나기를기다리는모드자식프로세스의사용자시간의합계 자식프로세스의시스템시간 : 끝나기를기다리는모드자식프로세스의시스템시간의합계 Unix System Programming 17

18 프로세스환경변수 프로세스정보 (16) LINUX 프로세스의환경은셸 (shell) 변수들로써이루어짐 셸 (shell) 변수들은스택 (stack) 에저장되어있음 환경변수접근방법 방법 #1 - 명령어행의인수 (argument) 들을접근하는것처럼주함수 (main function) 에환경변수파라미터를추가하는것 방법 #2 - 환경변수들이저장된테이블의시작주소를가지고있는전역변수 envion 을이용 Unix System Programming 18

19 프로세스정보 (17) 프로세스의환경변수 : getenv, putenv Unix System Programming 19

20 프로세스정보 (18) 자신의환경변수들을모두출력하는프로그램을작성하라. 환경변수 TZ(Time Zone) 을변경한후변경된내용을출력하여확인하라. 새로운환경변수 WARNING에값을설정한후그내용을출력시켜라. Unix System Programming 20

21 프로세스정보 (19) extern char **environ; void main(int argc, char *argv[], char *envp[]) { char *getenv(); printenv("initially", &envp); putenv("tz=pst8pdt"); printenv("after changing TZ", &envp); putenv("warning=don't use envp after putenv()"); printenv("after setting a new variable",&envp); printf("value of WARNING is %s\n",getenv("warning")); Unix System Programming 21

22 프로세스정보 (20) void printenv(char *label, char ***envpp) { char **p; printf("---- %s ---\n",label); printf(" envp is at %8o and contains %8o\n", envpp, *envpp); printf("environ is at %8o and contains %8o\n", &environ, environ); printf("my environment variables are:\n"); for(p=environ; *p; p++) printf("(%8o) = %8o -> %s\n",p,*p,*p); printf("(%8o) = %8o\n", p, *p); Unix System Programming 22

23 프로세스생성 : fork() #include <sys/types.h> #include <unistd.h> pid_t fork(void) 프로세스생성 (1) /* 정상종료되면자식프로세스에게는 0 을반환하고부모프로세스에게는자식프로세스의프로세스 ID 를반환한다. 그리고에러인경우에는 -1 를반환하고 errno 에에러를나타내는값을설정한다. */ 호출한프로세스의구조를동일하게복사한프로세스를생성 부모프로세스 (parent process) 와자식프로세스 (child process) 복제된자식프로세스는부모프로세스로부터텍스트 ( 코드 ), 데이터그리고파일디스크립터등모든정보나속성을상속받는다 자식프로세스의 CPU 사용시간정보는 0으로초기화된다 Unix System Programming 23

24 프로세스생성 (2) the child process inherit the following from the parent differences between the parent and child real-uid(gid), effectiveuid(gid), supplementary gid process group id, session id, controlling terminal set-user(group)-id flag current working directory, root directory, umask signal mask and dispositions the return value from fork PID and PPID child s resource utilizations are set to 0 pending alarms are cleared for the child the set of pending signals for the child is set to the empty set close-on-exec flags Environment resource limits Unix System Programming 24

25 프로세스생성 (3) 커널의 fork() 시스템콜수행절차 1. 새로운프로세스를위해프로세스테이블항을할당한다. 2. 자식프로세스에게고유의 ID 번호를부여한다. 3. 부모프로세스의내용을논리적으로복사한다. 예를들면, 텍스트영역과같은프로세스의일부영역은프로세스사이에공유될수있으므로, 커널은그영역을메모리내의새로운위치에복사하는대신영역참조계수 (region reference count) 를증가시킬수도있다. 4. 프로세스와관련된파일에대해파일테이블과 inode 테이블카운터 (counter) 를증가시킨다. 5. 부모프로세스에게는자식의 ID 번호를복귀시키고, 자식프로세스에게는 0 을복귀시킨다. Unix System Programming 25

26 프로세스생성 (4) fork() 시스템콜수행결과 unix System Programming 26

27 프로세스생성 (5) fork() 시스템콜수행결과 unix System Programming 27

28 프로세스생성 (6) fork() 시스템콜수행결과 unix System Programming 28

29 프로세스생성 (7) fork() 시스템콜에따른부모및자식프로세스구분 int pid; : if ((pid = for()) == 0) { // return 0 to child process // child process s processing else if (pid > 0) { // return process ID of child process to parent process // parent process s processing Else { perror( fork ); exit 1; Unix System Programming 29

30 프로세스생성 (8) UNIX 프로세스생성방법 : fork & exec 교재 pp.277 그림 9.2 참조 Unix System Programming 30

31 예제프로그램 #1 프로세스생성 (9) fork() 시스템콜전에부모프로세스의 ID를출력하고, fork() 시스템콜후에부모및자식프로세스의 ID를출력하여 fork 함수의기능을확인할수있는프로그램을작성한다 현재수행중인프로세스의 ID는 getpid() 함수를사용하고, 현재프로세스의부모프로세스 ID는 getppid() 함수를사용하여얻는다 Unix System Programming 31

32 프로세스생성 (10) #include <stdio.h> int main(void) { int getpid(), getppid(); printf("[%d] parent process id: %d\n",getpid(), getppid()); fork(); printf("\n\t[%d] parent process id: %d\n",getpid(), getppid()); printf("this IS FORK SYSTEM CALL TEST.\n"); return 0; Unix System Programming 32

33 예제프로그램 #2 프로세스생성 (11) 부모프로세스는대문자로 A 에서 Z 까지출력하고동시에자식프로세스는소문자로 a 에서 z 까지출력하는프로그램을작성하여두개의프로세스가동시에수행되고있음을확인하여라. Unix System Programming 33

34 #include <sys/types.h> #include <unistd.h> main(int argc, char *argv[]) { char ch, first, last; int pid; long i; 프로세스생성 (12) if((pid = fork())>0) { /* parent */ first = 'A'; last = 'Z'; else if(pid == 0) { /* child */ first = 'a'; last = 'z'; else { /* not fork(2) */ perror(argv[0]); exit(1); printf("\n"); for(ch = first; ch <= last; ch++) { /* delay loop */ for(i=0; i<= ; i++); write(1, &ch, 1); return 0; Unix System Programming 34

35 예제프로그램 #3 프로세스생성 (13) fork() 시스템콜에의한상속 부모프로세스가가지고있던변수값들은자식프로세스에복제되어그대로전달 부모프로세스의파일디스크립터테이블이자식프로세스에그대로전달 부모프로세스와자식프로세스사이의파일디스크립터상속및파일공유를테스트하는프로그램 Unix System Programming 35

36 프로세스생성 (14) /*proc_file -- fork 시파일이어떻게취급되는지를보인다. */ /*fork 는 data 가최소한 20 문자이상임을가정한다. */ #include <unistd.h> #include <fcntl.h> int main(void) { intfd; pid_tpid;/* 프로세스식별번호 */ char buf[10];/* 화일자료를저장할버퍼 */ if (( fd= open ("data", O_RDONLY)) == -1) fatal ("open failed"); read (fd, buf, 10); /* 파일포인터를전진시킨다. */ printpos("before fork", fd); /* 이제두개의프로세스를생성한다. */ switch (pid= fork()){ case -1: /* 오류 */ fatal ("fork failed"); break; 36

37 프로세스생성 (15) case 0: /* 자식 */ printpos("child before read", fd); read (fd, buf, 10); printpos("child after read", fd); break; default: /* 부모 */ wait ((int*)0); printpos("parent after wait", fd); exit(0); /* 파일내에서위치를프린트한다. */ void intprintpos(constchar *string, intfiledes) { off_t pos: if (( pos = lseek(filedes, 0, SEEK_CUR)) == -1) fatal ("lseekfailed"); printf("%s:%ld\n", string, pos); 37

38 프로세스생성 (16) fork 부모프로세스의메모리영역복사 부모프로세스의정보 (file descriptor, signal 등복사 ) vfork 부모프로세스의메모리영역공유 자식프로세스는 exec 이나 exit 호출을할때까지부모프로세스의메모리영역에서실행되며, 부모프로세스는실행을멈춘다. 자식프로세스에서의변경이부모프로세스에게영향을준다. 자식프로세스는 _exit 호출로종료해야한다. (exit는표준입출력을 flush, close한다 ) 보통 execve() 와함께사용 Clone Linux에서의 thread 생성 4 개의인자사용 fn: 새로생성된태스크에서수행할함수, arg: fn에게전달할함수 flags: CLONE_VM, CLONE_FILES, CLONE_PTRACE, CLONE_VFORK child stack: 새로생성된태스크에서사용할사용자수준스택 38

39 프로세스실행 : exec() 프로세스실행 (1) 호출한프로세스를다른프로그램을실행하는새로운프로세스로변환한다 3 가지인자 : 새롭게실행하는프로그램의파일경로명 새롭게실행하는프로그램의 main() 함수에전달하는명령어행의파라미터정보 (argv 정보 ) 새롭게실행하는프로그램의 main() 함수에전달하는환경변수정보 (envp 정보 ) 인자전달방식에따라 6 종류의시스템콜을지원 execl(), execv(), execl(), execve(), execlp(), execvp() 39

40 프로세스실행 : exec() 프로세스실행 (2) Unix System Programming 40

41 프로세스실행 : exec() #include <sys/types.h> #include <unistd.h> 프로세스실행 (3) int execl(const char *path, const char *argv0, *argv1,, *argvn, (char *)0) int execv(const char *path, char *const argv[]) /* const char *path : 실행파일의경로명 */ /* const char *argv0, *argv1,, *argvn : argv 정보목록 */ /* char *const argv[] : argv 정보 ( 문자열배열 ) */ /* 에러인경우에는 -1 를반환하고 errno 에에러를나타내는값을설정한다. */ 첫번째인자인경로명에서지정한실행파일을실행한다 Unix System Programming 41

42 프로세스실행 : exec() #include <sys/types.h> #include <unistd.h> 프로세스실행 (4) int execle(const char *path, const char *argv0, *argv1,, *argvn, (char *)0, char *const envp[]) int execve(const char *path, char *const argv[], char *const envp[]) /* const char *path : 실행파일의경로명 */ /* const char *argv0, *argv1,, *argvn : argv 정보목록 */ /* char *const argv[] : argv 정보 ( 문자열배열 ) */ /* char *const envp[]: envp 정보 ( 문자열배열 ) */ /* 에러인경우에는 -1 를반환하고 errno 에에러를나타내는값을설정한다. */ 환경변수정보를마지막인자로전달한다 Unix System Programming 42

43 프로세스실행 : exec() #include <sys/types.h> #include <unistd.h> 프로세스실행 (5) int execlp(const char *file, const char *argv0, *argv1,, *argvn, (char *)0) int execvp(const char *file, char *const argv[]) /* const char *file : 실행파일명 */ /* const char *argv0, *argv1,, *argvn : argv 정보목록 */ /* char *const argv[] : argv 정보 ( 문자열배열 ) */ /* 에러인경우에는 -1 를반환하고 errno 에에러를나타내는값을설정한다. */ 첫번째인자로파일명만주어지며, 환경변수 PATH 에서지정된디렉토리안에서찾아실행한다 Unix System Programming 43

44 예제프로그램 #1 프로세스실행 (6) 명령어행의파라미터에서지정한프로그램을실행하는프로그램 #include <stdio.h> #include <sys/types.h> #include <unistd.h> #define ERR -1 void usage(const char* fname) { char *cmd_name; if ((cmd_name = rindex(fname, / ))!= NULL) cmd_name++; else cmd_name = fname; fprintf(stderr, Usage: %s command [option]\n, cmd_name); exit(1); Unix System Programming 44

45 프로세스실행 (7) int main(int argc, char *argv[]) { if (argv < 2) Usage(argv[0]); if(execv(argv[1], &argv[1]) == ERR) { perror( execv ); exit(1); // doesn t reach here return 0; Unix System Programming 45

46 예제프로그램 #2 프로세스실행 (8) exec 시스템호출함수를이용하여다른프로그램을실행시키면본래의프로그램은실행이중단되는결과를가져온다. 그러므로프로그램에서 exec 함수를이용하여다른프로그램을수행시킨후중단없이작업을계속하려면 fork 를이용하여자식프로세스가 exec 함수를호출하게만들면부모프로세스의중단없이작업을계속수행할수있다 fork 와 exec 함수를이용하여부모프로세스가중단되지않도록 exec 함수를사용하여 LINUX 의 echo 명령어를실행시키는프로그램을작성하여라 Unix System Programming 46

47 프로세스실행 (9) int main(void) { int fork(); if(fork() == 0) { execl("/bin/echo", "echo","this is","message one",(char *) 0); perror("exec one failed"); exit(1); if(fork() == 0) { execl("/bin/echo","echo","this is","message two",(char *) 0); perror("exec two failed"); exit(2); if(fork() == 0) { execl("/bin/echo","echo","this is","message three",(char *) 0); perror("exec three failed"); exit(3); printf("parent program ending\n"); return 0; Unix System Programming 47

48 자식프로세스종료대기 (1) 자식프로세스종료대기 : wait() #include <sys/types.h> #include <sys/wait.h> pid_twait(int*status) /* int *status : 자식프로세스의종료상태정보 */ /* 자식프로세스가종료나정지한경우에자식프로세스의프로세스 ID 를반환한다. 시그널을수신하여복귀한경우에는외부변수 errno 에 EINTR 를설정한다. 에러인경우에는 -1 를반환하고 errno 에에러를나타내는값을설정한다. */ 호출프로세스는자식프로세스가종료되거나정지되기를기다린다 자식프로세스중에하나가종료되거나정지되면자식프로세스의 PID 값이반환하며, 자식프로세스의종료상태값을전달인자 status( 하위 16 비트 ) 에저장하여반환한다 48

49 자식프로세스종료대기 (2) 자식프로세스의종료또는정지상태정보구분 자식프로세스가 exit() 시스템콜의호출에의해종료한경우 exit() 로전달된값의하위 8 비트값하위 8 비트 = 0 자식프로세스가시그널에의해종료한경우 상위 8 비트 = 0 하위 8 비트 = 시그널번호 자식프로세스가정지한경우 정지한원인이되는시그널번호 하위 8 비트 = 0x7f 49

50 자식프로세스종료대기 (3) 자식프로세스종료대기 : waitpid() #include <sys/types.h> #include <sys/wait.h> pid_t waitpid(pid_t pid, int *status, int options) /* pid_t pid : 자식프로세스의프로세스 ID */ /* int *status : 자식프로세스의종료상태정보 */ /* int options : 동작에관한옵션 */ /* 자식프로세스가종료나정지한경우에자식프로세스의프로세스 ID 를반환한다. 시그널을수신하여복귀한경우에는외부변수 errno 에 EINTR 를설정한다. 에러인경우에는 -1 를반환하고 errno 에에러를나타내는값을설정한다. */ 종료나정지하는자식프로세스의프로세스 ID 또는프로세스그룹 ID 를지정할수있다 50

51 자식프로세스종료대기 (4) 자식프로세스종료대기 : waitpid() 자식프로세스지정 pid 값 지정하는자식프로세스 -1 보다작은값 pid 의절대값과같은프로세스그룹 ID 를가진프로세스 -1 자식프로세스중에임의의자식프로세스. wait() 와동일 0 waitpid() 를호출한프로세스의프로세스그룹 ID 와같은프로세스그룹 ID 를가지프로세스 0 보다큰값프로세스 ID 가 pid 와같은프로세스 option 인자 WNOHANG 대기할자식프로세스가없는경우에바로반환한다 WUNTRACED 자식프로세스가정지하고있는경우에도반환하며, status 는보고되지않는다 51

52 프로세스종료 : _exit() #include <unistd.h> void _exit(int status) /* intstatus : 종료상태정보 */ 프로세스종료 (1) 호출프로세스를종료하며, status 인자값이종료상태정보로전달된다 프로세스종료시에열어둔모드파일디스크립터를닫는다 52

53 프로세스종료 : exit() #include <stdlib.h> void exit(int status) /* intstatus : 종료상태정보 */ 프로세스종료 (2) 호출프로세스를종료하며, status 인자값이종료상태정보로전달된다 ( 라이브러리함수 ) _exit() 기능이외에종료시에지정된처리나입출력버퍼를비우는기능을수행한다 53

54 Zombie 프로세스 (1) Normal parent-child process relation A parent process waits for a child process to exit. Other situations A child process exits when its parent process is not currently executing wait. The child is zombie-a process without any kernel resources. The child will be removed if the parent executes wait. A parent exits while one or more children are still running. The parent can exit normally. The children are adopted by the init process(pid=1). Unix System Programming 54

55 zombie state Zombie 프로세스 (2) the kernel has to keep a certain amount of information consists of PID, the termination status of the process, and the amount of CPU time taken by the process the process that has terminated, but whose parent has not yet waited for it, is called a zombie init is written so that whenever one of its children terminates,init calls one of the wait functions to fetch the termination status init prevents the system from being clogged by zombies Unix System Programming 55

56 프로세스관련예제 #1 (1) 프로세스관련예제 #1 명령어행의파라미터에서지정한프로그램을자식프로세스를통해실행하고자식프로세스의종료상태정보를같이출력하는프로그램 쉘의명령어실행기능 (foreground command execution) Unix System Programming 56

57 프로세스관련예제 #1 (2) #include <stdio.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #define ERR -1 void usage(const char* fname) { char *cmd_name; if ((cmd_name = rindex(fname, / ))!= NULL) cmd_name++; else cmd_name = fname; fprintf(stderr, Usage: %s command [option]\n, cmd_name); exit(1); int main(int argc, char *argv[]) { int pid, status; if(argc < 2) usage(argv[0]); Unix System Programming 57

58 프로세스관련예제 #1 (3) if ((pid = fork()) == 0) { printf( Child process : execute a new program %s.\n, argv[1]); if (execv(argv[1], &argv[1] == ERR) { perror( execv ); exit(1); else if (pid > 0) { wait(&status); printf( Parent process : child process just finished.\n ); printf( status = 0x%04x\n, status); else { perror( fork ); exit(1); exit(0); Unix System Programming 58

59 프로세스관련예제 #2 프로세스관련예제 #2 동시에여러개의자식프로세스를생성하고, 자식프로세스로하여금다른프로그램을실행하도록한후에모든자식프로세스가종료할때까지대기하는프로그램 프로그램소스 교재 pp. 286 ~293 참조 Unix System Programming 59

60 쉘프로그램의기본구조 Shell 구현 (1) Unix System Programming 60

61 Shell 구현 (2) /* main.c: simple shell example. */ main(){... char prompt[] = "mysh> "; // 전처리 : 쉘설명출력 while (1) { // 쉘프롬프트출력. 그리고표준입력에서명령어라인읽기 if (read(0, command, DO_MAX_BUF) == 0) { printf("havea nice day^^ n"); exit(0); // 명령을 token 별로구분 while (1) { getnexttoken(&command[cmd_offset], argv[cur_argc]); cur_argc++;... // token 이내부명령일경우처리 if (strcmp(argv[0], "exit") == 0) { printf("havea nice day^^ n"); exit(0); // token 에서파이프, 입출력재지정, 백그라운드, 다중명령처리 // 쉘스크립트처리 // 외부명령처리 do_command(argv); Unix System Programming 61

62 Simple Shell (1) simple command processor 프로세스관련시스템호출을활용 표준 UNIX 명령및유틸리티와유사한형태 구조 while (!EOF) { 사용자로부터명령줄을받아들인다명령인수를조립하여수행한다자식을기다린다 (wait) Unix System Programming 62

63 Simple Shell 구현 교재 pp. 294~301 참조 Simple Shell (2) Unix System Programming 63

64 Session Session (1) a collection of one or more process group 각프로세스그룹은하나의세션에소속 각세션은하나의제어단말기 (controlling terminal) 을가짐 한세션은하나의 foreground process group과하나또는그이상의 background process group으로구성 daemon process에사용 controlling terminal을갖지않는프로세스 setsid() 를사용하여생성 Unix System Programming 64

65 Session Session (2) a process(not a process group leader) can create a new session by calling setsid( ) #include <unistd.h> pid_t setsid(void); The calling process is the leader of the new session. The calling process is the process group leader of the new process group. has no controlling terminal The process group ID and session ID of the calling process are set to the PID of the calling process Unix System Programming 65

66 Session (3) Session The calling process will be the only process in this new process group and in this new session A process group leader is a process with process group ID equal to its PID In order to be sure that setsidwill succeed, fork and exit, and have the child do setsid() return value the session ID of the calling process on success -1 on error Unix System Programming 66

67 Session (4) Process Group & Session Unix System Programming 67

<4D F736F F F696E74202D FC7C1B7CEBCBCBDBA20BBFDBCBAB0FA20BDC7C7E0205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D FC7C1B7CEBCBCBDBA20BBFDBCBAB0FA20BDC7C7E0205BC8A3C8AF20B8F0B5E55D> 학습목표 프로세스를생성하는방법을이해한다. 프로세스를종료하는방법을이해한다. exec함수군으로새로운프로그램을실행하는방법을이해한다. 프로세스를동기화하는방법을이해한다. 프로세스생성과실행 IT CookBook, 유닉스시스템프로그래밍 2/24 목차 프로세스생성 프로세스종료함수 exec 함수군활용 exec 함수군과 fork 함수 프로세스동기화 프로세스생성 [1] 프로그램실행

More information

2009년 상반기 사업계획

2009년 상반기 사업계획 프로세스생성과실행 IT CookBook, 유닉스시스템프로그래밍 학습목표 프로세스를생성하는방법을이해한다. 프로세스를종료하는방법을이해한다. exec함수군으로새로운프로그램을실행하는방법을이해한다. 프로세스를동기화하는방법을이해한다. 2/24 목차 프로세스생성 프로세스종료함수 exec 함수군활용 exec 함수군과 fork 함수 프로세스동기화 3/24 프로세스생성 [1]

More information

Microsoft PowerPoint - 10_Process

Microsoft PowerPoint - 10_Process Linux 프로세스프로그래밍 Programming - 프로세스생성 : fork, exec - 프로세스동기화 : wait - 프로세스관리함수 프로세스관련함수 프로세스생성과종료 함수 의미 fork 자신과완전히동일한프로세스를생성한다. exec 계열지정한실행파일로부터프로세스를생성한다. exit 종료에따른상태값을부모프로세스에게전달하며프로세스를종료한다. atexit exit

More information

제9장 프로세스 제어

제9장 프로세스 제어 제 9 장프로세스제어 리눅스시스템프로그래밍 청주대학교전자공학과 한철수 제 9 장 목차 프로세스생성 프로그램실행 입출력재지정 프로세스그룹 시스템부팅 2 9.1 절 프로세스생성 fork() 시스템호출 새로운프로그램을실행하기위해서는먼저새로운프로세스를생성해야하는데, fork() 시스템호출이새로운프로세스를생성하는유일한방법임. 함수프로토타입 pid_t fork(void);

More information

10.

10. 10. 10.1 10.2 Library Routine: void perror (char* str) perror( ) str Error 0 10.3 10.3 int fd; /* */ fd = open (filename, ) /*, */ if (fd = = -1) { /* */ } fcnt1 (fd, ); /* */ read (fd, ); /* */ write

More information

6주차.key

6주차.key 6, Process concept A program in execution Program code PCB (process control block) Program counter, registers, etc. Stack Heap Data section => global variable Process in memory Process state New Running

More information

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D> 리눅스 오류처리하기 2007. 11. 28 안효창 라이브러리함수의오류번호얻기 errno 변수기능오류번호를저장한다. 기본형 extern int errno; 헤더파일 라이브러리함수호출에실패했을때함수예 정수값을반환하는함수 -1 반환 open 함수 포인터를반환하는함수 NULL 반환 fopen 함수 2 유닉스 / 리눅스 라이브러리함수의오류번호얻기 19-1

More information

ABC 11장

ABC 11장 12 장고급응용 0 수행중인프로그램 프로세스 모든프로세스는유일한프로세스식별번호 (PID) 를가짐 유닉스에서는 ps 명령을사용하여프로세스목록을볼수있음 12-1 프로세스 $ ps -aux USER PID %CPU %MEM SZ RSS TT STAT START TIME COMMAND blufox 17725 34.0 1.6 146 105 i2 R 15:13 0:00

More information

제1장 Unix란 무엇인가?

제1장  Unix란 무엇인가? 1 12 장파이프 2 12.1 파이프 파이프원리 $ who sort 파이프 3 물을보내는수도파이프와비슷 한프로세스는쓰기용파일디스크립터를이용하여파이프에데이터를보내고 ( 쓰고 ) 다른프로세스는읽기용파일디스크립터를이용하여그파이프에서데이터를받는다 ( 읽는다 ). 한방향 (one way) 통신 파이프생성 파이프는두개의파일디스크립터를갖는다. 하나는쓰기용이고다른하나는읽기용이다.

More information

Microsoft PowerPoint - chap9 [호환 모드]

Microsoft PowerPoint - chap9 [호환 모드] 제 9 장프로세스관계 숙대창병모 1 Contents 1. Logins 2. Process Groups 3. Sessions 4. Controlling Terminal 5. Job Control 숙대창병모 2 로그인 숙대창병모 3 터미널로그인 /etc/ttys: 1 line per terminal device getty: opens terminal device

More information

Microsoft PowerPoint - Lecture_Note_7.ppt [Compatibility Mode]

Microsoft PowerPoint - Lecture_Note_7.ppt [Compatibility Mode] Unix Process Department of Computer Engineering Kyung Hee University. Choong Seon Hong 1 유닉스기반다중서버구현방법 클라이언트들이동시에접속할수있는서버 서비스를동시에처리할수있는서버프로세스생성을통한멀티태스킹 (Multitasking) 서버의구현 select 함수에의한멀티플렉싱 (Multiplexing)

More information

/chroot/lib/ /chroot/etc/

/chroot/lib/ /chroot/etc/ 구축 환경 VirtualBox - Fedora 15 (kernel : 2.6.40.4-5.fc15.i686.PAE) 작동 원리 chroot유저 ssh 접속 -> 접속유저의 홈디렉토리 밑.ssh의 rc 파일 실행 -> daemonstart실행 -> daemon 작동 -> 접속 유저만의 Jail 디렉토리 생성 -> 접속 유저의.bashrc 의 chroot 명령어

More information

좀비프로세스 2

좀비프로세스 2 Signal & Inter-Process Communication Department of Computer Engineering Kyung Hee University. Choong Seon Hong 1 좀비프로세스 2 좀비프로세스 (zombie process) 좀비프로세스란프로세스종료후메모리상에서사라지지않는프로세스 좀비프로세스의생성이유. 자식프로세스는부모프로세스에게실행결과에대한값을반환해야한다.

More information

System Programming Lab

System Programming Lab System Programming Lab Week 4: Shell Schedule for your own shell 1 st shell 기본기능 fork / exec Background Processing/ Sequential Execution ls, find, grep 2 nd Environment variables/ Shell variables built-in

More information

chap7.key

chap7.key 1 7 C 2 7.1 C (System Calls) Unix UNIX man Section 2 C. C (Library Functions) C 1975 Dennis Ritchie ANSI C Standard Library 3 (system call). 4 C?... 5 C (text file), C. (binary file). 6 C 1. : fopen( )

More information

1장. 유닉스 시스템 프로그래밍 개요

1장.  유닉스 시스템 프로그래밍 개요 Unix 프로그래밍및실습 7 장. 시그널 - 과제보충 응용과제 1 부모프로세스는반복해서메뉴를출력하고사용자로부터주문을받아자식프로세스에게주문내용을알린다. (SIGUSR1) ( 일단주문을받으면음식이완료되기전까지 SIGUSR1 을제외한다른시그널은모두무시 ) timer 자식프로세스는주문을받으면조리를시작한다. ( 일단조리를시작하면음식이완성되기전까지 SIGALARM 을제외한다른시그널은모두무시

More information

슬라이드 1

슬라이드 1 / 유닉스시스템개요 / 파일 / 프로세스 01 File Descriptor file file descriptor file type unix 에서의파일은단지바이트들의나열임 operating system 은파일에어떤포맷도부과하지않음 파일의내용은바이트단위로주소를줄수있음 file descriptor 는 0 이나양수임 file 은 open 이나 creat 로 file

More information

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

Microsoft PowerPoint - chap13-입출력라이브러리.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 스트림의 기본 개념을 알아보고,

More information

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

Microsoft PowerPoint - ch09_파이프 [호환 모드] 학습목표 파이프를이용한 IPC 기법을이해한다. 이름없는파이프를이용해통신프로그램을작성할수있다. 이름있는파이프를이용해통신프로그램을작성할수있다. 파이프 IT CookBook, 유닉스시스템프로그래밍 2/20 목차 파이프의개념 이름없는파이프만들기 복잡한파이프생성 양방향파이프활용 이름있는파이프만들기 파이프의개념 파이프 두프로세스간에통신할수있도록해주는특수파일 그냥파이프라고하면일반적으로이름없는파이프를의미

More information

2009년 상반기 사업계획

2009년 상반기 사업계획 파이프 IT CookBook, 유닉스시스템프로그래밍 학습목표 파이프를이용한 IPC 기법을이해한다. 이름없는파이프를이용해통신프로그램을작성할수있다. 이름있는파이프를이용해통신프로그램을작성할수있다. 2/20 목차 파이프의개념 이름없는파이프만들기 복잡한파이프생성 양방향파이프활용 이름있는파이프만들기 3/20 파이프의개념 파이프 두프로세스간에통신할수있도록해주는특수파일 그냥파이프라고하면일반적으로이름없는파이프를의미

More information

Microsoft PowerPoint - 09-Pipe

Microsoft PowerPoint - 09-Pipe 9. 파이프 상명대학교소프트웨어학부 파이프 시그널은이상한사건이나오류를처리하는데는이용하지만, 한프로세스로부터다른프로세스로대량의정보를전송하는데는부적합하다. 파이프 한프로세스를다른관련된프로세스에연결시켜주는단방향의통신채널 2 pipe() Usage #include int pipe(int filedes[2]); 3 < ex_1.c > #include

More information

제8장 프로세스

제8장 프로세스 제 8 장프로세스 리눅스시스템프로그래밍 청주대학교전자공학과 한철수 1 목차 쉘과프로세스 프로그램실행 프로그램종료 프로세스 ID 프로세스이미지 2 8.1 절 프로세스 프로세스 (process) 는파일과더불어리눅스운영체제의핵심개념중하나임. 리눅스시스템을깊이있게이해하기위해서는프로세스에대해서정확히이해해야함. 프로세스는간단히실행중인프로그램이라고할수있음. 프로그램이실행되면프로세스가됨.

More information

제1장 Unix란 무엇인가?

제1장  Unix란 무엇인가? 4 장파일 컴퓨터과학과박환수 1 2 4.1 시스템호출 컴퓨터시스템구조 유닉스커널 (kernel) 하드웨어를운영관리하여다음과같은서비스를제공 파일관리 (File management) 프로세스관리 (Process management) 메모리관리 (Memory management) 통신관리 (Communication management) 주변장치관리 (Device

More information

제8장 프로세스

제8장 프로세스 제 8 장프로세스 리눅스시스템프로그래밍 청주대학교전자공학과 한철수 제 8 장 목차 쉘과프로세스 프로그램실행 프로그램종료 프로세스 ID 프로세스이미지 2 8.1 절 프로세스 프로세스 (process) 는파일과더불어리눅스운영체제의핵심개념중하나임. 리눅스시스템을깊이있게이해하기위해서는프로세스에대하여정확히이해해야함. 프로세스는실행중인프로그램이라고간단히말할수있음. 프로그램이실행되면프로세스가됨.

More information

고급 프로그래밍 설계

고급 프로그래밍 설계 UNIT 12 프로세스제어 광운대학교로봇 SW 교육원 최상훈 init 프로세스 2 init 프로세스 프로세스 ID : 1 시스템부팅젃차마지막에커널에의해실행됨 커널부팅이후 UNIX 시스템을뛰우는역핛을함 시스템의존적초기화파일들 /etc/rc* 파일들, /etc/inittab 과, /etc/init.d 의파일들을읽고시스템을특정핚상태 ( 이를테면다중사용자상태 ) 로설정함

More information

<C1A63130C0E5C7C1B7CEBCBCBDBA2E687770>

<C1A63130C0E5C7C1B7CEBCBCBDBA2E687770> 제 10 장프로세스프로그래밍 프로세스시작 / 종료 자식프로세스생성 프로세스내에서새로운프로그램실행 시그널 시스템부팅 10.1 프로그램시작및종료 Unix 에서프로그램은어떻게실행이시작되고종료될까? 프로그램은 10.3 절에서살펴볼 exec 시스템호출에의해실행된다. 이호출은실행될프로그램의시작루틴에게명령줄인수 (command-line arguments) 와환경변수 (environment

More information

리눅스 프로세스 관리

리눅스 프로세스 관리 프로세스 (Process) Process 프로그램이나명령어를실행하면메모리에적재되어실제로실행되고있는상태를의미 이러한프로세스들은프로세스가시작하면서할당받는프로세스식별번호인 PID(Process ID), 해당프로세스를실행한부모프로세스를나타내는 PPID(Parent Process ID), UID 와 GID 정보를통해해당프로세스가어느사용자에속해있는지, 프로세스가파일에대해갖는권한및프로세스가실행된터미널,

More information

슬라이드 1

슬라이드 1 -Part3- 제 4 장동적메모리할당과가변인 자 학습목차 4.1 동적메모리할당 4.1 동적메모리할당 4.1 동적메모리할당 배울내용 1 프로세스의메모리공간 2 동적메모리할당의필요성 4.1 동적메모리할당 (1/6) 프로세스의메모리구조 코드영역 : 프로그램실행코드, 함수들이저장되는영역 스택영역 : 매개변수, 지역변수, 중괄호 ( 블록 ) 내부에정의된변수들이저장되는영역

More information

제12장 파일 입출력

제12장 파일 입출력 제 4 장파일입출력 리눅스시스템프로그래밍 청주대학교전자공학과 한철수 1 시스템호출 (system call) 파일 (file) 임의접근 (random access) 주요학습내용 2 4.1 절 커널의역할 (kernel) 커널 (kernel) 은운영체제의핵심부분으로서, 하드웨어를운영관리하는여러가지서비스를제공함 파일관리 (File management) 디스크 프로세스관리

More information

歯9장.PDF

歯9장.PDF 9 Hello!! C printf() scanf() getchar() putchar() gets() puts() fopen() fclose() fprintf() fscant() fgetc() fputs() fgets() gputs() fread() fwrite() fseek() ftell() I/O 2 (stream) C (text stream) : `/n'

More information

슬라이드 1

슬라이드 1 Task 통신및동기화 : 파이프 (Pipe) Chapter #11 파이프 (Unamed Pipe) 표준입출력과파이프 FIFO(Named Pipe) 강의목차 Unix System Programming 2 파이프 (Unnamed Pipe) 파이프 (Pipe) (1) 하나의프로세스를다른프로세스에연결시켜주는단방향의통신채널 입출력채널과동기화기능을제공하는특수한형태의파일

More information

Chapter #01 Subject

Chapter #01  Subject Device Driver March 24, 2004 Kim, ki-hyeon 목차 1. 인터럽트처리복습 1. 인터럽트복습 입력검출방법 인터럽트방식, 폴링 (polling) 방식 인터럽트서비스등록함수 ( 커널에등록 ) int request_irq(unsigned int irq, void(*handler)(int,void*,struct pt_regs*), unsigned

More information

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

임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 임베디드시스템설계강의자료 6 system call 2/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 System call table and linkage v Ref. http://www.ibm.com/developerworks/linux/library/l-system-calls/ - 2 - Young-Jin Kim SYSCALL_DEFINE 함수

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 KeyPad Device Control - Device driver Jo, Heeseung HBE-SM5-S4210 에는 16 개의 Tack Switch 를사용하여 4 행 4 열의 Keypad 가장착 4x4 Keypad 2 KeyPad 를제어하기위하여 FPGA 내부에 KeyPad controller 가구현 KeyPad controller 16bit 로구성된

More information

강의10

강의10 Computer Programming gdb and awk 12 th Lecture 김현철컴퓨터공학부서울대학교 순서 C Compiler and Linker 보충 Static vs Shared Libraries ( 계속 ) gdb awk Q&A Shared vs Static Libraries ( 계속 ) Advantage of Using Libraries Reduced

More information

Microsoft PowerPoint - chap6 [호환 모드]

Microsoft PowerPoint - chap6 [호환 모드] 제 6 장프로세스 (Process) 숙대창병모 1 내용 프로세스시작 / 종료 명령중인수 / 환경변수 메모리배치 / 할당 비지역점프 숙대창병모 2 프로세스시작 / 종료 숙대창병모 3 Process Start Kernel exec system call user process Cstart-up routine call return int main(int argc,

More information

untitled

untitled if( ) ; if( sales > 2000 ) bonus = 200; if( score >= 60 ) printf(".\n"); if( height >= 130 && age >= 10 ) printf(".\n"); if ( temperature < 0 ) printf(".\n"); // printf(" %.\n \n", temperature); // if(

More information

2009년 상반기 사업계획

2009년 상반기 사업계획 소켓프로그래밍활용 IT CookBook, 유닉스시스템프로그래밍 학습목표 소켓인터페이스를활용한다양한프로그램을작성할수있다. 2/23 목차 TCP 기반프로그래밍 반복서버 동시동작서버 동시동작서버-exec함수사용하기 동시동작서버-명령행인자로소켓기술자전달하기 UDP 프로그래밍 3/23 TCP 기반프로그래밍 반복서버 데몬프로세스가직접모든클라이언트의요청을차례로처리 동시동작서버

More information

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾ P a 02 r t Chapter 4 TCP Chapter 5 Chapter 6 UDP Chapter 7 Chapter 8 GUI C h a p t e r 04 TCP 1 3 1 2 3 TCP TCP TCP [ 4 2] listen connect send accept recv send recv [ 4 1] PC Internet Explorer HTTP HTTP

More information

02.Create a shellcode that executes "/bin/sh" Excuse the ads! We need some help to keep our site up. List Create a shellcode that executes "/bin/sh" C

02.Create a shellcode that executes /bin/sh Excuse the ads! We need some help to keep our site up. List Create a shellcode that executes /bin/sh C 02.Create a shellcode that executes "/bin/sh" Excuse the ads! We need some help to keep our site up. List Create a shellcode that executes "/bin/sh" C language Assembly code Change permissions(seteuid())

More information

<4D F736F F F696E74202D FB8DEB8F0B8AE20B8C5C7CE205BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D FB8DEB8F0B8AE20B8C5C7CE205BC8A3C8AF20B8F0B5E55D> 학습목표 통신프로그램이무엇인지이해한다. 을이용한 IPC 기법을이해한다. 함수를사용해프로그램을작성할수있다. IT CookBook, 유닉스시스템프로그래밍 2/20 목차 의개념 함수 해제함수 의보호모드변경 파일의크기확장 매핑된메모리동기화 데이터교환하기 의개념 파일을프로세스의메모리에매핑 프로세스에전달할데이터를저장한파일을직접프로세스의가상주소공간으로매핑 read, write

More information

K&R2 Reference Manual 번역본

K&R2 Reference Manual 번역본 typewriter structunion struct union if-else if if else if if else if if if if else else ; auto register static extern typedef void char short int long float double signed unsigned const volatile { } struct

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Network Programming Jo, Heeseung Network 실습 네트워크프로그래밍 멀리떨어져있는호스트들이서로데이터를주고받을수있도록프로그램을구현하는것 파일과는달리데이터를주고받을대상이멀리떨어져있기때문에소프트웨어차원에서호스트들간에연결을해주는장치가필요 이러한기능을해주는장치로소켓이라는인터페이스를많이사용 소켓프로그래밍이란용어와네트워크프로그래밍이랑용어가같은의미로사용

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 UNIX 및실습 8 장. 프로세스와사용자 명령익히기 1 학습목표 유닉스에서프로세스가무엇인지그개념을이해한다. 프로세스와관련된유닉스명령의사용방법을익힌다. 포그라운드처리와백그라운드처리의차이를이해한다. 사용자정보를보는명령의사용방법을익힌다. 2 01. 프로세스의개념과종류 프로세스 (process) 현재시스템에서실행중인프로그램 프로세스는고유번호를가진다. Process

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Web server porting 2 Jo, Heeseung Web 을이용한 LED 제어 Web 을이용한 LED 제어프로그램 web 에서데이터를전송받아타겟보드의 LED 를조작하는프로그램을작성하기위해다음과같은소스파일을생성 2 Web 을이용한 LED 제어 LED 제어프로그램작성 8bitled.html 파일을작성 root@ubuntu:/working/web# vi

More information

2009년 상반기 사업계획

2009년 상반기 사업계획 메모리매핑 IT CookBook, 유닉스시스템프로그래밍 학습목표 통신프로그램이무엇인지이해한다. 메모리매핑을이용한 IPC 기법을이해한다. 메모리매핑함수를사용해프로그램을작성할수있다. 2/20 목차 메모리매핑의개념 메모리매핑함수 메모리매핑해제함수 메모리매핑의보호모드변경 파일의크기확장 매핑된메모리동기화 데이터교환하기 3/20 메모리매핑의개념 메모리매핑 파일을프로세스의메모리에매핑

More information

Microsoft PowerPoint APUE(Intro).ppt

Microsoft PowerPoint APUE(Intro).ppt 컴퓨터특강 () [Ch. 1 & Ch. 2] 2006 년봄학기 문양세강원대학교컴퓨터과학과 APUE 강의목적 UNIX 시스템프로그래밍 file, process, signal, network programming UNIX 시스템의체계적이해 시스템프로그래밍능력향상 Page 2 1 APUE 강의동기 UNIX 는인기있는운영체제 서버시스템 ( 웹서버, 데이터베이스서버

More information

vi 사용법

vi 사용법 네트워크프로그래밍 6 장과제샘플코드 - 1:1 채팅 (udp 버전 ) 과제 서버에서먼저 bind 하고그포트를다른사람에게알려줄것 클라이언트에서알려준포트로접속 서로간에키보드입력을받아상대방에게메시지전송 2 Makefile 1 SRC_DIR =../../common 2 COM_OBJS = $(SRC_DIR)/addressUtility.o $(SRC_DIR)/dieWithMessage.o

More information

chap 5: Trees

chap 5: Trees 5. Threaded Binary Tree 기본개념 n 개의노드를갖는이진트리에는 2n 개의링크가존재 2n 개의링크중에 n + 1 개의링크값은 null Null 링크를다른노드에대한포인터로대체 Threads Thread 의이용 ptr left_child = NULL 일경우, ptr left_child 를 ptr 의 inorder predecessor 를가리키도록변경

More information

chap12(process).hwp

chap12(process).hwp 제 12 장프로세스 프로세스는파일과더불어유닉스운영체제가제공하는핵심개념중의하나이다. 유닉스시스템을깊이있게이해하기위해서는프로세스에대해정확히이해해야한다. 이장에서는프로그램이시작되는과정, 프로세스의구조, 프로세스생성및프로그램실행메커니즘, 프로세스사이의시그널등에대해서자세히살펴본다. 12.1 프로그램시작및종료 유닉스에서프로그램은어떻게실행이시작되고종료될까? 프로그램은 12.3절에서살펴볼

More information

The Pocket Guide to TCP/IP Sockets: C Version

The Pocket Guide to  TCP/IP Sockets: C Version 인터넷프로토콜 5 장 데이터송수신 (3) 1 파일전송메시지구성예제 ( 고정크기메시지 ) 전송방식 : 고정크기 ( 바이너리전송 ) 필요한전송정보 파일이름 ( 최대 255 자 => 255byte 의메모리공간필요 ) 파일크기 (4byte 의경우최대 4GB 크기의파일처리가능 ) 파일내용 ( 가변길이, 0~4GB 크기 ) 메시지구성 FileName (255bytes)

More information

untitled

untitled Step Motor Device Driver Embedded System Lab. II Step Motor Step Motor Step Motor source Embedded System Lab. II 2 open loop, : : Pulse, 1 Pulse,, -, 1 +5%, step Step Motor (2),, Embedded System Lab. II

More information

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

금오공대 컴퓨터공학전공 강의자료 C 프로그래밍프로젝트 Chap 14. 포인터와함수에대한이해 2013.10.09. 오병우 컴퓨터공학과 14-1 함수의인자로배열전달 기본적인인자의전달방식 값의복사에의한전달 val 10 a 10 11 Department of Computer Engineering 2 14-1 함수의인자로배열전달 배열의함수인자전달방식 배열이름 ( 배열주소, 포인터 ) 에의한전달 #include

More information

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C D616E2E637070>

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C D616E2E637070> #include "stdafx.h" #include "Huffman.h" 1 /* 비트의부분을뽑아내는함수 */ unsigned HF::bits(unsigned x, int k, int j) return (x >> k) & ~(~0

More information

Sena Technologies, Inc. HelloDevice Super 1.1.0

Sena Technologies, Inc. HelloDevice Super 1.1.0 HelloDevice Super 110 Copyright 1998-2005, All rights reserved HelloDevice 210 ()137-130 Tel: (02) 573-5422 Fax: (02) 573-7710 E-Mail: support@senacom Website: http://wwwsenacom Revision history Revision

More information

Microsoft PowerPoint - ch10 - 이진트리, AVL 트리, 트리 응용 pm0600

Microsoft PowerPoint - ch10 - 이진트리, AVL 트리, 트리 응용 pm0600 균형이진탐색트리 -VL Tree delson, Velskii, Landis에의해 1962년에제안됨 VL trees are balanced n VL Tree is a binary search tree such that for every internal node v of T, the heights of the children of v can differ by at

More information

Microsoft PowerPoint - chap10-함수의활용.pptx

Microsoft PowerPoint - chap10-함수의활용.pptx #include int main(void) { int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 중 값에 의한 전달 방법과

More information

Microsoft PowerPoint - [2009] 02.pptx

Microsoft PowerPoint - [2009] 02.pptx 원시데이터유형과연산 원시데이터유형과연산 원시데이터유형과연산 숫자데이터유형 - 숫자데이터유형 원시데이터유형과연산 표준입출력함수 - printf 문 가장기본적인출력함수. (stdio.h) 문법 ) printf( Test printf. a = %d \n, a); printf( %d, %f, %c \n, a, b, c); #include #include

More information

Microsoft PowerPoint oshw1.ppt [호환 모드]

Microsoft PowerPoint oshw1.ppt [호환 모드] 과제 1 : 기본이해 제출일 : 4월 10일 ( 목 ) 까지 과제내용» 연습문제풀이 1 1.6 2 2.8 3 3.8» 프로그래밍과제 4 $ ftp 211.119.245.75 (id: anonymous, passwd: 자기loginID) 또는 (id: ftp, passwd:ftp) 한다음 # cd pub 하고 # get p.c 하여 p 프로그램의 version

More information

Chap04(Signals and Sessions).PDF

Chap04(Signals and Sessions).PDF Signals and Session Management 2002 2 Hyun-Ju Park (Signal)? Introduction (1) mechanism events : asynchronous events - interrupt signal from users : synchronous events - exceptions (accessing an illegal

More information

13주-14주proc.PDF

13주-14주proc.PDF 12 : Pro*C/C++ 1 2 Embeded SQL 3 PRO *C 31 C/C++ PRO *C NOT! NOT AND && AND OR OR EQUAL == = SQL,,, Embeded SQL SQL 32 Pro*C C SQL Pro*C C, C Pro*C, C C 321, C char : char[n] : n int, short, long : float

More information

비트와바이트 비트와바이트 비트 (Bit) : 2진수값하나 (0 또는 1) 를저장할수있는최소메모리공간 1비트 2비트 3비트... n비트 2^1 = 2개 2^2 = 4개 2^3 = 8개... 2^n 개 1 바이트는 8 비트 2 2

비트와바이트 비트와바이트 비트 (Bit) : 2진수값하나 (0 또는 1) 를저장할수있는최소메모리공간 1비트 2비트 3비트... n비트 2^1 = 2개 2^2 = 4개 2^3 = 8개... 2^n 개 1 바이트는 8 비트 2 2 비트연산자 1 1 비트와바이트 비트와바이트 비트 (Bit) : 2진수값하나 (0 또는 1) 를저장할수있는최소메모리공간 1비트 2비트 3비트... n비트 2^1 = 2개 2^2 = 4개 2^3 = 8개... 2^n 개 1 바이트는 8 비트 2 2 진수법! 2, 10, 16, 8! 2 : 0~1 ( )! 10 : 0~9 ( )! 16 : 0~9, 9 a, b,

More information

03장.스택.key

03장.스택.key ---------------- DATA STRUCTURES USING C ---------------- 03CHAPTER 1 ? (stack): (LIFO:Last-In First-Out) 2 : top : ( index -1 ),,, 3 : ( ) ( ) -> ->. ->.... 4 Stack ADT : (LIFO) : init():. is_empty():

More information

BMP 파일 처리

BMP 파일 처리 BMP 파일처리 김성영교수 금오공과대학교 컴퓨터공학과 학습내용 영상반전프로그램제작 2 Inverting images out = 255 - in 3 /* 이프로그램은 8bit gray-scale 영상을입력으로사용하여반전한후동일포맷의영상으로저장한다. */ #include #include #define WIDTHBYTES(bytes)

More information

Microsoft PowerPoint oshw1&2.ppt [호환 모드]

Microsoft PowerPoint oshw1&2.ppt [호환 모드] 과제 1 : 기본이해 (4 월 8 일까지 ) 1. 1장 & 2장연습문제풀이 1 1.4 2 1.17 3 2.3 4 2.7 2. 프로그래밍과제 1» 연습문제 2.18 프로그램안에서가능한한많은 system call을사용한다. ptrace, dtrace 시스템호출추적방법은테스트한후수업시간에설명할예정이다. 3. 프로그래밍과제 2 ( 교재 p138 Chapter 3 프로젝트

More information

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100

Microsoft PowerPoint - ch09 - 연결형리스트, Stack, Queue와 응용 pm0100 2015-1 프로그래밍언어 9. 연결형리스트, Stack, Queue 2015 년 5 월 4 일 교수김영탁 영남대학교공과대학정보통신공학과 (Tel : +82-53-810-2497; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : ytkim@yu.ac.kr) 연결리스트 (Linked List) 연결리스트연산 Stack

More information

제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다.

제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 제 14 장포인터활용 유준범 (JUNBEOM YOO) Ver. 2.0 jbyoo@konkuk.ac.kr http://dslab.konkuk.ac.kr 본강의자료는생능출판사의 PPT 강의자료 를기반으로제작되었습니다. 이번장에서학습할내용 이중포인터란무엇인가? 포인터배열 함수포인터 다차원배열과포인터 void 포인터 포인터는다양한용도로유용하게활용될수있습니다. 2 이중포인터

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Text-LCD Device Control - Device driver Jo, Heeseung M3 모듈에장착되어있는 Tedxt LCD 장치를제어하는 App 을개발 TextLCD 는영문자와숫자일본어, 특수문자를표현하는데사용되는디바이스 HBE-SM5-S4210 의 TextLCD 는 16 문자 *2 라인을 Display 할수있으며, 이 TextLCD 를제어하기위하여

More information

Poison null byte Excuse the ads! We need some help to keep our site up. List 1 Conditions 2 Exploit plan 2.1 chunksize(p)!= prev_size (next_chunk(p) 3

Poison null byte Excuse the ads! We need some help to keep our site up. List 1 Conditions 2 Exploit plan 2.1 chunksize(p)!= prev_size (next_chunk(p) 3 Poison null byte Excuse the ads! We need some help to keep our site up. List 1 Conditions 2 Exploit plan 2.1 chunksize(p)!= prev_size (next_chunk(p) 3 Example 3.1 Files 3.2 Source code 3.3 Exploit flow

More information

untitled

untitled while do-while for break continue while( ) ; #include 0 i int main(void) int meter; int i = 0; while(i < 3) meter = i * 1609; printf("%d %d \n", i, meter); i++; return 0; i i< 3 () 0 (1)

More information

Chap06(Interprocess Communication).PDF

Chap06(Interprocess Communication).PDF Interprocess Communication 2002 2 Hyun-Ju Park Introduction (interprocess communication; IPC) IPC data transfer sharing data event notification resource sharing process control Interprocess Communication

More information

1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 #define _CRT_SECURE_NO_WARNINGS #include #include main() { char ch; printf(" 문자 1개를입력하시오 : "); scanf("%c", &ch); if (isalpha(ch))

More information

PowerPoint Template

PowerPoint Template BoF 원정대서비스 목차 환경구성 http://www.hackerschool.org/hs_boards/zboard.php?id=hs_notice&no=1170881885 전용게시판 http://www.hackerschool.org/hs_boards/zboard.php?id=bof_fellowship Putty War game 2 LOB 란? 해커스쿨에서제공하는

More information

Microsoft PowerPoint - chap06-2pointer.ppt

Microsoft PowerPoint - chap06-2pointer.ppt 2010-1 학기프로그래밍입문 (1) chapter 06-2 참고자료 포인터 박종혁 Tel: 970-6702 Email: jhpark1@snut.ac.kr 한빛미디어 출처 : 뇌를자극하는 C프로그래밍, 한빛미디어 -1- 포인터의정의와사용 변수를선언하는것은메모리에기억공간을할당하는것이며할당된이후에는변수명으로그기억공간을사용한다. 할당된기억공간을사용하는방법에는변수명외에메모리의실제주소값을사용하는것이다.

More information

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074>

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074> Chap #2 펌웨어작성을위한 C 언어 I http://www.smartdisplay.co.kr 강의계획 Chap1. 강의계획및디지털논리이론 Chap2. 펌웨어작성을위한 C 언어 I Chap3. 펌웨어작성을위한 C 언어 II Chap4. AT89S52 메모리구조 Chap5. SD-52 보드구성과코드메모리프로그래밍방법 Chap6. 어드레스디코딩 ( 매핑 ) 과어셈블리어코딩방법

More information

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

금오공대 컴퓨터공학전공 강의자료 C 프로그래밍프로젝트 Chap 13. 포인터와배열! 함께이해하기 2013.10.02. 오병우 컴퓨터공학과 13-1 포인터와배열의관계 Programming in C, 정재은저, 사이텍미디어. 9 장참조 ( 교재의 13-1 은읽지말것 ) 배열이름의정체 배열이름은 Compile 시의 Symbol 로서첫번째요소의주소값을나타낸다. Symbol 로서컴파일시에만유효함 실행시에는메모리에잡히지않음

More information

3. 다음장에나오는 sigprocmask 함수의설명을참고하여다음프로그램의출력물과그출력물이화면이표시되는시점을예측하세요. ( 힌트 : 각줄이표시되는시점은다음 6 가지중하나. (1) 프로그램수행직후, (2) 5 초후 (3) 10 초후 (4) 15 #include <signa

3. 다음장에나오는 sigprocmask 함수의설명을참고하여다음프로그램의출력물과그출력물이화면이표시되는시점을예측하세요. ( 힌트 : 각줄이표시되는시점은다음 6 가지중하나. (1) 프로그램수행직후, (2) 5 초후 (3) 10 초후 (4) 15 #include <signa 학번 : 이름 : 1. 다음가정하에서아래프로그램의출력물을예측하세요. 가정 : 부모프로세스의 process id=10100, 자식프로세스의 process id=10101. char buf[] = "a write to stdout\n"; int var; /* automatic variable on the stack */ pid_t pid; int glob = 31;

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Chapter 15 고급프로그램을 만들기위한 C... 1. main( ) 함수의숨겨진이야기 2. 헤더파일 3. 전처리문과예약어 1. main( ) 함수의숨겨진이야기 main( ) 함수의매개변수 [ 기본 14-1] main( ) 함수에매개변수를사용한예 1 01 #include 02 03 int main(int argc, char* argv[])

More information

Microsoft PowerPoint - chap12-고급기능.pptx

Microsoft PowerPoint - chap12-고급기능.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 가 제공하는 매크로 상수와 매크로

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 System Software Experiment 1 Lecture 5 - Array Spring 2019 Hwansoo Han (hhan@skku.edu) Advanced Research on Compilers and Systems, ARCS LAB Sungkyunkwan University http://arcs.skku.edu/ 1 배열 (Array) 동일한타입의데이터가여러개저장되어있는저장장소

More information

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

임베디드시스템설계강의자료 6 system call 1/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 임베디드시스템설계강의자료 6 system call 1/2 (2014 년도 1 학기 ) 김영진 아주대학교전자공학과 시스템호출개요 리눅스에서는사용자공간과커널공간을구분 사용자프로그램은사용자모드, 운영체제는커널모드에서수행 커널공간에대한접근은커널 ( 특권, priviledged) 모드에서가능 컴퓨팅자원 (CPU, memory, I/O 등 ) 을안전하게보호 커널수행을안전하게유지

More information

untitled

untitled int i = 10; char c = 69; float f = 12.3; int i = 10; char c = 69; float f = 12.3; printf("i : %u\n", &i); // i printf("c : %u\n", &c); // c printf("f : %u\n", &f); // f return 0; i : 1245024 c : 1245015

More information

Microsoft Word - Network Programming_NewVersion_01_.docx

Microsoft Word - Network Programming_NewVersion_01_.docx 10. Unix Domain Socket 105/113 10. Unix Domain Socket 본절에서는 Unix Domain Socket(UDS) 에대한개념과이에대한실습을수행하고, 이와동시에비신뢰적인통신시스템의문제점에대해서분석하도록한다. 이번실습의목표는다음과같다. 1. Unix Domain Socket의사용법을익히고, IPC에대해서실습 2. TCP/IP의응용계층과전달계층의동작을구현및실습

More information

슬라이드 1

슬라이드 1 7.4 프로세스간통신 Interprocess Communication 기본적인프로세스간통신기법 데이터스트림과파이프 data stream and pipe 정보의송수신에사용되는일련의연속된데이터 a sequence of data used to send or receive information 예 : 프로세스와파일 ( 파일디스크립터을통하여 ) 을연결해주는데이터스트림

More information

Microsoft PowerPoint - chap2

Microsoft PowerPoint - chap2 제 2 장. 파일입출력 (File I/O) 숙대창병모 1 목표 파일의구조및특성을이해한다. 파일을열고닫는다. 파일로부터데이터를읽고쓴다. 파일현재위치변경 기타파일제어 숙대창병모 2 2.1 파일구조 숙대창병모 3 What is a file? a file is a contiguous sequence of bytes no format imposed by the operating

More information

The Pocket Guide to TCP/IP Sockets: C Version

The Pocket Guide to  TCP/IP Sockets: C Version 얇지만얇지않은 TCP/IP 소켓프로그래밍 C 2 판 4 장 UDP 소켓 제 4 장 UDP 소켓 4.1 UDP 클라이언트 4.2 UDP 서버 4.3 UDP 소켓을이용한데이터송싞및수싞 4.4 UDP 소켓의연결 UDP 소켓의특징 UDP 소켓의특성 싞뢰할수없는데이터젂송방식 목적지에정확하게젂송된다는보장이없음. 별도의처리필요 비연결지향적, 순서바뀌는것이가능 흐름제어 (flow

More information

커알못의 커널 탐방기 이 세상의 모든 커알못을 위해서

커알못의 커널 탐방기 이 세상의 모든 커알못을 위해서 커알못의 커널 탐방기 2015.12 이 세상의 모든 커알못을 위해서 개정 이력 버전/릴리스 0.1 작성일자 2015년 11월 30일 개요 최초 작성 0.2 2015년 12월 1일 보고서 구성 순서 변경 0.3 2015년 12월 3일 오탈자 수정 및 글자 교정 1.0 2015년 12월 7일 내용 추가 1.1 2015년 12월 10일 POC 코드 삽입 및 코드

More information

Adobe Flash 취약점 분석 (CVE-2012-0754)

Adobe Flash 취약점 분석 (CVE-2012-0754) 기술문서 14. 08. 13. 작성 GNU C library dynamic linker $ORIGIN expansion Vulnerability Author : E-Mail : 윤지환 131ackcon@gmail.com Abstract 2010 년 Tavis Ormandy 에 의해 발견된 취약점으로써 정확한 명칭은 GNU C library dynamic linker

More information

Microsoft PowerPoint - chap4 [호환 모드]

Microsoft PowerPoint - chap4 [호환 모드] 제 5 장 C 표준라이브러리 숙대창병모 1 목표 C 표준라이브러리의깊이있는이해 시스템호출과 C 표준라이브러리관계 숙대창병모 2 C 입출력라이브러리함수 숙대창병모 3 시스템호출과라이브러리함수 System Calls well defined entry points directly into the kernel documented in section 2 of the

More information

3. 다음장에나오는 sigprocmask 함수의설명을참고하여다음프로그램의출력물과그출력물이화면이표시되는시점을예측하세요. ( 힌트 : 각줄이표시되는시점은다음 4 가지중하나. (1) 프로그램수행직후, (2) kill 명령실행직후, (3) 15 #include <signal.

3. 다음장에나오는 sigprocmask 함수의설명을참고하여다음프로그램의출력물과그출력물이화면이표시되는시점을예측하세요. ( 힌트 : 각줄이표시되는시점은다음 4 가지중하나. (1) 프로그램수행직후, (2) kill 명령실행직후, (3) 15 #include <signal. 학번 : 이름 : 1. 다음가정하에서아래프로그램의출력물을예측하세요. 가정 : 부모프로세스의 process id=20100, 자식프로세스의 process id=20101. int glob = 31; /* external variable in initialized data */ char buf[] = "a write to stdout\n"; int main(void)

More information

5.스택(강의자료).key

5.스택(강의자료).key CHP 5: https://www.youtube.com/watch?v=ns-r91557ds ? (stack): (LIFO:Last-In First-Out):. D C B C B C B C B (element) C (top) B (bottom) (DT) : n element : create() ::=. is_empty(s) ::=. is_full(s) ::=.

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 7-Segment Device Control - Device driver Jo, Heeseung HBE-SM5-S4210 의 M3 Module 에는 6 자리를가지는 7-Segment 모듈이아래그림처럼실장 6 Digit 7-Segment 2 6-Digit 7-Segment LED controller 16비트로구성된 2개의레지스터에의해제어 SEG_Sel_Reg(Segment

More information

컴파일러

컴파일러 YACC 응용예 Desktop Calculator 7/23 Lex 입력 수식문법을위한 lex 입력 : calc.l %{ #include calc.tab.h" %} %% [0-9]+ return(number) [ \t] \n return(0) \+ return('+') \* return('*'). { printf("'%c': illegal character\n",

More information

C 프로그래밍 언어 입문 C 프로그래밍 언어 입문 김명호저 숭실대학교 출판국 머리말..... C, C++, Java, Fortran, Python, Ruby,.. C. C 1972. 40 C.. C. 1999 C99. C99. C. C. C., kmh ssu.ac.kr.. ,. 2013 12 Contents 1장 프로그래밍 시작 1.1 C 10 1.2 12

More information

Microsoft PowerPoint - ch07 - 포인터 pm0415

Microsoft PowerPoint - ch07 - 포인터 pm0415 2015-1 프로그래밍언어 7. 포인터 (Pointer), 동적메모리할당 2015 년 4 월 4 일 교수김영탁 영남대학교공과대학정보통신공학과 (Tel : +82-53-810-2497; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : ytkim@yu.ac.kr) Outline 포인터 (pointer) 란? 간접참조연산자

More information

Microsoft PowerPoint - lab14.pptx

Microsoft PowerPoint - lab14.pptx Mobile & Embedded System Lab. Dept. of Computer Engineering Kyung Hee Univ. Keypad Device Control in Embedded Linux HBE-SM5-S4210 에는 16 개의 Tack Switch 를사용하여 4 행 4 열의 Keypad 가장착되어있다. 2 Keypad Device Driver

More information

휠세미나3 ver0.4

휠세미나3 ver0.4 andromeda@sparcs:/$ ls -al dev/sda* brw-rw---- 1 root disk 8, 0 2014-06-09 18:43 dev/sda brw-rw---- 1 root disk 8, 1 2014-06-09 18:43 dev/sda1 brw-rw---- 1 root disk 8, 2 2014-06-09 18:43 dev/sda2 andromeda@sparcs:/$

More information

<322EBCF8C8AF28BFACBDC0B9AEC1A6292E687770>

<322EBCF8C8AF28BFACBDC0B9AEC1A6292E687770> 연습문제해답 5 4 3 2 1 0 함수의반환값 =15 5 4 3 2 1 0 함수의반환값 =95 10 7 4 1-2 함수의반환값 =3 1 2 3 4 5 연습문제해답 1. C 언어에서의배열에대하여다음중맞는것은? (1) 3차원이상의배열은불가능하다. (2) 배열의이름은포인터와같은역할을한다. (3) 배열의인덱스는 1에서부터시작한다. (4) 선언한다음, 실행도중에배열의크기를변경하는것이가능하다.

More information

untitled

untitled - -, (insert) (delete) - - (insert) (delete) (top ) - - (insert) (rear) (delete) (front) A A B top A B C top push(a) push(b) push(c) A B top pop() top A B D push(d) top #define MAX_STACK_SIZE 100 int

More information

Microsoft PowerPoint APUE(File InO).pptx

Microsoft PowerPoint APUE(File InO).pptx Linux/UNIX Programming 문양세강원대학교 IT대학컴퓨터과학전공 강의목표및내용 강의목표 파일의특성을이해한다. 파일을열고닫는다. 파일로부터데이터를읽고쓴다. 기타파일제어함수를익힌다. 강의내용 파일구조 (UNIX 파일은어떤구조일까?) 파일관련시스템호출 시스템호출의효율과구조 Page 2 What is a File? A file is a contiguous

More information