epoll 실전 — LT·ET·ONESHOT·EXCLUSIVE 비교
#한 줄 요약
“epoll = 등록한 fd 수가 아니라 준비된 fd 수만큼 일하는 multiplex.”
select·poll은 호출할 때마다 감시할 fd 전체를 넘기고 훑지만, epoll은 관심 목록을 커널에 한 번 등록해 두고 준비된 fd만 돌려받습니다. 이 글의 모든 출력과 시간은 Debian 13 arm64 VM(커널6.12.116+deb13-arm64, gcc 14.2.0)에서 직접 돌린 결과입니다.
#어떤 상황에서 쓰나
게이트웨이 하나가 수천 개의 TCP 연결을 동시에 들고 있고, 그중 데이터가 오는 연결은 몇 개뿐인 상황이 있습니다. select는 fd 번호가 FD_SETSIZE(1024)보다 작은 fd만 감시할 수 있고, man page가 이 한계는 바뀌지 않는다고 적습니다(select(2), man-pages 6.9.1). poll은 그 제한이 없지만 매번 배열 전체를 커널에 넘깁니다. 아래 측정에서 2만 개 fd 중 하나만 준비됐을 때 poll은 호출당 1 ms가 넘었고 epoll은 1.5 µs였습니다.
임베디드 daemon에서도 쓸모가 큽니다. timerfd·signalfd·eventfd·socket을 epoll 하나에 묶으면 thread 하나의 event loop에서 타이머·signal·다른 thread의 알림·네트워크를 함께 처리합니다. 우체국 창구 직원이 번호표 기계 하나만 보고 있다가 호출된 번호만 응대하는 것과 같습니다.
#핵심 개념
epoll은 커널이 관리하는 관심 fd 집합 위에서 동작합니다.
| 호출 | 하는 일 |
|---|---|
epoll_create1(flags) | 관심 집합(epoll 인스턴스) 생성 |
epoll_ctl(epfd, ADD/MOD/DEL, fd, &ev) | 멤버 추가·변경·삭제 |
epoll_wait(epfd, events, n, timeout) | 준비된 fd만 회수 |
알림 방식은 두 가지입니다. Level-Triggered(LT, 기본값)는 fd가 준비된 상태인 동안 epoll_wait마다 계속 알립니다. Edge-Triggered(ET, EPOLLET)는 상태가 바뀌는 순간에만 알리므로, 한 번 깨면 EAGAIN이 날 때까지 비워야 다음 알림을 받습니다. 초인종(ET)은 누른 순간 한 번 울리고, 문 앞에 쌓인 택배(LT)는 치울 때까지 보입니다.
추가 플래그 두 개를 자주 씁니다. EPOLLONESHOT은 이벤트를 한 번 알린 뒤 그 fd를 비활성으로 돌려, 다시 EPOLL_CTL_MOD로 켤 때까지 알리지 않습니다. EPOLLEXCLUSIVE(Linux 4.5부터)는 같은 fd를 여러 epoll 인스턴스가 감시할 때 전부가 아니라 “하나 이상”만 깨워, thundering herd를 줄이는 용도라고 man page가 적습니다(epoll_ctl(2)).
#코드 / 실제 사용 예
아래 프로그램 하나로 LT·ET, ONESHOT, close와 dup, thundering herd, timerfd·eventfd·signalfd loop를 차례로 확인했습니다. 함수마다 한 가지 성질을 보여 주므로 필요한 함수만 떼어 써도 됩니다.
#define _GNU_SOURCE#include <arpa/inet.h>#include <errno.h>#include <fcntl.h>#include <pthread.h>#include <signal.h>#include <stdatomic.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/epoll.h>#include <sys/eventfd.h>#include <sys/signalfd.h>#include <sys/socket.h>#include <sys/timerfd.h>#include <unistd.h>
static int add(int ep, int fd, unsigned ev){ struct epoll_event e = { .events = ev, .data.fd = fd }; return epoll_ctl(ep, EPOLL_CTL_ADD, fd, &e);}
/* 1) LT vs ET when the handler reads only part of the data */static void partial(unsigned mode, const char *name){ int p[2]; pipe2(p, O_NONBLOCK); int ep = epoll_create1(0); add(ep, p[0], EPOLLIN | mode); write(p[1], "0123456789012345678901234567890123456789", 40); int wakes = 0, got = 0; char b[10]; struct epoll_event e; while (epoll_wait(ep, &e, 1, 100) == 1) { /* 100 ms timeout */ wakes++; got += read(p[0], b, sizeof b); /* only 10 bytes */ } printf("%s: wakeups=%d bytes read=%d of 40\n", name, wakes, got); close(ep); close(p[0]); close(p[1]);}
/* 2) ONESHOT: no second event until EPOLL_CTL_MOD */static void oneshot(void){ int p[2]; pipe2(p, O_NONBLOCK); int ep = epoll_create1(0); add(ep, p[0], EPOLLIN | EPOLLONESHOT); write(p[1], "xx", 2); struct epoll_event e; int a = epoll_wait(ep, &e, 1, 100); int b = epoll_wait(ep, &e, 1, 100); /* still readable, but disarmed */ struct epoll_event re = { .events = EPOLLIN | EPOLLONESHOT, .data.fd = p[0] }; epoll_ctl(ep, EPOLL_CTL_MOD, p[0], &re); int c = epoll_wait(ep, &e, 1, 100); printf("ONESHOT: first=%d second=%d after MOD=%d\n", a, b, c); close(ep); close(p[0]); close(p[1]);}
/* 3) close() with a dup alive: the registration stays */static void dupclose(void){ int p[2]; pipe2(p, O_NONBLOCK); int ep = epoll_create1(0); add(ep, p[0], EPOLLIN); int d = dup(p[0]); close(p[0]); /* the dup keeps the file alive */ write(p[1], "x", 1); struct epoll_event e; int n = epoll_wait(ep, &e, 1, 100); printf("close+dup: epoll_wait=%d, reported fd=%d (closed number), dup is fd %d\n", n, n == 1 ? e.data.fd : -1, d); int r = epoll_ctl(ep, EPOLL_CTL_DEL, d, NULL); printf("EPOLL_CTL_DEL with the dup: %d (%s)\n", r, r ? strerror(errno) : "ok"); close(ep); close(d); close(p[1]);}
/* 4) thundering herd on a listening socket */static int lfd;static atomic_int woke, accepted;static void *worker(void *arg){ unsigned flags = *(unsigned *)arg; int ep = epoll_create1(0); add(ep, lfd, EPOLLIN | flags); struct epoll_event e; for (;;) { if (epoll_wait(ep, &e, 1, 300) == 0) break; atomic_fetch_add(&woke, 1); int c = accept(lfd, NULL, NULL); if (c >= 0) { atomic_fetch_add(&accepted, 1); close(c); } usleep(1000); /* let others race too */ } close(ep); return NULL;}static void herd(unsigned flags, const char *name){ enum { W = 8, CONNS = 50 }; struct sockaddr_in a = { .sin_family = AF_INET, .sin_addr.s_addr = htonl(INADDR_LOOPBACK) }; lfd = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0); bind(lfd, (void *)&a, sizeof a); listen(lfd, 128); socklen_t al = sizeof a; getsockname(lfd, (void *)&a, &al); woke = accepted = 0; pthread_t t[W]; for (int i = 0; i < W; i++) pthread_create(&t[i], NULL, worker, &flags); usleep(50000); for (int i = 0; i < CONNS; i++) { int c = socket(AF_INET, SOCK_STREAM, 0); connect(c, (void *)&a, sizeof a); close(c); usleep(5000); } for (int i = 0; i < W; i++) pthread_join(t[i], NULL); printf("%s: %d workers, %d connections -> %d wakeups, %d accepted\n", name, W, CONNS, woke, accepted); close(lfd);}
/* 5) one loop for timerfd, eventfd, signalfd */static void loop(void){ int ep = epoll_create1(EPOLL_CLOEXEC); int tfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC); struct itimerspec it = { { 0, 100000000 }, { 0, 100000000 } }; /* 100 ms */ timerfd_settime(tfd, 0, &it, NULL); int efd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); sigset_t m; sigemptyset(&m); sigaddset(&m, SIGTERM); sigprocmask(SIG_BLOCK, &m, NULL); int sfd = signalfd(-1, &m, SFD_NONBLOCK | SFD_CLOEXEC); add(ep, tfd, EPOLLIN); add(ep, efd, EPOLLIN); add(ep, sfd, EPOLLIN); int ticks = 0, sent_ev = 0, sent_sig = 0; for (;;) { struct epoll_event e; epoll_wait(ep, &e, 1, -1); if (e.data.fd == tfd) { uint64_t n; read(tfd, &n, 8); ticks += n; if (ticks >= 3 && !sent_ev) { sent_ev = 1; uint64_t one = 1; write(efd, &one, 8); } if (ticks >= 5 && !sent_sig) { sent_sig = 1; kill(getpid(), SIGTERM); } } else if (e.data.fd == efd) { uint64_t v; read(efd, &v, 8); printf("loop: eventfd %llu at tick %d\n", (unsigned long long)v, ticks); } else if (e.data.fd == sfd) { struct signalfd_siginfo si; read(sfd, &si, sizeof si); printf("loop: signal %d (%s) at tick %d, leaving\n", si.ssi_signo, strsignal(si.ssi_signo), ticks); break; } }}
int main(void){ setvbuf(stdout, NULL, _IONBF, 0); partial(0, "LT"); partial(EPOLLET, "ET"); oneshot(); dupclose(); herd(0, "no EXCLUSIVE"); herd(EPOLLEXCLUSIVE, "EPOLLEXCLUSIVE"); loop(); return 0;}gcc -O2 -Wall -pthread -o ep ep.c && ./epLT: wakeups=4 bytes read=40 of 40ET: wakeups=1 bytes read=10 of 40ONESHOT: first=1 second=0 after MOD=1close+dup: epoll_wait=1, reported fd=3 (closed number), dup is fd 6EPOLL_CTL_DEL with the dup: -1 (No such file or directory)no EXCLUSIVE: 8 workers, 50 connections -> 50 wakeups, 50 acceptedEPOLLEXCLUSIVE: 8 workers, 50 connections -> 50 wakeups, 50 acceptedloop: eventfd 1 at tick 3loop: signal 15 (Terminated) at tick 5, leaving#LT와 ET — 일부만 읽는 handler
partial()은 pipe에 40바이트를 써 두고, 깨어날 때마다 10바이트만 읽습니다. LT는 남은 데이터가 있는 동안 계속 깨워 네 번 만에 40바이트를 모두 읽었습니다. ET는 처음 한 번만 깨웠고, 30바이트가 pipe에 남아 있는데도 100 ms 동안 다시 알리지 않았습니다. ET handler는 EAGAIN을 볼 때까지 읽어야 하고, 그러려면 fd가 non-blocking이어야 합니다. Blocking fd에서 “빌 때까지 읽기”를 하면 마지막 read가 EAGAIN 대신 잠들어 버립니다.
#EPOLLONESHOT — worker pool에서 한 fd를 한 번만
ONESHOT으로 등록한 fd는 첫 epoll_wait에서 알린 뒤, 데이터가 남아 있어도 두 번째 epoll_wait에서는 0이었습니다. EPOLL_CTL_MOD로 다시 켠 뒤에야 다시 알렸습니다. 여러 thread가 같은 epoll fd로 epoll_wait를 부르는 worker pool에서, 한 연결을 두 thread가 동시에 처리하지 않게 하는 장치가 이것입니다. 처리를 끝낸 thread가 MOD로 다시 켭니다.
#close와 dup
dupclose()는 fd를 등록하고 dup한 뒤 원래 fd를 닫았습니다. 닫은 fd 번호(3)로 여전히 이벤트가 왔고, dup한 fd로 EPOLL_CTL_DEL을 하면 ENOENT였습니다. man page는 같은 open file description을 가리키는 fd가 모두 닫혀야 관심 목록에서 빠진다고 설명하고, 그래서 dup 하기 전에 EPOLL_CTL_DEL로 빼라고 적습니다(epoll(7) Q&A “Will closing a file descriptor cause it to be removed from all epoll interest lists?”). 원래 fd가 아직 열려 있다면 close 전에 그 fd로 EPOLL_CTL_DEL을 해도 빠졌습니다(같은 VM에서 반환값 0, 이후 epoll_wait 0). dup한 fd로 지우면 ENOENT인 이유는, 커널이 관심 목록 항목을 (open file description, 등록할 때의 fd 번호) 쌍으로 찾기 때문입니다(v6.12 fs/eventpoll.c의 ep_cmp_ffd·ep_find).
#EPOLLEXCLUSIVE — accept thundering herd
herd()는 thread 8개가 각자 epoll 인스턴스로 같은 listening socket을 감시하게 하고, 연결 50개를 5 ms 간격으로 보냈습니다. 위 출력의 실행에서는 두 경우 모두 epoll_wait가 50번 돌아왔습니다. 같은 프로그램의 앞선 실행에서는 EPOLLEXCLUSIVE 없이 81번이었고(나머지 31번은 accept가 EAGAIN), 독립 검증으로 여섯 번 더 돌렸을 때 5680번이었습니다. 31번으로 흔들렸고, EPOLLEXCLUSIVE로는 매번 정확히 50번이었습니다. 즉 이 조건(thread 8개, 연결 5 ms 간격)에서 차이는 실행마다 0EPOLLEXCLUSIVE는 그 흔들림을 없앴습니다. 세는 값은 epoll_wait가 이벤트를 돌려준 횟수이고, 커널 안에서 깼다가 이벤트 없이 다시 잠든 횟수는 들어 있지 않습니다. 여러 process가 각자 socket을 열어 커널이 연결을 나눠 주게 하는 SO_REUSEPORT는 다른 방식이고, 이 글에서는 재지 않았습니다.
#timerfd·eventfd·signalfd를 한 loop에
loop()는 100 ms 주기 timerfd, eventfd, SIGTERM을 받는 signalfd를 한 epoll에 등록합니다. 세 번째 tick에서 eventfd에 1을 쓰고, 다섯 번째 tick에서 자기에게 SIGTERM을 보냈습니다. 출력대로 eventfd 알림과 signal이 모두 같은 epoll_wait loop로 들어왔습니다. signalfd로 받을 signal은 sigprocmask로 막아 두어야 기본 동작(SIGTERM이면 종료)이 먼저 일어나지 않습니다.
#io_uring과의 관계
epoll은 “읽을 수 있다”는 준비 알림만 주고 실제 read·write는 프로그램이 따로 부릅니다. io_uring은 read·write 같은 작업 자체를 제출하고 완료를 받는 인터페이스입니다. 이 글에서는 io_uring을 재지 않았습니다.
#측정 / 성능 비교
fd 수를 바꿔 가며, 매 반복마다 임의의 pipe 하나에 1바이트를 쓰고 그것을 기다려 읽는 데 걸린 시간을 쟀습니다(2만 회 평균). select·poll은 호출 때마다 집합 전체를 넘기고 결과 전체를 훑으며, epoll은 등록을 한 번만 하고 준비된 fd 하나만 받습니다.
#define _GNU_SOURCE#include <fcntl.h>#include <poll.h>#include <stdio.h>#include <stdlib.h>#include <sys/epoll.h>#include <sys/select.h>#include <time.h>#include <unistd.h>
static double now(void){ struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return ts.tv_sec + ts.tv_nsec / 1e9;}
int main(int argc, char **argv){ int n = atoi(argv[1]), iters = 20000; int (*p)[2] = malloc(sizeof(*p) * n); for (int i = 0; i < n; i++) pipe2(p[i], O_NONBLOCK); int maxfd = p[n - 1][1]; char c; srand(1);
/* select: rebuild the set every call, scan up to maxfd */ double sel = -1; if (maxfd < FD_SETSIZE) { double t0 = now(); for (int k = 0; k < iters; k++) { int r = rand() % n; write(p[r][1], "x", 1); fd_set s; FD_ZERO(&s); for (int i = 0; i < n; i++) FD_SET(p[i][0], &s); select(maxfd + 1, &s, NULL, NULL, NULL); for (int i = 0; i < n; i++) if (FD_ISSET(p[i][0], &s)) read(p[i][0], &c, 1); } sel = (now() - t0) / iters * 1e6; }
/* poll: pass the whole array every call */ struct pollfd *pf = calloc(n, sizeof *pf); for (int i = 0; i < n; i++) { pf[i].fd = p[i][0]; pf[i].events = POLLIN; } double t0 = now(); for (int k = 0; k < iters; k++) { int r = rand() % n; write(p[r][1], "x", 1); poll(pf, n, -1); for (int i = 0; i < n; i++) if (pf[i].revents) read(pf[i].fd, &c, 1); } double pol = (now() - t0) / iters * 1e6;
/* epoll: register once, get only the ready fd back */ int ep = epoll_create1(0); for (int i = 0; i < n; i++) { struct epoll_event e = { .events = EPOLLIN, .data.fd = p[i][0] }; epoll_ctl(ep, EPOLL_CTL_ADD, p[i][0], &e); } t0 = now(); for (int k = 0; k < iters; k++) { int r = rand() % n; write(p[r][1], "x", 1); struct epoll_event e; epoll_wait(ep, &e, 1, -1); read(e.data.fd, &c, 1); } double epl = (now() - t0) / iters * 1e6;
if (sel < 0) printf("n=%5d select: n/a (fd %d >= FD_SETSIZE %d) poll: %8.2f us epoll: %6.2f us\n", n, maxfd, FD_SETSIZE, pol, epl); else printf("n=%5d select: %8.2f us poll: %8.2f us epoll: %6.2f us\n", n, sel, pol, epl); return 0;}gcc -O2 -Wall -o scale scale.culimit -n 65536for n in 10 100 500 5000 20000; do ./scale $n; donen= 10 select: 0.83 us poll: 0.78 us epoll: 0.52 usn= 100 select: 4.16 us poll: 7.41 us epoll: 0.54 usn= 500 select: 20.51 us poll: 17.50 us epoll: 0.61 usn= 5000 select: n/a (fd 10002 >= FD_SETSIZE 1024) poll: 186.98 us epoll: 0.91 usn=20000 select: n/a (fd 40002 >= FD_SETSIZE 1024) poll: 1035.84 us epoll: 1.53 uspipe 하나가 fd 두 개라서 pipe 5000개면 fd 번호가 10002까지 갑니다. select는 FD_SETSIZE를 넘는 fd를 다룰 수 없어 측정하지 않았습니다. poll은 fd 수에 거의 비례해 늘었고(500개에서 17.50 µs, 2만 개에서 1035.84 µs), epoll은 2만 개에서도 1.53 µs였습니다. fd가 10개뿐일 때는 세 방식의 차이가 1 µs 안이므로, fd가 적은 프로그램이라면 어느 쪽을 써도 이 비용은 문제가 되지 않습니다. 같은 VM에서 다른 빌드 작업이 돌던 상태(load average 8 안팎)에서 한 번 잰 값입니다.
#자주 보는 함정
⚠️ ET에서 한 번만 읽음
위 ET: wakeups=1 bytes read=10 of 40처럼, 남은 데이터가 있어도 다음 알림이 오지 않습니다. ET에서는 EAGAIN이 날 때까지 읽어야 합니다.
⚠️ Blocking fd에 ET
ET의 “빌 때까지 읽기” loop는 EAGAIN으로 끝나야 하는데, blocking fd의 마지막 read는 EAGAIN을 돌려주지 않고 잠듭니다. ET로 등록하는 fd는 O_NONBLOCK으로 엽니다(위 코드는 pipe2(..., O_NONBLOCK)).
⚠️
dup한 fd가 남아 있는데close만 함
위 close+dup 출력처럼 닫은 번호로 이벤트가 계속 오고, dup한 fd로는 EPOLL_CTL_DEL이 ENOENT입니다. close 전에 등록한 그 fd로 EPOLL_CTL_DEL을 합니다.
⚠️ 여러 thread가 ONESHOT 없이 같은 epoll fd를 기다림
같은 VM에서 thread 4개가 한 epoll fd를 기다리고 1바이트를 읽지 않은 채 두었더니, LT는 4개 모두 이벤트를 받았고 EPOLLET과 EPOLLONESHOT은 1개만 받았습니다. 처리 중인 연결을 다른 thread가 건드리지 않게 하려면 EPOLLONESHOT과 처리 후 EPOLL_CTL_MOD를 씁니다.
⚠️ listening socket의 thundering herd
위 실험의 한 실행에서 EPOLLEXCLUSIVE 없이는 연결 50개에 epoll_wait가 81번 돌아왔습니다. 돌아온 thread 중 하나만 accept에 성공하고 나머지는 EAGAIN을 받습니다. EPOLLEXCLUSIVE로 등록하면 모든 실행에서 연결 수만큼만 돌아왔습니다.
#정리
- epoll은 관심 목록을 커널에 두고 준비된 fd만 돌려줍니다. 이 측정에서 2만 fd 중 하나가 준비됐을 때
poll은 1 ms가 넘었고 epoll은 1.5 µs였습니다. select는FD_SETSIZE(1024) 미만의 fd 번호만 다룹니다.- LT는 남은 데이터가 있는 동안 계속 알리고, ET는 바뀌는 순간 한 번만 알립니다. ET에서는 non-blocking fd로
EAGAIN까지 읽어야 합니다. - ONESHOT은 한 번 알린 fd를
MOD로 다시 켤 때까지 끕니다. - epoll 등록은 (open file description, 등록한 fd 번호) 쌍으로 잡히므로,
dup이 남아 있으면close로 빠지지 않고dup한 번호로는 지울 수도 없습니다. EPOLLEXCLUSIVE는 같은 fd를 감시하는 여러 epoll 인스턴스 전부가 아니라 하나 이상만 깨웁니다(epoll_ctl(2)).- timerfd·eventfd·signalfd를 한 epoll에 묶으면 thread 하나의 loop로 타이머·알림·signal을 함께 처리합니다.
다음 편은 UIO·VFIO입니다.
#관련 항목
- 7-07: 캐릭터 드라이버 — driver 쪽
.poll구현 - 7-09: mmap
- 12-10: Zero-Copy
- PE 5-04: eBPF
Modern Embedded Recipes · 85 of 153 전체 목차 접기
- 1 Modern Embedded Recipes — 모던 임베디드 실전 레시피 시리즈 소개
- 2 디지털 신호 기초 — Voltage Level·Edge·Noise Margin·반사 분석
- 3 임베디드 클럭과 타이밍 — Skew·Jitter·PLL 분석
- 4 GPIO 내부 구조 분해 — Push-Pull·Open-Drain·Schmitt Trigger
- 5 UART 하드웨어 동작 분석 — Baud Rate·Framing·FIFO
- 6 SPI 하드웨어 분석 — Clock Mode·MOSI/MISO·Chip Select
- 7 I2C 하드웨어 분석 — Open-Drain·Clock Stretching·Arbitration
- 8 ADC 동작 원리 — SAR·Sigma-Delta 비교
- 9 DAC 동작 원리 — R-2R Ladder·Sigma-Delta·Settling Time
- 10 PWM 신호 생성 분석 — Duty·Frequency·Dead Time·Center-Aligned
- 11 CAN 버스 전기적 특성 — 종단·전압 레벨·GND 전위차와 1 Mbit/s 버스 길이 예산
- 12 RS-485·RS-422 차동 신호 분석 — Termination·Biasing·Topology
- 13 LVDS 차동 신호 분석 — Common-Mode·Impedance·Eye Pattern
- 14 ARM Cortex-M 시리즈 비교 — M0·M3·M4·M7·M33·M55 분석
- 15 ARM Cortex-A 시리즈 비교 — A53·A55·A72·A78·X1 분석
- 16 Cortex-M 레지스터 구조 분석 — R0~R15·xPSR·CONTROL·Mask Registers
- 17 Cortex-M4 예외 처리 — Vector Table·NVIC 우선순위·Tail-Chaining
- 18 ARM 메모리 맵 분석 — Normal·Device·Strongly-Ordered Region
- 19 Cortex-M7 캐시와 DMA — Cache Line·Write-Back·Clean/Invalidate 순서
- 20 Cortex-M4 MPU 활용 — Region 배치·Stack Guard·Task 격리
- 21 AArch64 Linux MMU 기초 — Translation Table·TLB·ASID
- 22 ARM TrustZone-M 기초 — Secure/Non-Secure·NSC·MPC
- 23 ARM Memory Barrier 실전 — DMB·DSB·ISB·DMA·MMIO
- 24 임베디드 크로스 컴파일러 분석 — GCC·Clang·Sysroot 구성
- 25 C 컴파일 4단계 — Preprocess·Compile·Assemble·Link 추적
- 26 ELF 파일 구조 분석 — Section·Segment·Symbol Table·DWARF
- 27 링커 스크립트 기초 — SECTIONS·MEMORY·entry point
- 28 링커 스크립트 고급 — Overlay·BSS·init_array·LMA/VMA
- 29 임베디드 스타트업 코드 분석 — Reset_Handler·Vector Table·SystemInit
- 30 C 런타임 crt0 분석 — Stack·BSS Zero·Data Copy·atexit
- 31 임베디드 메모리 레이아웃 — .text·.rodata·.data·.bss·.heap·.stack
- 32 임베디드 컴파일러 최적화 분석 — -O0~-O3·-Os·-LTO 비교
- 33 Map 파일 분석 — 링커가 넣은 것, 끌어온 이유, 버린 것 읽기
- 34 Make·CMake 크로스 컴파일 — Toolchain File·Sysroot·Preset
- 35 임베디드 Bootloader 체인 — BootROM·SPL·U-Boot·Kernel·Secure Boot
- 36 첫 bare-metal 프로그램 작성 — Linker·Startup·main의 최소 구성
- 37 MMIO 레지스터 직접 접근 — volatile·Memory Map·Aliasing 분석
- 38 GPIO 드라이버 직접 구현 — STM32F407을 HAL 없이 레지스터로
- 39 임베디드 클럭 설정 분석 — HSE·PLL·SYSCLK·AHB/APB 분주
- 40 Cortex-M 인터럽트 핸들링 — NVIC·Priority·Vector·EXTI
- 41 SysTick 타이머 활용 — 24-bit Counter·1ms Tick·delay 구현
- 42 UART 드라이버 구현 — polling·interrupt·DMA 3가지 방식 비교
- 43 SPI 드라이버 구현 — Master·Slave·CRC·DMA
- 44 I2C 드라이버 구현 — STM32F405/407 Master·Repeated START·Clock Stretching·Bus Recovery
- 45 임베디드 DMA 기초 — Memory-to-Memory·Peripheral·Circular Mode
- 46 저전력 모드 분석 — Sleep·Stop·Standby·Wake-up Source
- 47 STM32F405/407 IWDG·WWDG 워치독 구현 — Independent vs Window 비교
- 48 임베디드 Flash 프로그래밍 — Erase·Program·Read While Write
- 49 DDR 초기화 실패 진단 — Timing·Calibration·Walking Bit Test
- 50 PWM 출력 실전 — LED 밝기·모터 속도 제어
- 51 DC 모터 제어 — H-Bridge·PWM Duty·Encoder Feedback
- 52 스테퍼 모터 제어 — Full Step·Half Step·Microstepping
- 53 서보 모터 제어 — 50 Hz PWM·다채널·Calibration
- 54 Character LCD 제어 — HD44780·4-bit Mode·Custom Char
- 55 SPI OLED 제어 — SSD1306·Frame Buffer·Page 단위 갱신
- 56 TFT 디스플레이 구동 — ILI9341 SPI와 STM32F746 LTDC
- 57 환경 센서 활용 — BME280 온습압·SHT3x 비교
- 58 IMU 센서 활용 — MPU-6050·Data Ready·Complementary Filter
- 59 CAN 통신 구현 — bxCAN Bit Timing·Filter·Mailbox·Error 상태
- 60 USB Device 기초 — TinyUSB CDC·Descriptor·STM32F407 OTG_FS
- 61 Ethernet MAC+PHY 통합 — RMII·MDIO·lwIP Raw API
- 62 SD 카드 SPI 모드 + FatFs — 초기화·diskio 포팅·다중 블록 쓰기와 f_sync
- 63 STM32F4 RTC 활용 — Calendar·Alarm·Sub-second·Tamper·Backup Register
- 64 RTOS 도입 결정 분석 — Super Loop vs RTOS 트레이드오프
- 65 RTOS Task 설계 패턴 — 우선순위·스택·State Machine
- 66 RTOS Scheduler 동작 분석 — Tick·Context Switch·Yield
- 67 RTOS Semaphore 활용 — Binary·Counting·ISR Give
- 68 RTOS Mutex 활용 — Recursive·Priority Inheritance 적용
- 69 RTOS Queue 활용 — By-Value·By-Reference·Timeout 패턴
- 70 RTOS Event Group 활용 — Bit Wait·Sync·Notify
- 71 RTOS Software Timer 활용 — One-shot·Auto-reload·Daemon Task
- 72 ISR-Safe API 설계 — Reentrant·Atomic·Defer 패턴
- 73 Priority Inversion 진단·예방 — Mars Pathfinder Lesson 추적
- 74 Timer Wheel 분석 — Hashed·Hierarchical·O(1) Tick
- 75 RTOS 디버깅 기법 — Stack·Heap·Run-time Stats·SystemView
- 76 i.MX8M Mini EVK Linux 부팅 흐름 — BootROM에서 PID 1까지 단계별 인계
- 77 U-Boot 활용 — bootcmd·env·tftp·boot.scr 분석
- 78 Device Tree 실전 — DTS·DTB·Overlay·Phandle 추적
- 79 Device Tree Overlay 적용 — Runtime fragment·dtoverlay
- 80 임베디드 커널 빌드 — defconfig·menuconfig·Image·deb 패키지
- 81 커널 모듈 기초 — init/exit·Parameter·KBuild·modprobe
- 82 캐릭터 드라이버 작성 — file_operations·cdev·register_chrdev
- 83 Platform 드라이버 작성 — of_match·devm 해제 순서·probe 실패 판정 (Linux v6.12)
- 84 mmap 4가지 모드 — Anonymous·File·Shared·Huge Page
- 85 epoll 실전 — LT·ET·ONESHOT·EXCLUSIVE 비교
- 86 UIO·VFIO 분석 — User-Space Driver와 IOMMU 격리
- 87 sysfs·configfs 활용 — kobject 기반 User 인터페이스
- 88 IRQ Affinity 설정이 거부되거나 되돌아가는 이유 — smp_affinity·effective_affinity·isolcpus·irqbalance
- 89 루트 파일시스템 구축 — Buildroot 기초·Package·Toolchain
- 90 임베디드 동적 메모리 — malloc 위험·결정성·대안 분석
- 91 메모리 정렬과 패딩 분석 — Natural·Strict Alignment·Trap
- 92 Cache Line Alignment — alignas·Padding·SoA 적용
- 93 DMA-Friendly Allocator — dma_alloc_coherent·IOMMU·Pool
- 94 Zero-Copy Pipeline — DMA-BUF·sendfile·io_uring·splice
- 95 NUMA Memory Topology — numactl·numa_alloc·HBM 적용
- 96 SIMD 활용 분석 — Intrinsics·Auto-Vectorization·OpenMP SIMD
- 97 ARM NEON 심화 — Matrix Multiply·FFT·Image Filter 적용
- 98 임베디드 스택 분석 — high-water·overflow 탐지
- 99 임베디드 코드 크기 최적화 — -Os·LTO·Section Garbage Collection
- 100 임베디드 전력 최적화 — Sleep Mode·Clock Gating·DVFS
- 101 WCET 분석 기법 — Static·Measurement·Hybrid 방법론
- 102 Lock-Free Ring Buffer 구현 — SPSC·Power-of-2·Memory Order
- 103 Wait-Free Signaling — Atomic Flag·Sequence·Latest-Value
- 104 RCU (Read-Copy-Update) 기초 — Quiescent State·Grace Period
- 105 Hazard Pointer 분석 — Lock-Free Memory Reclamation
- 106 Compare-And-Swap 패턴 — Stack·Counter·Linked List 적용
- 107 Atomic Operation 비용 분석 — Fence·Cache Line·Contention
- 108 Spinlock vs Mutex 결정 가이드 — Context Switch·Hold Time
- 109 ABA 문제 회피 — Tagged Pointer·Hazard·Generation Counter
- 110 False Sharing 해결 — Cache Line Padding·Per-CPU·thread_local
- 111 MPMC Queue 구현 — Multi-producer Multi-consumer Lock-Free
- 112 임베디드 디버깅 마인드셋 — 가설·격리·재현·이분탐색
- 113 JTAG·SWD 안 붙을 때 — 핀·전압·속도·세션 진단
- 114 GDB 원격 디버깅 — OpenOCD·J-Link·target remote 구성
- 115 Cortex-M 하드폴트 분석 — Stacked Frame·CFSR 읽기
- 116 UART 안 찍힐 때 — Bare-metal 체크리스트
- 117 임베디드 부팅 실패 진단 — 단계별 Isolation
- 118 인터럽트 누락·중복 진단 — Priority·Pending·Re-entry 추적
- 119 메모리 오버플로우·오염 진단 — Canary·MPU·Pattern 분석
- 120 타이밍·Race 진단 — Heisenbug 잡는 법
- 121 통신 프로토콜 분석 — Logic Analyzer와 Protocol Decoder
- 122 임베디드 로깅 시스템 설계 — 레벨·버퍼·SWO·Deferred
- 123 임베디드 포스트모템 분석 — Core Dump와 Field Crash
- 124 FPGA 기초 분석 — LUT·FF·BRAM·DSP 자원 구조
- 125 Vivado 사용법 — Project·Constraint·Synth·Impl·Bitstream
- 126 PCIe BAR 매핑 분석 — Config Space·Enumeration·MMIO 접근
- 127 AXI 인터페이스 — AXI4·AXI4-Lite·AXI-Stream 비교
- 128 Zynq PS-PL 통신 — GP·HP·ACP 인터페이스 선택
- 129 Mailbox Protocol 분석 — Host와 Accelerator를 잇는 Doorbell
- 130 Command Queue·Submission Queue — NVMe·XDMA 공통 패턴
- 131 DMA Completion 메커니즘 — Interrupt·Polling·Completion Ring
- 132 PCIe Streaming 분석 — BAR Type·MSI-X·Kernel Bypass
- 133 Vitis HLS 분석 — Pragma·Pipeline II·Dataflow 실전 감각
- 134 HLS 최적화 기법 — Pipeline·Unroll·Partition·Dataflow
- 135 Vitis AI 분석 — DPU·xmodel·VART
- 136 OpenCL on FPGA — Kernel·Channel·Burst Memory 분석
- 137 Intel Quartus로 넘어가기 전 — 어느 toolchain에서나 쓰는 HDL과 testbench
- 138 Edge Inference 분석 — Cloud vs Edge·Latency·Privacy
- 139 Edge 추론 Pipeline 측정 — Stage Latency·Mailbox 정책·Buffer 수
- 140 NPU 아키텍처 분석 — Ethos·Hexagon·Systolic Array 비교
- 141 딥러닝 Quantization 분석 — PTQ·QAT·INT8·INT4·Calibration
- 142 TensorRT 분석 — ONNX→Engine·FP16·INT8·DLA·Multi-Stream
- 143 TFLite Micro 분석 — Op Resolver·Tensor Arena·Cortex-M
- 144 ONNX Runtime 분석 — Execution Provider와 Cross-Platform 배포
- 145 Edge Thermal Management — Throttling·DVFS·Fan Curve·Sustained
- 146 NVIDIA Jetson 분석 — Nano·Xavier·Orin·Thor·JetPack·DLA·VPI
- 147 Zero-Copy Camera Pipeline — V4L2·DMA-BUF·GPU Import·NPU 직결
- 148 온디바이스 LLM 추론 — llama.cpp·GGUF·MLX·KV Cache·NPU Backend
- 149 Cortex-M33 TF-M·TrustZone — Secure Firmware·PSA·MCUboot
- 150 Matter·Thread 분석 — IoT 통합 표준·Commissioning·Multi-Fabric
- 151 PCIe → CXL 진화 — 같은 PHY 위 cache-coherent 프로토콜 추가
- 152 QEMU CXL Type 3 디바이스 에뮬레이션 — 노트북에서 CXL 개발 환경 구축
- 153 Linux CXL 드라이버 분석 — cxl_pci·cxl_core·region·DAX