<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Operating Systems on Blogs</title><link>https://hbisheng.github.io/blogs/operating-system/</link><description>Recent content in Operating Systems on Blogs</description><generator>Hugo</generator><language>en-us</language><copyright>Bisheng Huang</copyright><lastBuildDate>Mon, 20 Feb 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://hbisheng.github.io/blogs/operating-system/index.xml" rel="self" type="application/rss+xml"/><item><title>Operational System Overview</title><link>https://hbisheng.github.io/blogs/operating-system/operating-system-overview/</link><pubDate>Tue, 04 Oct 2022 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/operating-system/operating-system-overview/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; OS is a &lt;strong&gt;system program&lt;/strong&gt; that provides a curated environment for user programs to run.&lt;/p&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;Think about all the physical aspects of running a program in reality, everything that is not written in the user program is handled by the OS.&lt;/p&gt;</description></item><item><title>Computer startup process</title><link>https://hbisheng.github.io/blogs/operating-system/computer-startup-process/</link><pubDate>Tue, 04 Oct 2022 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/operating-system/computer-startup-process/</guid><description>&lt;p&gt;With a &lt;a href="https://hbisheng.github.io/blogs/computer-architecture/program-exec-mental-model/"&gt;mental model of program execution&lt;/a&gt; in mind, what happens when you turn on your computer?&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Read-only memory (ROM) on the mainboard is always available for read once the power is on.&lt;/li&gt;&#10;&lt;li&gt;Once power is plugged in, CPU starts executing instructions from ROM. The first program is BIOS.&lt;/li&gt;&#10;&lt;li&gt;BIOS performs &lt;strong&gt;Power On Self Test (POST)&lt;/strong&gt; which checks that necessary hardware devices are present.&lt;/li&gt;&#10;&lt;li&gt;BIOS finds the &lt;strong&gt;boot drive&lt;/strong&gt; (the hard disk) and starts the &lt;strong&gt;bootloader&lt;/strong&gt; program.&lt;/li&gt;&#10;&lt;li&gt;The &lt;strong&gt;bootloader&lt;/strong&gt; loads the &lt;strong&gt;operating system&lt;/strong&gt; image (its programs and data) into memory.&lt;/li&gt;&#10;&lt;li&gt;The operating system takes control.&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Now let&amp;rsquo;s dive into the &lt;a href="https://hbisheng.github.io/blogs/operating-system/operating-system-overview/"&gt;operating system&lt;/a&gt;—the first piece of system software.&lt;/p&gt;</description></item><item><title>CPU scheduling/throttling</title><link>https://hbisheng.github.io/blogs/operating-system/cpu-scheduling/</link><pubDate>Wed, 15 Feb 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/operating-system/cpu-scheduling/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; The operating system controls when and how long processes run on the CPUs.&lt;/p&gt;&#10;&lt;h2 id="background"&gt;Background&lt;/h2&gt;&#10;&lt;p&gt;A &lt;strong&gt;program&lt;/strong&gt; is a static sequence of instructions. When it is being executed, it becomes a &lt;strong&gt;process&lt;/strong&gt; managed by the operating system. The operating system controls which processes have access to the CPU at a given point in time.&lt;/p&gt;</description></item><item><title>System Calls</title><link>https://hbisheng.github.io/blogs/operating-system/system-calls/</link><pubDate>Fri, 17 Feb 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/operating-system/system-calls/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; User programs issue system calls to use the services provided by the operating system. Such services include interacting with the hardware devices.&lt;/p&gt;&#10;&lt;p&gt;The operating system is the interface between a user program and the hardware devices. The OS provides services to the user programs. The services are provided through &lt;strong&gt;system calls&lt;/strong&gt;. To use hardware resources, users programs invoke system calls.&lt;/p&gt;</description></item><item><title>File system</title><link>https://hbisheng.github.io/blogs/operating-system/filesystem/</link><pubDate>Mon, 20 Feb 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/operating-system/filesystem/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; A filesystem organizes the information on disks to support reading and writing a large number of files.&lt;/p&gt;&#10;&lt;p&gt;Information that needs to be persisted is stored on the disk. You want to store a lot of data in it, which requires you to organize the information well. In disks, the space is divided into pages. The interface provided by the hardware disks can be simplified as two APIs:&lt;/p&gt;</description></item><item><title>Paging, Page Cache</title><link>https://hbisheng.github.io/blogs/operating-system/paging/</link><pubDate>Mon, 20 Feb 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/operating-system/paging/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; Data is moved between disks and memory in pages. The OS maintains the illusion that each process has its own virtual memory space and translates a virtual address into a physical one with the help of the page directory and page tables. The OS has kernel-level page caches for files.&lt;/p&gt;</description></item><item><title>Memory Management</title><link>https://hbisheng.github.io/blogs/operating-system/memory-management/</link><pubDate>Mon, 20 Feb 2023 00:00:00 +0000</pubDate><guid>https://hbisheng.github.io/blogs/operating-system/memory-management/</guid><description>&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt; The OS is responsible for managing the memory, including allocation, deallocation, defragmentation, and reclaim.&lt;/p&gt;&#10;&lt;h2 id="memory-allocation"&gt;Memory allocation&lt;/h2&gt;&#10;&lt;p&gt;&lt;strong&gt;Buddy system&lt;/strong&gt;&lt;/p&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;Maintain a list of free blocks.&lt;/li&gt;&#10;&lt;li&gt;Allocation&#10;&lt;ul&gt;&#10;&lt;li&gt;Choose the smallest possible block during allocation. Split the memory block if the allocation takes less than half of the block. Say you have one block of 16KB and the user requests a block of 4KB, you end up with two free blocks: 4KB and 8KB.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;Deallocation&#10;&lt;ul&gt;&#10;&lt;li&gt;When a block is freed, if its buddy (the node that shares the same parent) is also free, they can be merged into a larger free node.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;p&gt;The buddy system reduces fragmentation to some degree. At least smaller blocks can be merged at times to serve larger requests.&lt;/p&gt;</description></item></channel></rss>