Chapter 10:Shell === :::info 終於來到最後一章了,最後我們要完成一個`shell`供使用者輸入的介面。 最重要手要完成的就是 print log,開發過程中這是最重要的一環,接著我們要 support pid ,讓每個 process 擁有唯一的 number,然後是 process management: `fork()`、`exec()`、`wait()`、`exit()`、`pipe()`,然後再來是要讓使用者輸入的 keyboard 實作,最後才是完整的`shell`。   1. Print Log   2. pid   3. fork   4. exec   5. wait and exit   6. pipe   7. Keyboard   8. My Shell ::: >[time=Thu, Dec 18, 2025 2:32 AM] --- https://youtu.be/BHXdv1iA31s <iframe width="560" height="315" src="https://www.youtube.com/embed/BHXdv1iA31s?si=Zk_sN6Q2koyazf53" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe> https://youtu.be/k3__qZBkzl0 <iframe width="560" height="315" src="https://www.youtube.com/embed/k3__qZBkzl0?si=Oj46a2YNo4xIoqiz" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>  # Print Log >[!Note] System Call > ## Source Code https://github.com/srhuang/a-os/commit/f643094b1c03ef5d09e1feb38cba3f65ac3f39a2 ## Compile ``` make all ``` ## Put on hard disk ``` sh gen.sh ``` ## Checkpoint  # pid  ## Source Code https://github.com/srhuang/a-os/commit/21fe8b02f7561383b1ff5bc84de4f8c129cee4ec ## Compile ``` make all ``` ## Put on hard disk ``` sh gen.sh ``` ## Checkpoint  # fork  >[!Note] User Process Resource > >[!Note] fork kstack > ## Source Code https://github.com/srhuang/a-os/commit/2e47b238bd0d3b260e46dc74602fe72ea4d1e9ce ## Compile ``` make all ``` ## Put on hard disk ``` sh gen.sh ``` ## Checkpoint  # exec >[!Note] Hard Disk Layout > >[!Note] C Runtime Library (CRT) > ## Source Code https://github.com/srhuang/a-os/commit/053aa01835c86eab0b8f6d750f370edf6e6b6abb ## Compile ``` make all ``` ## Put on hard disk ```sh= dd if=../code/out/mbr.bin of=./60mb.img bs=512 count=1 conv=notrunc dd if=../code/out/loader.bin of=./60mb.img bs=512 count=4 seek=1 conv=notrunc dd if=../code/out/kernel.bin of=./60mb.img bs=512 count=200 seek=5 conv=notrunc dd if=../code/out/usr.bin of=./60mb.img bs=512 count=100 seek=205 conv=notrunc dd if=../code/out/prog of=./60mb.img bs=512 count=100 seek=305 conv=notrunc ``` ``` sh gen.sh ``` ## Checkpoint  # wait and exit  ## Source Code https://github.com/srhuang/a-os/commit/770eb9e4b597a03db3fed5f457a8ac763fa67956 ## Compile ``` make all ``` ## Put on hard disk ``` sh gen.sh ``` ## Checkpoint  # pipe  >[!Note] IO Queue > ## Source Code https://github.com/srhuang/a-os/commit/9bb5d704f6f54169c4da0f14899513802e75a131 ## Compile ``` make all ``` ## Put on hard disk ``` sh gen.sh ``` ## Checkpoint  test ioqueue   # Keyboard > Reference: > [Bochs' map of I/O ports to functions](https://bochs.sourceforge.io/techspec/PORTS.LST) >  >[!Note] Scan Code >https://wiki.osdev.org/PS/2_Keyboard#Scan_Code_Set_1 > ## Source Code https://github.com/srhuang/a-os/commit/722021b66b2dde6e178327ff2d9f634a6f346803 ## Compile ``` make all ``` ## Put on hard disk ``` sh gen.sh ``` ## Checkpoint  # My Shell  >[!Note] Absolute Path > >[!Note] Command Length > ## Source Code https://github.com/srhuang/a-os/commit/9fec70088b00fffb1ea9f7b3686375f529007248 >[!Warning] Bug Fix >https://github.com/srhuang/a-os/commit/e631516f2db8ef0db418886650c762d117bbddbb ## Compile ``` make all ``` ## Put on hard disk ``` sh gen.sh ``` ## Checkpoint   
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up