1 / 5

FIFO 와 이름형 파이프 파이프는 부모와 자식 프로세스와 같이 조상이 같은 프로세스들만 연결 파이프는 영구히 존재할 수 없음 com1 | com2 ( 그림 7.5)

FIFO 와 이름형 파이프 파이프는 부모와 자식 프로세스와 같이 조상이 같은 프로세스들만 연결 파이프는 영구히 존재할 수 없음 com1 | com2 ( 그림 7.5) mknod channel p cat < channel &; ls –al > channel int mkfifo (const char *pathname, mode_t mode); open (“/tmp/fifo”, O_WRONLY|O_NONBLOCK) 예제 – p 238 (rcvmessage.c, sendmessage.c). 실습

owen-roy
Download Presentation

FIFO 와 이름형 파이프 파이프는 부모와 자식 프로세스와 같이 조상이 같은 프로세스들만 연결 파이프는 영구히 존재할 수 없음 com1 | com2 ( 그림 7.5)

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. FIFO와 이름형 파이프 • 파이프는 부모와 자식 프로세스와 같이 조상이 같은 프로세스들만 연결 • 파이프는 영구히 존재할 수 없음com1 | com2 (그림 7.5) • mknod channel p • cat < channel &; ls –al > channel • int mkfifo (const char *pathname, mode_t mode); • open (“/tmp/fifo”, O_WRONLY|O_NONBLOCK) • 예제 – p 238 (rcvmessage.c, sendmessage.c)

  2. 실습 • client와 server와의 간단한 대화형 program • client가 입력한 내용을 server가 화면에 print

  3. 고급 프로세스간 통신 • message queue • semaphore • shared memory • fcntl 을 사용한 레코드 록킹 • -읽기록 • -쓰기록 • int fcntl(int filedes, int cmd, struct flock *ldata) • . cmd – F_GETLK, F_SETLK, F_SETLKW • . Ldata – l_type (F_RDLCK, F_WRLCK, F_UNLCK), l_whence, • off_t l_start, off_t l_len, pid_t l_pid)

  4. 고급 프로세스간 통신 • fcntl 을 사용한 레코드 록킹 • -예제 – p251 (test1.c) • -록 정보는 fork 호출에 의해 계승되지 않는다 • fcntl 호출의 파일포인터를 변경시키지 않는다 • 한 프로세스에 속한 모든 록은 그 프로세스가 죽을 때 자동적으로 제거

  5. 실습 • client는 argv로 받은 pipetest에 10byte록을 건 후, sleep(2), unlock • argv로 받은 filename을 fifo를 통해 server로 전달 • server는 filename에 해당하는 파일을 open, read, pipewrite • client는 server로부터 받은 내용을 화면으로 출력

More Related