본문 바로가기

전체 글95

시그널 시그널 :커널 또는 프로세스에서 다른 프로세스에 어떤 이벤트가 발생되었는지 알려주는 기법 Ctrl + C 프로세스 종료 Ctrl + Z foreground 프로세스가 background 프로세스로 변경 (멈춤) SIGKILL SIGALARM SIGSTP SIGCONT SIGINT SIGSEGV kill -l : 시그널 리스트 출력 시그널 동작 제어 시그널 무시 시그널 블록 시그널 재정의 커널에서 기본동작 수행 int kill(pid_t pid, int sig); signal(SIGINT, SIG_IGN); --> 시그널 무시 signal(SIGINT, (void *)signal_handler); --> 재정의 &표시를 붙이면 background 실행 시그널과 프로세스 PCB에 해당 프로세스가 블록/처리해.. 2021. 7. 7.
ipcs / 공유 메모리 ipcs : 커널 공간에 어떤 IFC가 생성되어 있는 지 확인하는 명령어 shared memory : kernel에 메모리 공간을 만들고, 해당 공간을 변수처럼 쓰는 방식 해당 메모리 주소를 변수처럼 사용한다. 공유 메모리의 key를 가지고 여러 프로세스가 접근 가능하다. 공유 메모리 키 생성 int shmget(key_t key, size_t size, int shmflg); (이걸 shmid에 넣으면 된다.) 공유 메모리 연결 int *shmat (int shmid, const void *shmaddr, int shmflg) //shmid : shmget으로 생성한 식별자 //shmaddr : 연결 주소 (char *(NULL) 로 생성하면 알아서 찾아간다.) //shmflg //리턴값 : 성공 시 .. 2021. 7. 7.
structure - class 둘의 동작이 다르다. structure - copy class - share 2021. 7. 6.
IPC 기법 pipe int fd[2], pid, nbytes; parent에서 write (fd[1], msg, MSGSIZE) child에서 nbytes = read (fd[0], buf, MSGSIZE) message queue FIFO msqid = msgget (key, msgflg) //key는 int, msgflg는 option : message queue 생성 msgsnd(msqid, $sbuf, buf_length, IPC_NOWAIT) // block mode : 0 : message send msgrcv(msqid, *msgp, msgsz, msgtype, msgflg) : message receive ftok() : key 생성 함수 key_t ftok(const char *path, int i.. 2021. 7. 6.