다시 thread로 돌아왔다. #include <stdlib.h> #include <stdio.h> #include <string.h> #include <pthread.h> #define MAXNITEMS 1000000 #define MAXNTHREADS 100 #define MIN(X,Y) ((X)<(Y) ? (X) : (Y)) //gcc -lpthread 옵션으로 컴파일. int nitems; /* read-only by producer and consumer */ //shared를 초기화 하는데, //맨 처음에 mutext가 있음. //나머지는 0으로 초기화됨.. struct { pthread_mutex_t mutex; int buff[MAXNITEMS]; int nput;…… sync, mutex. unix network programming p161 계속 읽기


fifo 예제. unix network programming 55p
pipe는 이름을 없어 parent, child process만 통신이 가능하다. 이를 보안한게 named pipe인데, fifo라고도 한다. 책은 다른 유닉스 버전으로 작성하여, linux에 맞게 수정했다. 결론적으로 pipe와 비슷하고 더 쉽다. #include <stdlib.h> #include <stdio.h> #include <errno.h> #include <unistd.h> #include <sys/types.h> #include <fcntl.h> #include <sys/wait.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> #define FIFO1 “/tmp/fifo.1” #define FIFO2 “/tmp/fifo.2” #define MAXLINE…… fifo 예제. unix network programming 55p 계속 읽기
pipe 예제. unix network programming 47p
pipe를 이해하기 전, 일단 gdb를 사용하는 방법을 알아야 했다. pipe가 서로 다른 프로세스를 연결하는 수단이라, gdb 기본 설정으로는 pipe로 어떤 내용을 확인하기 어려웠다. 아래 코드를 디버그 하기로 했다. #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <string.h> #define MAXLINE 100 void client(int, int), server(int, int); void server(int readfd, int writefd){ char buff[MAXLINE];…… pipe 예제. unix network programming 47p 계속 읽기
자율적 자가 격리 썰
호텔이 다 좋은데 유선 인터넷이 없다. 벽에 cat 6라고 정확하게 적혀있어 랜 선을 꼽았다. 제길, 머텅구리 포트다. 왜 멍텅구리 포트를 2개나 방에 설치했는지 모르겠다. 이런 ㅅㅂ.. 전에 가격을 최대한 줄여 만든 종이박스 PC를 인터넷에 물릴 수 없었다. 지금 와이파이 모듈을 사면 PC 값 나올까봐 연결하지 않았다. 고민 끝에 휴대폰 테더링으로 인터넷에 연결했다. 속도 700KBps는 너무나…… 자율적 자가 격리 썰 계속 읽기