<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Cà Phê &amp; Code — Hệ điều hành</title>
    <link>https://coffeecode.vn/categories/he-dieu-hanh</link>
    <description>Cà Phê &amp; Code là blog dành cho những người yêu công nghệ và lập trình. Nơi chia sẻ kiến thức coding, công cụ hữu ích, xu hướng công nghệ, kinh nghiệm phát triển phần mềm và những câu chuyện phía sau màn hình — tất cả được kể theo cách gần gũi, dễ hiểu, như một cuộc trò chuyện bên tách cà phê.</description>
    <language>vi</language>
    <atom:link href="https://coffeecode.vn/categories/he-dieu-hanh/rss.xml" rel="self" type="application/rss+xml"/>
    <item>
      <title>Chi phí một syscall</title>
      <link>https://coffeecode.vn/posts/chi-phi-syscall</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/chi-phi-syscall</guid>
      <description>Một lời gọi hàm thường tốn 0,8ns; một syscall getpid bẫy vào nhân tốn ~113ns (gấp 140 lần). Nhưng clock_gettime chỉ 15ns — vì nó KHÔNG bẫy, nó chạy trong vDSO. Đo thật bằng C và strace.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>fork tốn gì</title>
      <link>https://coffeecode.vn/posts/fork-ton-gi</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/fork-ton-gi</guid>
      <description>fork() không sao chép dữ liệu nhờ copy-on-write (fork 1GB 1,6ms so với memcpy 490ms), nhưng nó vẫn tốn O(bộ nhớ) vì phải sao chép bảng trang: 33us ở 1MB lên 1613us ở 1GB. Đo thật.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>Copy-on-write khi fork</title>
      <link>https://coffeecode.vn/posts/copy-on-write-khi-fork</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/copy-on-write-khi-fork</guid>
      <description>Sau fork, con ghi 0% thì chiếm riêng 0MB, ghi 100% thì 400MB — bộ nhớ được chia sẻ đúng tới khi ghi. Nhưng RSS đứng yên 400MB ở mọi mức: nó đếm cả trang chung. Đo thật bằng smaps.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>Chi phí tạo luồng</title>
      <link>https://coffeecode.vn/posts/chi-phi-tao-luong</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/chi-phi-tao-luong</guid>
      <description>Tạo một luồng tốn 42us, tạo một tiến trình 96us — nhanh hơn ~2 lần, không phải 100 lần. Và 1000 luồng làm VmSize +8GB nhưng RAM thật chỉ +8MB: 8MB mỗi luồng là địa chỉ ảo. Đo thật.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>Chuyển ngữ cảnh</title>
      <link>https://coffeecode.vn/posts/context-switch</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/context-switch</guid>
      <description>Ghim hai luồng vào một nhân, đổi ngữ cảnh tốn 0,5us. Bỏ ghim để dùng hai nhân — chậm gấp 16 lần (8,7us), vì đó là cross-core chứ không phải đổi ngữ cảnh. Đo thật bằng ping-pong.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>Trạng thái tiến trình</title>
      <link>https://coffeecode.vn/posts/trang-thai-tien-trinh</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/trang-thai-tien-trinh</guid>
      <description>Dựng từng trạng thái R/S/D/Z/T rồi đọc /proc: dd đồng bộ nằm trong D tới 72% thời gian. Và load average không vọt lên ngay khi có tải — vì nó là trung bình trượt 1/5/15 phút. Đo thật.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>mmap so với read</title>
      <link>https://coffeecode.vn/posts/mmap-so-voi-read</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/mmap-so-voi-read</guid>
      <description>Đọc file chạm mọi byte: mmap và read bằng nhau (~3700 MB/s). Nhưng chạm thưa 1 byte/trang, mmap nhanh gấp 5 lần (190 vs 40 GB/s) — vì read phải chép cả file vào buffer. Đo thật.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>Page cache</title>
      <link>https://coffeecode.vn/posts/page-cache</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/page-cache</guid>
      <description>Đọc lạnh từ đĩa 93ms, đọc ấm từ cache 18ms — nhanh gấp 5 lần. Nhưng đo hớ: ghi file bằng dd đã nạp sẵn nó vào cache, nên &apos;lần đầu&apos; của tôi vốn đã ấm. Phải drop_caches. Đo thật.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>fsync tốn gì</title>
      <link>https://coffeecode.vn/posts/fsync-ton-gi</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/fsync-ton-gi</guid>
      <description>write() không fsync đạt ~984.000 ghi/giây — nhưng đó là tốc độ cache, dữ liệu chưa bền. Thêm fsync ép xuống đĩa: sụp còn ~2.578 ghi/giây (388us mỗi lần). Gộp fsync cứu lại tốc độ. Đo thật.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>Ghi đệm và write-back</title>
      <link>https://coffeecode.vn/posts/ghi-dem-va-write-back</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/ghi-dem-va-write-back</guid>
      <description>Ghi 300MB không fsync: Dirty nằm nguyên 300MB suốt 30 giây rồi mới về 0 — nhân đẩy trang bẩn xuống đĩa đúng mốc dirty_expire. Cửa sổ 30 giây đó là lý do phải fsync. Đo thật bằng /proc/meminfo.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>Đọc trước</title>
      <link>https://coffeecode.vn/posts/doc-truoc</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/doc-truoc</guid>
      <description>Đọc tuần tự 6701 MB/s, ngẫu nhiên 295 MB/s. Nhưng đọc tuần tự mà TẮT readahead chỉ 134 MB/s — chậm 50 lần, dù không hề seek. Tuần tự nhanh vì readahead, không phải vì SSD không seek. Đo thật.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>Bộ nhớ ảo và RSS</title>
      <link>https://coffeecode.vn/posts/bo-nho-ao-va-rss</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/bo-nho-ao-va-rss</guid>
      <description>Cấp phát 2GB tức thì, VmSize +2GB nhưng VmRSS +0. Và đọc hết 2GB đó vẫn +0 RAM — vì đọc bộ nhớ mới chạm zero-page chung; chỉ GHI mới cấp RAM thật. Đo thật bằng /proc/self/status.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>Overcommit bộ nhớ</title>
      <link>https://coffeecode.vn/posts/overcommit-bo-nho</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/overcommit-bo-nho</guid>
      <description>malloc 512 GB trên một máy 8 GB vẫn báo THÀNH CÔNG — vì overcommit chỉ hứa, chưa giao RAM. Sự thật lộ khi chạm trang: OOM killer giết ở giới hạn thật. Đo thật.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>OOM killer</title>
      <link>https://coffeecode.vn/posts/oom-killer</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/oom-killer</guid>
      <description>Khi hết RAM, nhân giết ai? Không phải kẻ vừa xin làm tràn, mà KẺ TO NHẤT — một tiến trình ngoài cuộc đang ngồi yên. Đo thật bằng oom_score và dmesg.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>cgroup giới hạn bộ nhớ</title>
      <link>https://coffeecode.vn/posts/cgroup-gioi-han-bo-nho</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/cgroup-gioi-han-bo-nho</guid>
      <description>Container ở 255/256 MB — sắp OOM? Không hẳn: nếu &apos;đầy&apos; là page cache thì container khỏe re, oom_kill=0; nếu là anon thì exit 137. Cùng con số, kết cục trái ngược. Đo thật.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>Huge pages</title>
      <link>https://coffeecode.vn/posts/huge-pages</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/huge-pages</guid>
      <description>Truy cập ngẫu nhiên trên 1 GB: trang 4KB mất 138 ns/lần, trang lớn 2MB chỉ 114 ns — chênh đó là chi phí lỗi TLB. Và một lần THP=always khiến &apos;nền 4KB&apos; của tôi âm thầm là 2MB. Đo thật.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>Swap</title>
      <link>https://coffeecode.vn/posts/swap-va-loi-trang-nang</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/swap-va-loi-trang-nang</guid>
      <description>Nạp lại một trang đã bị đẩy ra swap tốn ~704 ns, chậm hơn đọc RAM 58 lần — dù bộ đếm ru_majflt và pswpin đều báo 0. Tin đồng hồ hơn bộ đếm. Đo thật bằng MADV_PAGEOUT.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>Bộ nhớ chia sẻ</title>
      <link>https://coffeecode.vn/posts/bo-nho-chia-se</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/bo-nho-chia-se</guid>
      <description>Chuyển 1 GB giữa hai tiến trình: pipe 3,1 GB/s, bộ nhớ chia sẻ có ring 9,8 GB/s (~3×). Nhưng shm một đệm lại chậm hơn pipe, và một số 15 GB/s dối đã suýt lừa tôi. Đo thật.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>Pipe và bộ đệm</title>
      <link>https://coffeecode.vn/posts/pipe-va-bo-dem</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/pipe-va-bo-dem</guid>
      <description>Pipe báo dung lượng 64 KB, nhưng ghi khối 4097 byte chỉ nhét được 44 KB trước khi chặn — cách ghi định hình con số. Và khi đầy, write() chặn đúng tới khi bên đọc rút. Đo thật.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
    <item>
      <title>Lỗi trang</title>
      <link>https://coffeecode.vn/posts/loi-trang</link>
      <guid isPermaLink="true">https://coffeecode.vn/posts/loi-trang</guid>
      <description>Chạm 200MB anon chỉ sinh 102 lỗi trang, không phải 51200 — vì trang lớn THP. Và đọc file lạnh từ đĩa chỉ đếm 1 major fault dù chậm gấp 27 lần cache — vì readahead. Đo thật bằng getrusage.</description>
      <pubDate>Thu, 3 Sep 2026 00:00:00 +0700</pubDate>
      <category>Hệ điều hành</category>
    </item>
  </channel>
</rss>
