How Linux Kernel Prints Text on Screen

  Рет қаралды 47,584

Nir Lichtman

Nir Lichtman

22 күн бұрын

In this video we will dive into a simple call to the printf function and see what happens in the kernel and how it gets eventually printed on screen.
For more information about setting up an environment for kernel dev, checkout the welcome link on my channel.
Docs used in video:
- docs.kernel.org/dev-tools/gdb...
- wiki.osdev.org/Text_UI

Пікірлер: 179
@nirlichtman
@nirlichtman 19 күн бұрын
- The display mechanism the kernel chooses depends on the setup, this is what it chose in the case of standard QEMU config & x86_64, but on other machines it may use something else for example a framebuffer. VGA mode 3 is a common x86/x64 choice, especially for older machines, but modern ones may not support it at all. - The reason it printed 3 "H" letters and not "Hel" is that I recycled the same command that I used to modify the first letter to red, and only changed the color so it brought over the same first letter each time.
@user-il3uq6cx4e
@user-il3uq6cx4e 18 күн бұрын
@@nirlichtman Pls Make Linux OS But With Debian-Based
@MrMassaraksh
@MrMassaraksh 13 күн бұрын
Thank you for explaining why H is printed 3 times, because it can be understood as you run over the same char, but in reality you just moved further in “array of letters”.
@FernandoMumbach
@FernandoMumbach 20 күн бұрын
This video is a tutorial on: - How printf works in the kernel - How to the debug the kernel with GDB - An intro into how to to use GDB - A guide on how to look up kernel documentation And several things more. Condensed in 12 minutes. This is perfect!! I've never seen a video as good as this one explaining anything!
@Henrix1998
@Henrix1998 19 күн бұрын
I have used GDB for about a year now every week and learned new commands
@thescroogemcduck
@thescroogemcduck 16 күн бұрын
This is more than an intro on how to use GDB lol, I thought I was decent with it but this is next level.
@ericlindell3777
@ericlindell3777 20 күн бұрын
”we’re gonna have to dive in a little bit to the assembly”. What a madlad ❤
@namanchhabra4136
@namanchhabra4136 20 күн бұрын
I always wanted to know kernel that deep 🙂
@MrLarossi
@MrLarossi 19 күн бұрын
we all like it deeper
@Scoopta
@Scoopta 20 күн бұрын
You're making one of the nerdiest linux videos I've seen on windows using MS edge...saying I'm confused is an understatement
@marsovac
@marsovac 20 күн бұрын
What you use doesn't matter. It is how well you use it... On Windows at least he doesn't have to deal with Wayland issues :D What I was wondering the most is why didn't he turn off the search box in the taskbar :P
@Scoopta
@Scoopta 20 күн бұрын
@@marsovac ...as someone who runs wayland without Xwayland or X11 compatibility at all...and as a developer of reasonably widely used wayland software...I take issue to that remark lol =D...that aside the search box is terrible.
@ddthegr8
@ddthegr8 20 күн бұрын
He's under three VMs
@LordDoucheBags
@LordDoucheBags 18 күн бұрын
@@marsovac wayland on newest nvidia drivers works well right now. Fedora btw
@MrEdrftgyuji
@MrEdrftgyuji 13 күн бұрын
A lot of corporate environments demand you use Edge.
@maciej.opalinski
@maciej.opalinski 15 күн бұрын
no unnecessary talking, straight to the point, extremely well explained, this is why I pay for internet, thank you brother
@katiagalkina4607
@katiagalkina4607 20 күн бұрын
The rabbit hole is much deeper than I was thinking!
@ismbks
@ismbks 20 күн бұрын
this feels like i'm watching paid content for free
@OrangeDied
@OrangeDied 20 күн бұрын
kys_write?? how rude...
@nyvyme
@nyvyme 20 күн бұрын
oh
@nyvyme
@nyvyme 20 күн бұрын
oh "kms" exist
@jackkendall6420
@jackkendall6420 20 күн бұрын
You should write text to the screen NOW!
@adama7752
@adama7752 20 күн бұрын
I agree, the side effects of this function are wild.
@kipchickensout
@kipchickensout 20 күн бұрын
​@@jackkendall6420 xD
@gustawitresh
@gustawitresh 20 күн бұрын
WTF, bro just said. "I don't really like AT&T *assembly* syntax, so I'm going to intel *syntax*" This man is crazy
@gustawitresh
@gustawitresh 20 күн бұрын
"it's more fun to read" omg
@lukelee2075
@lukelee2075 17 күн бұрын
The magic behind a standard library function-and the POSIX system calls-is what every CS student would have wondered about for once. Thank you for making this video. It brought back memories of being curious about how a computer works.
@CornThatLefty
@CornThatLefty 20 күн бұрын
This series of videos is awesome. Just explains and explores a low-level topic quickly and without any fluff.
@nickdaria
@nickdaria 20 күн бұрын
Excellent video as always. Love seeing well-made low level computing content that does deep dives into while keeping it just dense enough to watch in your free time. I feel like many videos on this topic are always either way too short/simplified or way too long and drawn out. You always hit it on the head.
@timeimp
@timeimp 19 күн бұрын
This is like a whole subject at uni in less than 15 minutes. Subscribed!
@CookieGod24
@CookieGod24 20 күн бұрын
I don’t know why but the way you say ‘config’ sounds satisfying
@GrittyMaholmes
@GrittyMaholmes 17 күн бұрын
I love the confidence in your voice , i wana be this confidence when coding .
@stevep5759
@stevep5759 14 күн бұрын
Really fast paced and right to the point. New sub 🎉
@patrickprucha5522
@patrickprucha5522 20 күн бұрын
I like the way you explain things. I also noticed that you are very good and very at ease with programming languages. I will look into more of your videos / media when i jump into c programming. thanks again
@KovalenkoYT
@KovalenkoYT 18 күн бұрын
I just discovered this channel today, and with two videos that I have seen I feel that in half an hour I have learned more than what I learned in many classes at the university. Subscribed!
@khazarhajiyev7710
@khazarhajiyev7710 20 күн бұрын
Have been looking for a channel like that for a long time, thank you!
@yonatanelizarov6747
@yonatanelizarov6747 20 күн бұрын
Thanks man, really useful. Keep up the great work!
@JohnnySacc
@JohnnySacc 20 күн бұрын
That was awesome, I'd love a full series of this
@sanderbos4243
@sanderbos4243 20 күн бұрын
This is such a good reference video for anyone wanting to dive into the kernel
@ciCCapROSTi
@ciCCapROSTi 3 күн бұрын
Came here to learn about the kernel, but instead got an intermediate GDB tutorial. I'm thankful, I'm a lot more interested in GDB than the Linux kernel, actually. As for the video mode, yeah, I remember programming assembly as a child, I know how that mode works. I produced several full screen vomits of blinking colors.
@waldmensch2010
@waldmensch2010 20 күн бұрын
these videos are so cool and nerdy and the best of it you learn so much
@orestissabethai830
@orestissabethai830 18 күн бұрын
We are going to need some more of that gdb magic you are doing. Nice video!
@MadMathMike
@MadMathMike 20 күн бұрын
You're a freaking wizard, Nic. Great video! 👍😊
@Joker9586
@Joker9586 13 күн бұрын
Very interesting insight! Great content, thank you sir
@AK-vx4dy
@AK-vx4dy 20 күн бұрын
Excellent job and crazy skills 🤯
@eitantal726
@eitantal726 20 күн бұрын
What happens when you have a console window, rather than raw VGA as your tty? How does it "know" that stdout is mapped to VGA in this case? is it done during process creation?
@thebuggerdev
@thebuggerdev 20 күн бұрын
When a process writes to stdout (file descriptor = 1) typically it is managed by a parent process. Parent process can catch this data (like for example console window process) or pass through to it's parent. Init is a special process, that starts all other proceses, so it's stdout is rendered by a kernel (also it can pass through data from a process, that is it's child)
@eitantal726
@eitantal726 20 күн бұрын
@@thebuggerdev So the is full process something like this? (let's say, XTerm) printf -> kernel -> parent process -> x11
@thebuggerdev
@thebuggerdev 20 күн бұрын
@@eitantal726 yes, in this example XTerm is a parent process
@thebuggerdev
@thebuggerdev 20 күн бұрын
@@eitantal726 and to be precise: communication of xterm with x11 is also done by kernel's functions
@atharvakamble5785
@atharvakamble5785 8 күн бұрын
This video is insanely good, not many like these!
@Akronymus_
@Akronymus_ 20 күн бұрын
Finally found this vid. I clicked on a different one when seeing this in the periphery and was searching for it ever since.
@callummacleod2177
@callummacleod2177 15 күн бұрын
Excellent information presentation 👌
@kaankarakoc7680
@kaankarakoc7680 20 күн бұрын
thanks for another great video!
@app3264
@app3264 19 күн бұрын
Love your videos!
@MyWatermelonz
@MyWatermelonz 20 күн бұрын
Dang breh aside from just screen printing, I learned some gdb and vim. Lots of good stuff.
@YRBYD
@YRBYD 20 күн бұрын
Great video!
@pablote325
@pablote325 19 күн бұрын
this is an insanely good video.... thanks
@Jonathan-ru9zl
@Jonathan-ru9zl 20 күн бұрын
You back!
@notyourfox
@notyourfox 17 күн бұрын
Thanks a lot! I'm trying to grasp system calls and standard library for my own OS. I am always shocked by the complexity of the code in Linux kernel and the amount of knowledge and talent it required to write.
@MO-fg2cm
@MO-fg2cm 20 күн бұрын
Damn the knowledge I got through this video is amazing
@user-dv9dl2cl1p
@user-dv9dl2cl1p Күн бұрын
learns a lot, thanks!
@MrMassaraksh
@MrMassaraksh 13 күн бұрын
Thank you! Good stuff
@David-wh8zs
@David-wh8zs 20 күн бұрын
This is such a good video
@dovonun
@dovonun 19 күн бұрын
You are an absolute legend 🤯
@golarac6433
@golarac6433 19 күн бұрын
I use gdb a lot but somehow didn't know about the 'advance' command, I would put a breakpoint when I wanted to advance forward (that I had to delete or disable later). So that's nice, thanks :) It might be worth adding that the vga text mode is a very legacy functionality. Qemu still supports it since its very easy to use from software but I'm not even sure if modern gpus support that. I think all modern gpus support only a normal linear pixel frame buffer where you'd have to blit your font characters manually.
@nirlichtman
@nirlichtman 19 күн бұрын
That's a good point, added information about this in the pinned comment.
@yahiaghadiry9885
@yahiaghadiry9885 20 күн бұрын
Amazing video But I have a question, all those boot logs before printing the H, how are those printed.
@jameskuo2822
@jameskuo2822 20 күн бұрын
printk(); in kernel space, in (very, very) shorts. I do believe they use different ways to printf() to implement printk().
@ecuasonic_7
@ecuasonic_7 9 сағат бұрын
This is so cool, thank you
@sezarstarscourge7368
@sezarstarscourge7368 19 күн бұрын
wonderful explaination ,
@gustawitresh
@gustawitresh 20 күн бұрын
idk why, but this is fun to watch.
@abdelrahmanyasser5720
@abdelrahmanyasser5720 19 күн бұрын
Great job, Thanks bro
@whamer100
@whamer100 20 күн бұрын
wow i didnt expect displaying text to be so complicated, that's interesting
@LeandroCoutinho
@LeandroCoutinho 20 күн бұрын
Amazing video! Linux kernel + gdb + qemu = ❤ I hope you manage to build more videos like this. =D Hardware and software interaction would be great. 😃
@muhammadmahad
@muhammadmahad 17 күн бұрын
Thanks for such an amazing video.
@muhammadmahad
@muhammadmahad 17 күн бұрын
Could you please share the tips to become good in low level things just like you?
@nirlichtman
@nirlichtman 17 күн бұрын
Yes, there are a bunch of tips on my welcome page, link in the channel description
@muhammadmahad
@muhammadmahad 17 күн бұрын
@@nirlichtman Thank you Nir :)
@cyberbiosecurity
@cyberbiosecurity 13 күн бұрын
Awesome, thank you
@theforeskinsnatcher373
@theforeskinsnatcher373 18 күн бұрын
some cool gdb tricks I didn't know. But I think I'll use the tui/disassembly view instead of jumping to addresses
@GreeneThumbs
@GreeneThumbs 20 күн бұрын
This is fantastic
@ricozhuang7625
@ricozhuang7625 18 күн бұрын
That is deeper than I thought
@jayhanjaelee
@jayhanjaelee Күн бұрын
It’s so interesting👍
@cosmiclattemusic
@cosmiclattemusic 18 күн бұрын
this is why I love KZbin
@soleroks
@soleroks 20 күн бұрын
Well done.
@valerys.219
@valerys.219 19 күн бұрын
essential things, nicely done. But IMHO you missed one point, how vga works (logical level), ie what the kernel write to the vga memory in order to see an 'H' on the screen. Anyway thanks for sharing.
@leonardopohlmann2723
@leonardopohlmann2723 20 күн бұрын
Nice👌
@Swampdragon102
@Swampdragon102 20 күн бұрын
I still don't know why the random modified memory appears on the terminal, but I've learned the basics of GDB, so that's something
@nirlichtman
@nirlichtman 20 күн бұрын
On VGA text mode 3 (the display mode the kernel decided to use in this case), the text on screen is manipulated through memory, so when writing to a specific memory address we can change the contents on the screen. (more info on the OSDev wiki article link in description)
@clonkex
@clonkex 19 күн бұрын
That memory was about to be printed anyway. It was H to start with because that was the beginning of Hello World. He just found where it was about to happen and changed the memory just before it did. Then because he kept using the same second byte and only changing the colour byte, it printed more H characters instead of the e and l it would have otherwise printed.
@justinnamilee
@justinnamilee 20 күн бұрын
Oh damn, I'm coming in for another "Neat!"
@iyar220
@iyar220 20 күн бұрын
Yayyy
@VaibhavSharma-zj4gk
@VaibhavSharma-zj4gk 20 күн бұрын
Thats a knowledge packed video. I understood it in parts. Is there any past video i need to see to better inderstand this one?
@sanderbos4243
@sanderbos4243 20 күн бұрын
Depends on which parts you were and weren't able to follow. Any GDB tutorial will be a good place to start
@nirlichtman
@nirlichtman 20 күн бұрын
I would recommend checking out my videos about making a simple distro, Linux system calls explained, and generally my Linux playlists. Also, welcome to check out my welcome page for recommended resources, link on my channel
@ghostsdefeated4078
@ghostsdefeated4078 17 күн бұрын
this channel is cracked
@la.zanmal.
@la.zanmal. 20 күн бұрын
0:56 For the record: the `-j` flag stands for "jobs", and tells `make` how many actions it may run in parallel. It can generally make a complex build faster, up to the limit of the number of CPU cores you have. At least for me, the numeric argument isn't necessary and by just passing `-j`, "make will not limit the number of jobs that can run simultaneously".
@NimaqAlizadeh
@NimaqAlizadeh 20 күн бұрын
Nice 🎉
@chrisking1017
@chrisking1017 17 күн бұрын
How does this change in a terminal app in a desktop environment?
@ElPikacupacabra
@ElPikacupacabra 20 күн бұрын
Why did it print 3 "H"? I tought it would continue with the other letters...
@nirlichtman
@nirlichtman 20 күн бұрын
Reason it printed 3 "H"s is that when I changed to the other colors, I reused the command in which I modified the "H" to red, and only changed the color, so it kept the same character as before.
@ElPikacupacabra
@ElPikacupacabra 19 күн бұрын
@@nirlichtman Ah, right. You did not update just the top byte.
@guilherme5094
@guilherme5094 20 күн бұрын
👍👍Thanks!
@eliphazbouye
@eliphazbouye 20 күн бұрын
Nir please I want to know what you way to learn efficiently ? can you give me our method ? some tips ? . Great video thanks
@nirlichtman
@nirlichtman 20 күн бұрын
Thanks! Check out my welcome page for more information and recommended resources (link on my channel)
@eliphazbouye
@eliphazbouye 7 күн бұрын
@@nirlichtman Very awesome thank you 🙏
@umikaliprivate
@umikaliprivate 6 күн бұрын
Could you make a video about how to make a simple wayland-based window manager?
@conandoyle1859
@conandoyle1859 9 күн бұрын
great!
@matematikaadit
@matematikaadit 20 күн бұрын
I guess if you wanna keep the character value but only change the color, you do bitwise AND to the value, for example $r10w=$r10w & 0x2FF (for green color) right? Did GDB support this expression?
@user-sq9oj2zu2v
@user-sq9oj2zu2v 19 күн бұрын
Nice
@binux5592
@binux5592 18 күн бұрын
Can yolu create 64 bit bootloader with c and asm
@doug9000
@doug9000 19 күн бұрын
would be cool to show how graphical virtual terminals work in low level too.
@skylarmorknerbrown
@skylarmorknerbrown 19 күн бұрын
This man is making some of the most informative and interesting Linux videos on all of youtube... using Windows 10
@user-fd4cy8je7m
@user-fd4cy8je7m 19 күн бұрын
شكرا لك
@reddishradish7590
@reddishradish7590 7 күн бұрын
I'm fairly new to linux.. Can someone tell me what he did on 9:17, to split the screen??
@nirlichtman
@nirlichtman 7 күн бұрын
:term command on Vim, more info on my Vim tips playlist
@palapapa0201
@palapapa0201 16 күн бұрын
9:17 How did you do the "term" thing?
@nirlichtman
@nirlichtman 16 күн бұрын
When inside of a terminal in Vim you can use CTRL+W and then ":" to run commands, in this case I ran the ":term" command to open a new terminal. more information about these kinds of stuff in my playlist "Vim Tips"
@chinchiang4345
@chinchiang4345 9 күн бұрын
AMZ!!! love it !!! THX U U is very handsome!!!! ❤❤❤❤❤❤❤❤❤❤
@Nop_Nop_0x90
@Nop_Nop_0x90 15 күн бұрын
Can you start a series on deeo dive into Linux kernal ? (A real detailed one)
@nirlichtman
@nirlichtman 15 күн бұрын
More kernel videos are planned :)
@Trollox
@Trollox 20 күн бұрын
How do you split view with the browser so easily?
@nirlichtman
@nirlichtman 20 күн бұрын
I use LightWM, it's a tiling window manager for Windows I am working on (more info on the welcome link on my channel)
@clonkex
@clonkex 19 күн бұрын
Windows has some built in shortcuts if you don't want a custom window manager (win+left for instance) but it's not as good as what this guy has
@insert0name0here91
@insert0name0here91 13 күн бұрын
How did you get the linux terminal on powershell?
@nirlichtman
@nirlichtman 11 күн бұрын
using wsl command
@insert0name0here91
@insert0name0here91 11 күн бұрын
@@nirlichtman after I used that I ran "make defconfig" and it gives me the error "make: *** No rule to make target 'defconfig'. Stop"
@nirlichtman
@nirlichtman 11 күн бұрын
@@insert0name0here91 check out my video about making a simple distro (or the welcome link on my channel) for setup information
@insert0name0here91
@insert0name0here91 11 күн бұрын
@@nirlichtman ok
@TSW3585
@TSW3585 21 сағат бұрын
Bro. Are you operative system developer ? how the hell can I learn that stuffs ?. This is a serius question. What books did you read about this ?
@nathanielthomas4437
@nathanielthomas4437 10 күн бұрын
Driver devs can get a lot of hate sometimes, but if it weren't for them, we wouldn't get to see the hard work of printf()!
@its_code
@its_code 20 күн бұрын
❤❤❤😊
@MykolaTheVaultDweller
@MykolaTheVaultDweller 20 күн бұрын
based
@w3w3w3
@w3w3w3 18 күн бұрын
interesting
@codewizard58
@codewizard58 9 күн бұрын
int(9, "hi there" )
@eitantal726
@eitantal726 20 күн бұрын
personally, I'm used to the convenience of a visual IDE and debugger
@thebuggerdev
@thebuggerdev 20 күн бұрын
JetBrains C Lion can connect to GDB (including qemu) and it works great, but unless using beta version it's not free. Do you know any free visual debuggers that works with remote GDB?
@eitantal726
@eitantal726 20 күн бұрын
@@thebuggerdev I use IAR when I debug, but I imagine VScode can interface with gdb
@thebuggerdev
@thebuggerdev 20 күн бұрын
@@eitantal726 I tested multiple VSCode plugins with no success
@MissNorington
@MissNorington 19 күн бұрын
Why is Linux using VGA mode 3 in 2024?????
@nirlichtman
@nirlichtman 19 күн бұрын
It still supports it, but what it uses depends in the end on your setup, check out the pinned comment.
@mickolesmana5899
@mickolesmana5899 20 күн бұрын
Noob arch user : nooo you can't just run both windows and linux Chad Kernel dev : anyway I just opened Qemu on Linux from ssh windows
@nirlichtman
@nirlichtman 20 күн бұрын
*WSL :)
@mickolesmana5899
@mickolesmana5899 20 күн бұрын
@@nirlichtman WSL? EVEN BETTER
@user-il3uq6cx4e
@user-il3uq6cx4e 8 күн бұрын
Please Make Linux With Based-Debian
@evildragon1774
@evildragon1774 20 күн бұрын
i'm not judging you but, why are you using windows when you're very interested in linux?
@nirlichtman
@nirlichtman 20 күн бұрын
I am also interested in Windows :)
@jomazu7874
@jomazu7874 19 күн бұрын
debugging linux kernel on windows im having a stroke
@tusharsr2709
@tusharsr2709 18 күн бұрын
isn't it wsl?
@jomazu7874
@jomazu7874 18 күн бұрын
@@tusharsr2709 could be yeah
How Hackers Bypass Kernel Anti Cheat
19:38
Ryscu
Рет қаралды 586 М.
What is the Smallest Possible .EXE?
17:57
Inkbox
Рет қаралды 317 М.
Опасность фирменной зарядки Apple
00:57
SuperCrastan
Рет қаралды 9 МЛН
What Happens When Booting Linux with Low Memory
5:11
Nir Lichtman
Рет қаралды 62 М.
How A Steam Bug Deleted Someone’s Entire PC
11:49
Kevin Fang
Рет қаралды 941 М.
How a CPU Instruction Decoder and Instruction Execution Works
14:21
Why Didn't He Get the Job? Let's Find Out! // Code Review
27:25
The Cherno
Рет қаралды 86 М.
100+ Linux Things you Need to Know
12:23
Fireship
Рет қаралды 885 М.
Andrew Kelley   Practical Data Oriented Design (DoD)
46:40
ChimiChanga
Рет қаралды 52 М.
researchers find an unfixable bug in EVERY ARM cpu
9:48
Low Level Learning
Рет қаралды 470 М.
Making Minimalist Web Server in C on Linux
10:23
Nir Lichtman
Рет қаралды 236 М.
Kernel 6.10 | Locked & Optimized
56:02
Maple Circuit
Рет қаралды 37 М.
Reading Kernel Source Code - Analysis of an Exploit
19:02
LiveOverflow
Рет қаралды 125 М.
Что делать если в телефон попала вода?
0:17
Лена Тропоцел
Рет қаралды 2,8 МЛН
iPhone 16 с инновационным аккумулятором
0:45
ÉЖИ АКСЁНОВ
Рет қаралды 9 МЛН
КРУТОЙ ТЕЛЕФОН
0:16
KINO KAIF
Рет қаралды 6 МЛН