분류 전체보기

    Pipe 사용 예시

    #include #include #include #include #include //for fork() #include // for wait() int main(int argc, char** argv) { int pipe_fds[2]; //size가 2인 int형 배열 pid_t pid; char buf[1024]; //파일 데이터를 담을 버퍼 int wstatus; printf("[%d] start of function\n", getpid()); memset(buf, 0, sizeof(buf));//초기화 if (pipe(pipe_fds)) {//파이프 생성 0아닌 값은 에러 perror("pipe()");// 에러 처리 return -1; } pid = fork(); if (pid == 0) { /*..

    Pipe와 Named Pipe

    Pipe - Uni-directional byte stream - name or ID가 없음 -> unrelated process 간 사용 불가능 - related process 간에 사용 가능 (ex. fork()) - 한 프로세스 당 read, write의 일방향적 Pipe fork() Pipe_fork())_Problem - 위 그림은 오류 존재. Parent Process가 Child Process에게 데이터를 전송하려 할 때, 자신이 write한 데이터를 read해버릴 수 있음 - Parent Process의 read fd와 Child Process의 write fd를 close 시켜 일방향성 유지 Pipe APIs int pipe(int pipefd[2]); - pipe 생성 파라미터 - pi..

    IPC란?

    IPC(Inter-Process-Communication) - 프로세스 간 통신 - 프로세스들 사이에서 데이터를 주고받는 행위 또는 그에 대한 방법, 경로(위키백과) IPC 3가지 형태 - Data transfer: 프로세스간 직접적으로 데이터를 전송하는 매커니즘 - Shared memory: 두 프로세스가 메모리를 공유하는 방법 - Synchronization(동기화): 두 개 이상의 프로세스가 공유 자원을 사용할 때 동시에 접근해서 일어나는 오류를 방지하기 위해 규칙을 적용하는 매커니즘