Spaces:
Sleeping
BSc: Advanced Linux
Contents
- 1 Advanced Linux
- 2 Teaching Methodology: Methods, techniques, & activities
Advanced Linux
- Course name: Advanced Linux
- Code discipline: xxxxx
- Subject area:
Short Description
This course covers the following concepts: The fundamental principles for booting
; Linux Kernel: understanding, programming, debugging, contributing; Device drivers; Power management; Graphical stack overview; Userspace: understating and interaction with Kernel, debugging userspace application and libraries.
Prerequisites
Prerequisite subjects
Prerequisite topics
Course Topics
Course Sections and Topics | Section | Topics within the section | | --- | --- | | X86/Arm assembler introduction | 1. Basic assembler: registers, operations 2. x86 ABI reference 3. Context switching 4. CPU security rings | | Userspace | 1. Executable files overview 2. ELF format 3. SO format 4. POSIX API | | Userspace debugging (GDB) | 1. Debugging techniques overview 2. GDB (Gnu debugger) usage 3. Stack trace 4. Watchpoints/breakpoints | | Linux Kernel introduction | 1. Kernel usage 2. Supported HW 3. Building the kernel | | Booting the Kernel | 1. Boot Sequence 2. Device Tree 3. U-boot 4. initrd/initramfs | | Kernel Modules | 1. Linux device and driver model 2. Virtual Filesystems | | Memory management | 1. Physical Memory 2. Virtual Memory 3. Memory Allocation | | Threads, processes and scheduling | 1. Thread 2. Processes 3. Timers | | Concurrent access to resources | 1. Mutexes 2. Spin locks 3. RW-locks |
Intended Learning Outcomes (ILOs)
What is the main purpose of this course?
The main purpose of this course is to give the students advanced knowledge of how Linux operation system boots, works and what parts it is consists of.
ILOs defined at three levels
Level 1: What concepts should a student know/remember/explain?
By the end of the course, the students should be able to ...
- Principles of Operating Systems.
- Principles of bootloaders (first- /second- stage).
- Linux booting principles.
- Linux Kernel and apps debugging principles.
Level 2: What basic practical skills should a student be able to perform?
By the end of the course, the students should be able to ...
- Memory management in Kernel and userspace.
- Linux kernel subsustems.
- Concurrent access to resources.
- HW devices interaction in Linux.
- Interrupt and multithreading execution.
- Real- and virtual- filesystems interaction.
Level 3: What complex comprehensive skills should a student be able to apply in real-life scenarios?
By the end of the course, the students should be able to ...
- Kernel drivers design skills.
- Linux Kernel contribution and advanced GIT knowledge.
- C language low-level Kernel programming.
- C/C++ language system programming.
- POSIX API usage.
- Kernel and userspace debugging (including KGDB/GDB).
- x86/ARM assembly programming.
Grading
Course grading range
| Grade | Range | Description of performance | | --- | --- | --- | | A. Excellent | 100-150 | - | | B. Good | 80-100 | - | | C. Satisfactory | 60-79 | - | | D. Poor | 0-59 | - |
Course activities and grading breakdown
| Activity Type | Percentage of the overall course grade | | --- | --- | | Labs/seminar classes | 100 | | Interim performance assessment | 0 | | Exams | 50 |
Recommendations for students on how to succeed in the course
Resources, literature and reference materials
Open access resources
- Writing Kernel Module: i2c -
- Fundamental Linux Kernel programming by Krishenko V.A., Rayzanova N.U. - /
- Linux Operating System by Kuryachiy G.V., Malinskiy K.A. -
- Systemd after 10 years, historical and techical review, -
- Evolution of Linux Kernel by Novikov E.M., -
- Online resources shared by instructor
Closed access resources
Software and tools used within the course
Teaching Methodology: Methods, techniques, & activities
Activities and Teaching Methods
Activities within each section | Learning Activities | Section 1 | Section 2 | Section 3 | Section 4 | Section 5 | Section 6 | Section 7 | Section 8 | Section 9 | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | Development of individual parts of software product code | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | | Homework and group projects | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | | Midterm evaluation | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | | Testing (written or computer based) | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | | Discussions | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
Formative Assessment and Course Activities
Ongoing performance assessment
Section 1
| Activity Type | Content | Is Graded?
|
| --- | --- | --- |
| Question | ARM architecture is faster than x86, itn’s it? | 1
|
| Question | Why does antivirus software works in RING0? | 1
|
| Question | What is the main purpose of having interrupts? | 1
|
| Question | How-to debug anything inside interrupt context? | 1
|
| Question | Show the difference in x86 and ARM CPU registers. | 0
|
| Question | Create basic
atomic operations for ARM in x86 (and vice versa). | 0
|
| Question | Implement simple context switching without threads. | 0
|
Section 2
| Activity Type | Content | Is Graded? | | --- | --- | --- | | Question | Why can’t we just use .EXE and .DLL files on Linux? | 1 | | Question | Do .SO files actually share same memory physical addresses? | 1 | | Question | POSIX vs WinAPI? Which is better from portability point of view? | 1 | | Question | What is the most secure method for interprocess communication? | 1 | | Question | What is the fastest method for interprocess communication? | 1 | | Question | Create simple app for ELF format parsing. | 0 | | Question | Create app that shows dependencies between .so and executable file. | 0 | | Question | Create two apps communicating with each other. At least 2 methods. Compare the speed. | 0 | | Question | Create app with joinable and detachable threads. Check the difference. | 0 | | Question | Create app that uses fork() and execve() with controlling child process. | 0 |
Section 3
| Activity Type | Content | Is Graded? | | --- | --- | --- | | Question | What is GDB? What platforms can be debugged using GDB? | 1 | | Question | Do we have any alternatives for GDB? | 1 | | Question | What should we have related to the app to debug it in GDB? | 1 | | Question | Name popular GDB front-ends. Check what front-ends for GDB you already use. | 1 | | Question | What alternatives to GHIDRA do we have for different platforms? | 1 | | Question | Debug simple app using GDB with symbols in runtime. Use breakpoints and watchpoints and step by step debugging. | 0 | | Question | Load coredump and debug it in GDB. | 0 | | Question | Fix few variables in binary file using GHIDRA without source code. | 0 |
Section 4
| Activity Type | Content | Is Graded? | | --- | --- | --- | | Question | Monolithic kernel vs Micro-kernel. What is faster and why? | 1 | | Question | How Linux works on HW without IOMMU? | 1 | | Question | Tools required for building Linux Kernel. | 1 | | Question | Name few operations systems bases on Linux and name the difference. | 1 | | Question | Contributing to Open Source software and Kernel. What is the difference? | 0 | | Question | Git usage: commits, email-patches. | 0 | | Question | Git usage: rewriting history. | 0 | | Question | Building Linux Kernel for your own PC. | 0 | | Question | Running new Kernel on your machine. | 0 | | Question | Kernel config file location and editing. | 0 |
Section 5
| Activity Type | Content | Is Graded? | | --- | --- | --- | | Question | What is the difference between BIOS and UEFI? What we prefer in nowadays? | 1 | | Question | What is the usage for secure boot? What requirements should be met for this? | 1 | | Question | Why in x86 we do not have device tree? And why is it required for ARM platforms? | 1 | | Question | What is the purpose of having initramfs? Can we skip that stage? | 1 | | Question | Build U-boot | 0 | | Question | Rebuilding initramfs | 0 | | Question | Changing boot order of your PC. Creating simple systemd service. | 0 |
Section 6
| Activity Type | Content | Is Graded? | | --- | --- | --- | | Question | How kernel module can be compiled and used inside or outside Linux Kernel Image? | 1 | | Question | What is the purpose of System.map file for correct Linux Kernel functionality? | 1 | | Question | What is the real requirement to have virtual filesystems in Linux Kernel? | 1 | | Question | Name few real and virtual filesystems. Briefly describe usage in real life. | 1 | | Question | Develop and deploy simple Kernel Module outside kernel image. Dynamic Loading. | 0 | | Question | Develop and deploy simple Kernel Module inside kernel image. | 0 | | Question | SysFS/ DebugFS / ProcFS/ TmpFS usage | 0 |
Section 7
| Activity Type | Content | Is Graded? | | --- | --- | --- | | Question | Why do we need virtual memory? | 1 | | Question | Why does Linux Kernel maps itself to every process address space? | 1 | | Question | How does page fault handler work? | 1 | | Question | What is segmentation fault and how it handles in Linux Kernel? | 1 | | Question | Create simple allocator (myalloc/myfree). | 0 | | Question | Create benchmark for simple allocator. | 0 |
Section 8
| Activity Type | Content | Is Graded?
|
| --- | --- | --- |
| Question | What is the difference between thread and process? | 1
|
| Question | Can process exist without any threads? | 1
|
| Question | What scheduling methods does Linux Kernel has? | 1
|
| Question | What make realtime
OS really realtime? | 1
|
| Question | What is the difference between cooperative and preemptive multitasking? | 1
|
| Question | Implement your own threads inside app. | 0
|
| Question | Implement simple scheduler for your threading app. | 0
|
| Question | Implement timer for your app without using real
timers. | 0
|
Section 9
| Activity Type | Content | Is Graded? | | --- | --- | --- | | Question | Why do we need locking structures? | 1 | | Question | Where is mutex preferred on spinlock? | 1 | | Question | Where is spinlock preferred on mutex? | 1 | | Question | Can we just write locking-free code? | 1 | | Question | What is deadlock and how it could be handled? | 1 | | Question | Implement simple locking structures. | 0 | | Question | Implement Wait-die lock. | 0 |
Final assessment
Section 1
- Describe basic CPU registers and their purpose.
- Describe x86 ABI.
- What is context switching and how does it work?
- Name all CPU security rings and describe security levels.
- Interrupts. Interrupt handler.
Section 2
- Describe ELF executable format.
- Describe how Linux processes could be load from ELF file.
- Describe .SO library loading and their layout in memory.
- Describe methods of interprocess communication (at least 2).
- POSIX. Describe network operations.
- POSIX. Describe pthread library.
- POSIX. Describe time operations.
- Describe select(), poll() methods. Name the difference.
- POSIX. Describe filesystem operations.
Section 3
- GDB. Why do we need to have symbols? Can we debug without them?
- GDB. Describe debugging techniques only using coredump.
- GDB. Describe usage or breakpoints and watchpoints.
- GDB/GDB Server. Remote debugging. Describe how to do that.
- GDB. Describe multiarch debugging.
- GDB. Describe how to debug multithreaded application.
- GDB. Stack trace. Describe usage and how-to.
- GHIDRA. Describe usage flow.
Section 4
- Briefly describe modern OS architecture. (for ex. Linux)
- Describe supported HW by Linux Kernel.
- Describe contribution process to Linux Kernel.
Section 5
- Name popular bootloaders and briefly describe the difference.
- Describe all boot sequence starting from pushing START button.
- Describe in details the role of initrd/initramfs in booting process.
- First userspace process. Describe how it works and why do we need SystemV/system?
Section 6
- Describe Linux device and driver model
- Real- and Virtual- filesystems. Describe in details.
- Name other Linux Kernel subsystems and their usage.
Section 7
- Describe how virtual memory maps on physical memory.
- Describe in details how TLB works. How TLB increases memory operations?
- Describe structure of page table, its location and management from OS.
- Describe memory allocation techniques. Describe one of them in details.
Section 8
- Describe how threading works.
- Describe pthread API usage.
- Describe difference between monotomic and realtime clocks.
- Describe scheduling strategies. Make a suggestion, which one is preferred for different situations.
- Describe difference in memory management between threads and processes.
Section 9
- Describe mutex internals.
- Describe spin lock internals.
- Describe deadlock problem and how it could be handled.
- Compare different locking methods and make conclusion of which is faster and why.
- Deeply describe wait-die locks.
- P.1.2.10 Section 10
- Section title: Kernel debugging
- Topics covered in this section:
- Debugging techniques
- DebugFS
- Other methods overview (J-Tag etc).
- KGDB
- What forms of evaluation were used to test students’ performance in this section?
- Typical questions for ongoing performance evaluation within this section
- Name and briefly describe kernel-debugging techniques.
- What debug levels for printk do you know and what is their usage?
- What other methods of Kernel debugging techniques do you know?
- Why can’t we use regular GDB to debug Linux Kernel?
- Typical questions for seminar classes (labs) within this section
- Usage of DebugFS for basic debugging
- Usage of printk and debug levels.
- KGDB usage for Kernel debugging.
- Test questions for final assessment in this section
- Explain usage of debugFS in modern kernels.
- Describe main kernel debugging techniques.
- P.1.2.11 Section 11
- Section title: HW busses
- Topics covered in this section:
- GPIO
- UART
- i2c
- spi
- pin muxing
- DMA
- What forms of evaluation were used to test students’ performance in this section?
- Typical questions for ongoing performance evaluation within this section
- What HW bus type should we prefer for flash memory?
- What bus is the fastest?
- What should we do if we don’t have enough available pins for our needs?
- Can spi devices be connected in parallel? How can we do that?
- DMA – overkill technique or our current basic needs? Briefly review advantages and disadvantages of DMA.
- Typical questions for seminar classes (labs) within this section
- Implement connection to other device using UART. Exchange data.
- Note: additional tasks will be given depends on current HW availability.
- Test questions for final assessment in this section
- Describe i2c bus. Usage of i2c bus.
- Describe spi bus. Usage of spi bus.
- Describe GPIO subsystem. Usage of GPIO.
- Describe pin muxing.
- Describe usage of DMA and consider exchange speed with and without DMA.
- P.1.2.12 Section 12
- Section title: PCI
- Topics covered in this section:
- PCI Physical parameters
- PCI Electrical parameters
- PCI Logical model
- PCI Configuration
- What forms of evaluation were used to test students’ performance in this section?
- Typical questions for ongoing performance evaluation within this section
- Briefly describe PCI specification.
- What is difference between PCI and PCIe?
- Name devices that could be connected to PC using PCI bus.
- Device tree and PCI. Briefly describe how we can configure them.
- Typical questions for seminar classes (labs) within this section
- Measure PCI Ex bus speed with different connection types: x1, x2, x4 and x16.
- Test questions for final assessment in this section
- Describe parameters of PCI bus interface.
- Describe usage of PCI bus in modern PC/laptop.
- Describe configuration and enumeration of devices on PCI bus.
- P.1.2.13 Section 13
- Section title: USB
- Topics covered in this section:
- USB Physical parameters
- USB Electrical parameters
- USB Logical model
- USB Configuration and enumeration
- What forms of evaluation were used to test students’ performance in this section?
- Typical questions for ongoing performance evaluation within this section
- Briefly describe USB specification.
- USB/A/B – type C. Describe difference.
- What devices could be connected using USB bus?
- Why we do not reboot after USB device connection to discover it?
- Can we add USB devices to device tree for faster enumeration?
- Typical questions for seminar classes (labs) within this section
- Implement simple USB device driver for keyboard/flash card/mouse etc.
- Test questions for final assessment in this section
- Describe parameters of USB interface.
- Describe usage of USB in modern PC/laptop.
- Describe configuration and enumeration of devices on USB.
- P.1.2.14 Section 14
- Section title: Graphical Stack overview
- Topics covered in this section:
- Framebuffer
- X11
- Wayland
- UI interfaces: GTK/Qt
- What forms of evaluation were used to test students’ performance in this section?
- Typical questions for ongoing performance evaluation within this section
- Linux- and Windows- comparison of graphical stack.
- Can we access framebuffer when it is double- or triple- buffered?
- What part of OS owns framebuffer?
- How X11 knows when to redraw on screen info?
- Can we use X11 and Wayland together?
- Typical questions for seminar classes (labs) within this section
- Create app with direct access to framebuffer.
- Use X11 forwarding using SSH tunnel.
- Create simple GTK/Qt application.
- Test questions for final assessment in this section
- Describe the usage of framebuffer.
- Describe the purpose of X11 system.
- Describe the purpose and advantages of Wayland framework.
The retake exam
Section 1
Section 2
Section 3
Section 4
Section 5
Section 6
Section 7
Section 8
Section 9