1 / 4

고급 프로세스간 통신 message queue semaphore shared memory fcntl 을 사용한 레코드 록킹 - 읽기록 - 쓰기록

고급 프로세스간 통신 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). 고급 프로세스간 통신

Télécharger la présentation

고급 프로세스간 통신 message queue semaphore shared memory fcntl 을 사용한 레코드 록킹 - 읽기록 - 쓰기록

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. 고급 프로세스간 통신 • 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)

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

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

  4. deadlock (test2.c – p256) • 실습 • 파일 testfile의 0에서 4바이트까지 lock • fork를 호출하여 자식 프로세스 생성 • 자식 프로세스는 5에서 9바이트까지와 0 에서 4바이트까지를 lock하려고 시도한다. 두번째의 lock시도는 부모프로세스가 lock한 영역이므로 자식프로세스는 대기 • 부모프로세스는 sleep를 호출하여 10초간 휴면, 자식이 두 번의 lock을 수행할 수 있도록 한다. • 부모가 깨어나면 5 에서 9 바이트까지 lock을 시도한다

More Related