- 2m
- 5m
Developing a Multithreaded Kernel From Scratch
About this course
This course is designed to teach you how to create your very own multitasking operating system and kernel from scratch. It is assumed you have no experience in programming kernels and you are taught from the ground up.
Real Mode Development
Real mode is a legacy mode in all Intel processors that causes the processor to start in a legacy state, it performs like the old 8086 Intel processors did back in the way.
In the "Real Mode Development" section of the course we start by learning about the boot process and how memory works, we then move on to creating our very own boot loader that we test on our real machine! This boot loader will output a simple "Hello World!" message to the screen and we write this boot loader in purely assembly language.
In this section we also read a sector(512 bytes) from the hard disk and learn all about interrupts in real mode and how to create them.
This section gives you a nice taster into kernel development, without over whelming you with information. You are taught the basics and enough about the legacy processors to be able to move forward to more modern kernel development further into this course.
Protected Mode Development
In this section we create a 32 bit multi-tasking kernel that has the FAT16 filesystem. Our kernel will use Intel's built in memory protection and security mechanisms that allow us to instruct the processor to protect our kernel and prevent user programs from damaging it.
This section is very in depth, you are taught all about paging and virtual memory. We take advantage of clever instructions in Intel processors to allow all processes to share the same memory addresses, this is known as memory virtualization. We map memory addresses to point to different physical memory addresses to create the illusion that every process that is running is loaded at the same address. This is a very common technique in kernel development and is also how swap files work (Those files that are used to compensate for when you run out of usable RAM).
We create our own virtual filesystem layer that uses a design that is similar to the Linux kernel. This clever abstraction that will be taught to you was inspired by the instructors knowledge of writing Linux kernel drivers in his past.
You are taught about the design of the FAT16 filesystem and how the FAT16 filesystem is broken down into clusters and that they can chain together. We then implement our very own FAT16 filesystem driver allowing files to be born!
We implement functionality for tasks and processes and write our own keyboard drivers.
In this course you also get to learn how memory management works, we implement the "malloc" and "free" functions creating our very own heap that's designed to keep track of what memory is being used. Memory management is essential in any operating system and kernel.
Let us not forget that we even create an ELF file loader, we will compile all our operating systems programs into ELF files and allow the loading of binary programs or ELF programs. ELF files contain a lot of information that describes our program for example where our program should be loaded into memory and the different sections of the program.
By the end of this course you will have a fully functioning 32 bit multi-tasking kernel that can have many processes and tasks running at the same time. You will have a working shell that we can use as well.
Assembly language bonus
This is a bonus section designed to bring your assembly skills up to scratch should you struggle a little bit with the assembly language in this course. It's however advised you come to this course with experience in assembly language, we do use it and its important. Never the less if you want to take a chance on this course with no assembly experience then this section will help point you in the right direction so your able to take what you learned and apply it to the kernel.
Taught by an expert that has created Linux kernel modules professionally in the work place.
What you'll learn
- How to create a kernel from scratch
- How to create a multi-tasking kernel
- How to handle malicious or problematic programs in your operating system. Terminating them if they misbehave.
- How memory works in computers
- The difference between kernel land, user land and the protection rings that make up modern computing
- Kernel design patterns used by the Linux kernel its self
- You will learn all about virtual memory and how to map virtual addresses to physical addresses
- You will learn how to make the kernel understand processes and tasks
- You will learn how to load ELF files
- You will learn how to debug disassembled machine code
- You will learn how to debug your kernel in an emulator with GDB.
Who this course is for
- People who want to develop a kernel from scratch
Requirements
- Understanding the C programming language
- Understanding Assembly Language
Curriculum
139 Lessons • 29h 30m estimated learning time- 4m
- 8m
- 3m
- 16m
- 2. Understanding Real Mode? 5m
- 3. Segmentation Memory Model 9m
- 4. Improving Our Bootloader 8m
- 5. Preparing our bootloader to be booted on real hardware 6m
- 6. Writing our bootloader to a USB stick 3m
- 1m
- 8. The Interrupt Vector Table Explained 4m
- 9. Implementing our own interrupts in real mode 7m
- 10. Disk Access And How It Works 6m
- 11. Reading from the hard disk 14m
- 1. What Is Protected Mode? 7m
- 2. Switching To Protected Mode 16m
- 3. Restructuring Our Project 3m
- 4. Enabling the A20 line 3m
- 5. Creating a Cross Compiler So We Can Code In C 12m
- 6. Loading our 32 bit kernel into memory and working with debugging symbols 39m
- 7. Cleaning our object files 2m
- 8. Dealing With Alignment Issues 8m
- 9. C Code In Protected Mode 9m
- 10. Text Mode Explained 3m
- 11. Writing To The Screen, Hello World Tutorial 17m
- 12. Interrupt Descriptor Table Explained 9m
- 13. Implementing The Interrupt Descriptor Table 28m
- 14. Implementing In And Out Instructions 10m
- 15. Programmable Interrupt Controller Explained 5m
- 16. Programmable Interrupt Controller Implementation 13m
- 17. Understanding The Heap And Memory Allocation 21m
- 18. Implementing Our Heap 1h 5m
- 19. Creating The Enable Interrupts Function 3m
- 20. Understanding Paging 21m
- 21. Implementing Paging 29m
- 22. Modifying The Page Table 24m
- 23. Preparing To Read From The Hard Disk 3m
- 24. Reading from the disk in C with the ATA controller 11m
- 25. Improving Our Disk Driver 10m
- 26. What Is A Filesystem? 8m
- 27. Creating A Path Parser 37m
- 28. Creating A Disk Stream 16m
- 29. File Allocation Table Explained 18m
- 30. Starting To Create Our FAT filesystem 14m
- 31. Understanding The VFS(Virtual Filesystem System) Layer 7m
- 32. Implementing Our Virtual Filesystem Core Functionality 28m
- 33. Implementing FAT16 filesystem driver core functionality 18m
- 34. Implementing FAT16 Structures 20m
- 35. Implementing The FAT16 Resolver Function 34m
- 36. Implementing the VFS fopen function 25m
- 37. Implementing FAT16 fopen function 58m
- 38. Implementing the VFS fread function 7m
- 39. Implementing FAT16 fread functionality 9m
- 40. Implementing the VFS fseek functionality 3m
- 41. Implementing The FAT16 fseek functionality 6m
- 42. Implementing The VFS fstat functionality 5m
- 43. Implementing the FAT16 fstat functionality 7m
- 44. Implementing The VFS fclose functionality 3m
- 45. Implementing the FAT16 fclose functionality 8m
- 46. Implementing A Kernel Panic 3m
- 47. Understanding User Land 15m
- 48. Changing our kernel segment and data descriptors to be written in C 20m
- 49. Implementing The TSS(Task Switch Segment) 12m
- 50. Implementing Task Foundations 30m
- 51. Implementing Process Foundations Part 1 39m
- 52. Implementing Process Foundations Part 2 25m
- 53. Packing the GDT 2m
- 54. Implementing User Land Functionality 18m
- 55. Creating Our First User Process Application 10m
- 56. Executing The Process And Dropping Into User Land Privileges 8m
- 57. Changing The Paging Functionality 7m
- 58. Talking With The Kernel From User Land 21m
- 59. Creating the interrupt 0x80 for user process to kernel communication 25m
- 60. Creating The Ability To Create And Execute Kernel Commands 12m
- 61. Creating our first kernel command 11m
- 62. Calling our kernel command 7m
- 63. Copying strings from the tasks process 15m
- 64. Reading the task's stack 22m
- 65. Creating The Print Command 15m
- 66. Understanding keyboard access in protected mode 16m
- 67. Creating the virtual keyboard layer 16m
- 68. Creating the PS2 port keyboard driver part 1 24m
- 69. Improving our interrupt descriptor table design 20m
- 70. Creating a cleaner way to create interrupt handlers in the interrupt descriptor 11m
- 71. Changing The Current Process 8m
- 72. Creating the PS2 port keyboard driver part 2 14m
- 73. Getting a key from the keyboard buffer in user land 11m
- 74. Creating a putchar command that writes one character to the terminal 7m
- 75. Implementing backspace in the terminal 4m
- 76. Revising our stream reader 7m
- 77. Elf Files Explained 23m
- 78. Implementing The Elf Loader - Part 1 19m
- 79. Implementing The Elf Loader - Part 2 24m
- 80. Implementing The Elf Loader - Part 3 5m
- 81. Implementing The Elf Loader - Part 4 18m
- 82. Implementing The Elf Loader - Part 5 29m
- 83. Implementing The Elf Loader - Part 6 14m
- 84. Writing User Programs In C 15m
- 85. Implementing system print in stdlib 7m
- 86. Implementing system get key in stdlib 3m
- 87. Implementing Malloc In Our stdlib 22m
- 88. Implementing Free In Our stdlib 10m
- 89. Changing the way we map virtual pages for the process 3m
- 90. Implementing itoa function 5m
- 91. Implementing the putchar function 8m
- 92. Implementing the printf function 7m
- 93. Implementing the ability to read lines 11m
- 94. Creating a shell 10m
- 95. Loading other programs from our shell 27m
- 96. Creating some important stdlib functions 13m
- 97. Memory Mapping malloc in stdlib 9m
- 98. Memory Unmapping free In stdlib 12m
- 99. Process arguments - Part 1 10m
- 100. Process Arguments - Part 2 29m
- 101. Process Arguments - Part 3 6m
- 102. Implementing A 'System' Command 19m
- 103. Implementing program termination 16m
- 104. Handling program crashes 9m
- 105. Creating An Exit Command 6m
- 106. Handling caps lock, upper case and lower case letters 12m
- 107. Running multiple tasks at the same time multi-tasking 7m
- 108. Changing our fat16_new_fat_item_for_directory_item function 2m
- 109. Changing out fat16_open function 4m
- 110. Changing our fat16_get_root_directory function 3m
- 111. Changing our process_load_binary function 3m
- 112. Improvements to our fat16_to_proper_string function 9m
- 113. Changing our restore_general_purpose_registers function 4m
- 114. Kernel Optimizations 1h 20m
- 1. What Is Assembly Language? 2m
- 2. Installing The Emulator 2m
- 3. Hello World In Assembly 18m
- 4. Transistors And Logic Gates Understanding The Processor 13m
- 5. Registers In Assembly 10m
- 6. Segmentation In The 8086 9m
- 7. The Stack, Subroutines And Endiness Explained 9m
- 1. Kernel Development Book And Compiler Development Course 3m
- 2. Part Two Course Now Available 1m
- 0.00 instructor rating
- 1 courses
- Systems students worldwide
Daniel McCarthy
Learn from DragonZap instructors with practical, build-first lessons focused on systems, low-level programming, compilers, kernels, and real-world engineering fundamentals.
Student reviews
A great format to pick up a ton of bonus knowledge that would be very difficult to pick up otherwise. Lets you dive into very granular stuff, like the OSDev wiki, but he guides you through navigating it so you can return...
Great so far. I have been getting the answer to my long wonders about OS. On the other hand, I think it'll be more interactive if challenges/home work are a part of the course.
Everything was explained realy well.
Very good 5/5 Това може да е много добро
This is my first class with this instructor. I'm enjoying it so far. I look forward to building an OS, but the theory so far has been very good, too.
An absolute must for people who focus on kernel development !!
I could never grasp paging until this course. Thank you!