Skip to content

Commit ae4024b

Browse files
author
seungwonme
committed
Update
1 parent 49fad26 commit ae4024b

File tree

12 files changed

+98
-4
lines changed

12 files changed

+98
-4
lines changed

GUIDE.md

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
<img src="https://cdn.inflearn.com/public/courses/328823/cover/1081d7c2-64b4-4063-87f4-c40e11bb481f/KakaoTalk_20220517_140737840.jpg?w=736" alt="Inflearn" style="width:300px;"/>
2424

25-
![]()
26-
2725
전반적인 흐름을 빠르게 익힐 때 사용했습니다.
2826

2927
## Books

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
55
## 01-Introduction
66
- [What is an Operating System?](md/os-01.md)
7+
8+
- [IPC(Inter-Process Communication)](ipc/README.md)

ipc/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Inter-Process Communication
2+

ipc/msg-queue/Dockerfile

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM alpine:3.20
2+
3+
RUN apk update && \
4+
apk add vim \
5+
gcc \
6+
g++ && \
7+
mkdir /app
8+
9+
WORKDIR /app
10+
11+
CMD while true; do sleep 100; done

ipc/msg-queue/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Message Queue

ipc/msg-queue/clean.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
docker rm -f alpine > /dev/null 2>&1 && docker rmi -f alpine > /dev/null 2>&1

ipc/msg-queue/run.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
3+
docker build -t alpine . && docker run -d --name alpine -v $(pwd)/src:/app alpine

ipc/msg-queue/src/receiver

71.5 KB
Binary file not shown.

ipc/msg-queue/src/receiver.cpp

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include <fcntl.h>
2+
#include <mqueue.h>
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
#include <string.h>
6+
#include <sys/stat.h>
7+
8+
int main()
9+
{
10+
mqd_t mq;
11+
char buffer[256];
12+
13+
// 메시지 큐 열기
14+
mq = mq_open("/myqueue", O_RDONLY);
15+
if (mq == -1)
16+
{
17+
perror("mq_open");
18+
exit(1);
19+
}
20+
21+
// 메시지 받기
22+
if (mq_receive(mq, buffer, 256, NULL) == -1)
23+
{
24+
perror("mq_receive");
25+
exit(1);
26+
}
27+
28+
printf("Message received: %s\n", buffer);
29+
30+
// 메시지 큐 닫기 및 삭제
31+
mq_close(mq);
32+
mq_unlink("/myqueue");
33+
return 0;
34+
}

ipc/msg-queue/src/sender

71.5 KB
Binary file not shown.

ipc/msg-queue/src/sender.cpp

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include <fcntl.h>
2+
#include <mqueue.h>
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
#include <string.h>
6+
#include <sys/stat.h>
7+
8+
int main()
9+
{
10+
mqd_t mq;
11+
struct mq_attr attr;
12+
char *msg = "Hello, Process 2!";
13+
14+
// 메시지 큐 속성 설정
15+
attr.mq_flags = 0;
16+
attr.mq_maxmsg = 10;
17+
attr.mq_msgsize = 256;
18+
attr.mq_curmsgs = 0;
19+
20+
// 메시지 큐 생성 및 열기
21+
mq = mq_open("/myqueue", O_CREAT | O_WRONLY, 0644, &attr);
22+
if (mq == -1)
23+
{
24+
perror("mq_open");
25+
exit(1);
26+
}
27+
28+
// 메시지 보내기
29+
if (mq_send(mq, msg, strlen(msg) + 1, 0) == -1)
30+
{
31+
perror("mq_send");
32+
exit(1);
33+
}
34+
35+
printf("Message sent: %s\n", msg);
36+
37+
// 메시지 큐 닫기
38+
mq_close(mq);
39+
return 0;
40+
}

md/os-01.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
[강의](https://core.ewha.ac.kr/publicview/C0101020140307151724641842?vmode=f)
2-
31
# 운영체제란
42

53
![](/img/os-01-01.png)
@@ -168,3 +166,5 @@ Multiprocess는 대규모 시스템에서 성능과 처리량을 향상시키는
168166
## 운영체제의 구조
169167

170168
![](/img/os-01-12.png)
169+
170+
[강의](https://core.ewha.ac.kr/publicview/C0101020140307151724641842?vmode=f)

0 commit comments

Comments
 (0)