# NCTU OSDI 2021
###### tags: `OSDI`
## External Reference
* #### Bare metal tutorials in C
https://github.com/bztsrc/raspi3-tutorial
* #### Operating system tutorials in C
https://github.com/s-matyukevich/raspberry-pi-os
* #### Embedded Programming with the GNU Toolchain
http://www.bravegnu.org/gnu-eprog/index.html
* #### Georgia Institute of Technology - cs3210, Design Operating Systems
https://tc.gts3.org/cs3210/2020/spring/cal.html
* #### CSE451: Introduction to Operating Systems
https://courses.cs.washington.edu/courses/cse451/15au/index.html
* #### MIT, Operating System Engineering
https://pdos.csail.mit.edu/6.828/2020/index.html
* #### Baking Pi – Operating Systems Development
https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/
* #### Understanding the Linux Kernel, 3rd Edition
http://gauss.ececs.uc.edu/Courses/c4029/code/memory/understanding.pdf
* #### Building an Operating System for the Raspberry Pi (但不是Raspberry Pi 3)
https://jsandler18.github.io/
* #### Mel Gorman's book "Understanding the Linux Virtual Memory Manager"
https://www.kernel.org/doc/gorman/html/understand/
* #### OSDev.org
https://wiki.osdev.org/Main_Page
* #### Other
https://people.kth.se/~johanmon/ose.html
* #### SystemProgramming, angrave
https://github.com/angrave/SystemProgramming/wiki
* #### BCM2835 ARM Peripherals
https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/README.md
https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/BCM2835-ARM-Peripherals.pdf
https://github.com/raspberrypi/documentation/files/1888662/BCM2837-ARM-Peripherals.-.Revised.-.V2-1.pdf (修正版)
* #### BCM2837
https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2837/README.md
https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2836/QA7_rev3.4.pdf
* #### Dynamic Tracing with DTrace & SystemTap
https://myaut.github.io/dtrace-stap-book/index.html
* #### The Linux Kernel
https://www.kernel.org/doc/html/latest/locking/locktypes.html
## Previous Work - 2020 OSDI
:::info
2021年作業與2020年稍有不同,參考時需注意
:::
* 2020 OSDI - JingWangTW
https://github.com/JingWangTW/NCTU-OSDI-2020/tree/master
* 2020 OSDI - YK
https://kaiiiz.github.io/notes/nctu/osdi/
* 其中一位助教
https://github.com/GrassLab/osdi2020/tree/0856126
* 李** 助教
0616074
* https://github.com/RinHizakura
* https://github.com/JackGrence
## Other Reference
#### Arm assembly
* http://www.toves.org/books/arm/
* http://wen00072.github.io/blog/2015/04/22/hello-assembly/
* https://azeria-labs.com/writing-arm-assembly-part-1/
#### Memory Layout
https://www.geeksforgeeks.org/memory-layout-of-c-program/
## Lab Reference
:::success
紀錄實作各Lab有參考到的資料、網站
:::
### Lab0
### Lab1
#### Linker Script
* https://blog.louie.lu/2016/11/06/10%E5%88%86%E9%90%98%E8%AE%80%E6%87%82-linker-scripts/
* https://wen00072.github.io/blog/2014/03/14/study-on-the-linker-script/
* https://www.slideshare.net/jserv/from-source-to-binary-how-gnu-toolchain-works/46
* https://sourceware.org/binutils/docs/ld/Scripts.html#Scripts
* https://wiki.osdev.org/Linker_Scripts
* [ELF中的.bss section和COMMON section](http://swaywang.blogspot.com/2012/06/elfbss-sectioncommon-section.html)
#### Makefile
* http://maxubuntu.blogspot.com/2010/02/makefile.html
* http://www.opensourceforu.com/2012/06/gnu-make-in-detail-for-beginners/
* https://mropengate.blogspot.com/2018/01/makefile.html
* https://hackmd.io/@sysprog/gnu-linux-dev/https%3A%2F%2Fhackmd.io%2Fs%2FSySTMXPvl
#### Other external references
* Calling assembly functions from C and C++
https://www.keil.com/support/man/docs/armclang_intro/armclang_intro_lmi1470147220260.htm
* MEMORY INSTRUCTIONS: LOAD AND STORE
https://azeria-labs.com/memory-instructions-load-and-store-part-4/
* What registers to save in the ARM C calling convention?
https://stackoverflow.com/questions/261419/what-registers-to-save-in-the-arm-c-calling-convention
* 關於GNU Inline Assembly (C語言裡面執行Assembly)
* http://wen00072.github.io/blog/2015/12/10/about-inline-asm/
### Lab2
- Transmit kernel through UART1
https://github.com/bztsrc/raspi3-tutorial/tree/master/14_raspbootin64
- relocated bootloader
https://github.com/bztsrc/raspi3-tutorial/blob/master/14_raspbootin64/start.S
- receiver
https://github.com/bztsrc/raspi3-tutorial/blob/master/14_raspbootin64/main.c
- CPIO archive format in FreeBSD Manual Pages
https://www.freebsd.org/cgi/man.cgi?query=cpio&sektion=5
- CPIO arcihve source code in SEL4PROJ project (Cpio in "New ASCII Format")
https://github.com/SEL4PROJ/libcpio
- Initial ramdisk
https://en.wikipedia.org/wiki/Initial_ramdisk
### Lab3
- Jserv Linux 核心設計: 記憶體管理
https://hackmd.io/@sysprog/linux-memory
- 2020 OSDI Somebody's LAB-6
https://kaiiiz.github.io/notes/nctu/osdi/lab6/buddy-system/
https://github.com/GrassLab/osdi2020/tree/ab140f2676320a454c72a4d00e8f30afdb54c74b
- Physical Page Allocation(Buddy and Slab)
https://www.kernel.org/doc/gorman/html/understand/understand009.html
https://www.kernel.org/doc/gorman/html/understand/understand011.html#Sec:%20Tracking%20Free%20Objects
- Linux kernel list.h file
https://github.com/torvalds/linux/blob/master/include/linux/list.h
- The Slab Allocator in the Linux kernel.
https://hammertux.github.io/slab-allocator
- Buddy memory allocation, Wikipedia
https://en.wikipedia.org/wiki/Buddy_memory_allocation
- Overview of Linux Memory Management Concepts: Slabs
http://www.secretmango.com/jimb/Whitepapers/slabs/slab.html
- Buddy System – Memory allocation technique, GeeksforGeeks
https://www.geeksforgeeks.org/buddy-system-memory-allocation-technique/
- Linux 的記憶體管理, 陳鍾誠的網站
http://ccckmit.wikidot.com/lk:memory
- 我有所不知的 static inline function
https://medium.com/@hauyang/%E6%88%91%E6%9C%89%E6%89%80%E4%B8%8D%E7%9F%A5%E7%9A%84-static-inline-b363892b7450
- 解釋Linux Kernel list.h
http://simon88.leanote.com/post/%E5%86%85%E6%A0%B8%E9%93%BE%E8%A1%A8list.h
- Other
https://people.kth.se/~johanmon/ose/assignments/buddy.pdf
### Lab4
- Lab4實作紀錄
https://hackmd.io/Xp1pItIkRsKiM7Un655sXQ
### Lab5
- Lab5實作紀錄
https://hackmd.io/xhbHgDurTcGUuRTzpGshqQ
### Lab6 - VFS
- Lab6 Sepc
https://grasslab.github.io/NYCU_Operating_System_Capstone/labs/lab6.html
- 實作紀錄
https://www.notion.so/Lab6-Virtual-File-System-2990755ae8604f13ae488d946b1106cc
### Lab7 - File System Meets Hardware
- 實作紀錄
https://www.notion.so/Lab7-File-System-Meets-Hardware-7c58f5ca16d9400784a776f91d985a48
- https://forum.osdev.org/viewtopic.php?p=288532&sid=56df6457550d1de0a98e3a59077edb83#p288532
- Microsoft Extensible Firmware Initiative FAT32 File System Specification
http://www.osdever.net./documents/fatgen103.pdf
---
#### 問助教的問題
* 為何下列的.S code可以僅啟用core 0 關閉其他3個 core (為何要使用and?)
```
.globl _start
_start:
mrs x0, mpidr_el1
and x0, x0,#0xFF // Check processor id
cbz x0, master // Hang for all non-primary CPU
b proc_hang
```
答:可以清掉其他bit
* bss section initailize 0?
答: 可以讓Linker會對BSS section進行類似壓縮
* Enter輸入是'\r'為何不是'\n'
答: 可能根據screen putty軟體不同,像putty會自動幫轉'\r'成'\n'
* Lab2 提示
答: 就是參考External references + 網路資料
解釋User thread, Kernel thread
在Linux Kernel thread = Task structure 會被Scheduler納入排程

#### 實作心得
{"metaMigratedAt":"2023-06-15T20:24:31.332Z","metaMigratedFrom":"Content","title":"NCTU OSDI 2021","breaks":true,"contributors":"[{\"id\":\"e5c57de4-5b31-4833-8080-a7fd4f82ae7e\",\"add\":13213,\"del\":6017}]"}