예제코드 3

[IPC] shared memory 예제 코드

[IPC] shared memory 예제 코드 1. 구조 - 커널에서 제공하는 메모리를 이용한 프로세스가 데이터를 공유하는 구조이다. - 자세한 설명은 다음 포스트 참조 [프로세스간 통신] IPC(inter process communication) 종류 2. 예제 코드 (1) Header #ifndef __SHARE_MEMORY_H__ #define __SHARE_MEMORY_H__ #define SHM_INFO_COUNT 30 typedef struct _shm_info{ char str_ip[40]; unsigned int int_ip; unsigned int int_id; }SHM_INFOS; #endif//__SHARE_MEMORY_H__ (2) shared Memory Writing 코드 #in..

[IPC] pipe 예제 코드

[IPC] pipe 예제 코드 1. 구조 - 부모 프로세스와 자식 프로세스간에 통신을 할때 사용 한다. - 자세한 설명은 다음 포스트 참조 [프로세스간 통신] IPC(inter process communication) 종류 2. 예제 코드 #include #include #include #include int main(void) { int fd[2], nbytes, rc = 0; pid_t childpid; char string[] = "Hello, world!\n"; char readbuffer[80]; if ((rc = pipe(fd)) < 0) { printf("Creating Pipe is Error [%d]\n", rc); } if((childpid = fork()) == -1) { perror..

[IPC] 메모리 맵 mmap() 예제 코드

[IPC] 메모리 맵 mmap() 예제 코드 1. 구조 - 메모리 맵은 파일과 메모리를 직접 mapping일 시켜주는 구조로 이루어 져있다. - 자세한 설명은 다음 포스트 참조 [프로세스간 통신] IPC(inter process communication) 종류 2. 예제 코드 /* Copyright (C) * 2018 - doitnow-man * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the Licen..