1 / 6

foreground, background smallsh while (!EOF) { input command line; execute command; wait;

foreground, background smallsh while (!EOF) { input command line; execute command; wait; }. smallsh main (p153) userin (p146 ~ 147) - prompt 를 표시하고 입력인자를 읽음 procline  gettok (p149) - gettok 를 사용하여 토큰으로 분리한 후 , 유형 변수를 지정함 - <br>, &amp;, ;, argument

ronan-mejia
Download Presentation

foreground, background smallsh while (!EOF) { input command line; execute command; wait;

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. foreground, background • smallsh • while (!EOF) { • input command line; • execute command; • wait; • }

  2. smallsh • main (p153) • userin (p146 ~ 147) • - prompt를 표시하고 입력인자를 읽음 • procline  gettok (p149) • - gettok를 사용하여 토큰으로 분리한 후, 유형 변수를 지정함 • - \n, &, ;, argument • runcommand(p152) • - child process를 생성한 후 입력한 명령어를 수행시킴 • - foreground인 경우, child process가 종료할 때까지 기다림 • - background인 경우, 즉시 종료함

  3. 실습 • - smallsh을 수정하여 testdata를 출력하는 명령어를 수행할 수 있도록 함 • step1) argc와 argv를 이용하여 파일을 읽은후 출력할 수 있는 프로그램 작성 • > ./test8 testdata • 위의 명령어를 인식할 수 있도록 항상 실행은 ./로 시작 • step2) 위의 명령어에 대한 type을 정의함 • step3) runcommand를 사용하여 background와 foreground를 인식할 수 • 있도록 작성함 • 수정사항) smallsh.h에 type 정의 • userin.c의 gettok 함수를 정의된 type을 인식할 수 있도록 수정 • procline.c도 정의된 type을 가지는 arguments를 저장할 수 있도록 수정

  4. 프로세스 식별번호 • 프로세스 0 – 스와퍼 (스케쥴러) • 프로세스 1 – 초기화 프로세스 (init) • getpid(), getppid() • (예제) – p156 (test1.c) • (실습) – 연습문제 5.11(두 프로그램으로 구성) • 1) fork와 exec를 사용하여 gentemp를 수행하도록 함 • 2) gentemp는 파일 이름의 prefix를 인수로 입력 받도록 함

  5. 프로세스 그룹과 프로세스 그룹 식별번호 • 그림 5.5 (who | awk ‘{print $1}’ | sort –u) • 프로세스들의 한 집합을 한꺼번에 처리할 때 유리 • 프로세스 그룹은 프로세스 그룹 식별번호에 의해 표시 • 한 프로세스가 프로세스 그룹 식별번호와 동일한 pid를 가지고 있으면 • 리더로 간주 • getpgrp에 의해 프로세스 그룹 식별번호를 획득 • int setpgid(pid_t pid, pid_t pgid) • - 식별번호가 pid인 프로세스의 그룹 식별자를 pgid로 설정 • - pid가 0이면 호출 프로세스의 pid가 사용 • - pid와 pgid가 동일하면 리더로 설정 • - pgid가 0이면 pid가 프로세스 그룹 식별번호로 설정

  6. 환경 • name=something • showmyenv.c • setmyenv.c • getenv(), putenv() • getuid(), geteuid(), getgid(), getegid()

More Related