How Linux Kernel Prints Text on Screen

  Рет қаралды 73,281

Nir Lichtman

Nir Lichtman

Күн бұрын

Пікірлер: 229
@nirlichtman
@nirlichtman 3 ай бұрын
- 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.
@MustiSapoo
@MustiSapoo 3 ай бұрын
@@nirlichtman Pls Make Linux OS But With Debian-Based
@MrMassaraksh
@MrMassaraksh 3 ай бұрын
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 4 ай бұрын
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 3 ай бұрын
I have used GDB for about a year now every week and learned new commands
@thescroogemcduck
@thescroogemcduck 3 ай бұрын
This is more than an intro on how to use GDB lol, I thought I was decent with it but this is next level.
@bagfleet
@bagfleet 4 ай бұрын
”we’re gonna have to dive in a little bit to the assembly”. What a madlad ❤
@Scoopta
@Scoopta 3 ай бұрын
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 3 ай бұрын
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 3 ай бұрын
@@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 3 ай бұрын
He's under three VMs
@LordDoucheBags
@LordDoucheBags 3 ай бұрын
@@marsovac wayland on newest nvidia drivers works well right now. Fedora btw
@MrEdrftgyuji
@MrEdrftgyuji 3 ай бұрын
A lot of corporate environments demand you use Edge.
@katiagalkina4607
@katiagalkina4607 3 ай бұрын
The rabbit hole is much deeper than I was thinking!
@lately-late
@lately-late 3 ай бұрын
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.
@matthias7534
@matthias7534 3 ай бұрын
no unnecessary talking, straight to the point, extremely well explained, this is why I pay for internet, thank you brother
@namanchhabra4136
@namanchhabra4136 4 ай бұрын
I always wanted to know kernel that deep 🙂
@MrLarossi
@MrLarossi 3 ай бұрын
we all like it deeper
@nickdaria
@nickdaria 3 ай бұрын
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 3 ай бұрын
This is like a whole subject at uni in less than 15 minutes. Subscribed!
@ismbks
@ismbks 4 ай бұрын
this feels like i'm watching paid content for free
@CornThatLefty
@CornThatLefty 3 ай бұрын
This series of videos is awesome. Just explains and explores a low-level topic quickly and without any fluff.
@CookieGod24
@CookieGod24 4 ай бұрын
I don’t know why but the way you say ‘config’ sounds satisfying
@patrickprucha5522
@patrickprucha5522 4 ай бұрын
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 3 ай бұрын
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!
@GrittyMaholmes
@GrittyMaholmes 3 ай бұрын
I love the confidence in your voice , i wana be this confidence when coding .
@stevep5759
@stevep5759 3 ай бұрын
Really fast paced and right to the point. New sub 🎉
@shahriarmorabi8945
@shahriarmorabi8945 2 ай бұрын
i have longed for this exact video for years. Thank you.
@sanderbos4243
@sanderbos4243 3 ай бұрын
This is such a good reference video for anyone wanting to dive into the kernel
@BorderKeeper
@BorderKeeper 3 ай бұрын
Programmer of 10 years here. This is straight up black magic.
@hobbesip1
@hobbesip1 Ай бұрын
This is a fire hose of awesome knowledge. Keep up this great work! And I'll spend the next week understanding and absorbing what you have demonstrated.
@khazarhajiyev7710
@khazarhajiyev7710 4 ай бұрын
Have been looking for a channel like that for a long time, thank you!
@autistadolinux5336
@autistadolinux5336 2 ай бұрын
clicked for the kernel, stayed for the gdb tutorial
@OrangeDied
@OrangeDied 4 ай бұрын
kys_write?? how rude...
@nyvyme
@nyvyme 4 ай бұрын
oh
@nyvyme
@nyvyme 4 ай бұрын
oh "kms" exist
@jackkendall6420
@jackkendall6420 4 ай бұрын
You should write text to the screen NOW!
@adama7752
@adama7752 4 ай бұрын
I agree, the side effects of this function are wild.
@kipchickensout
@kipchickensout 4 ай бұрын
​@@jackkendall6420 xD
@r4co351
@r4co351 2 ай бұрын
Just found out about your channel and I'm already hooked with it! שמח לראות שאתה מישראל 😊. Keep up the great work!
@nirlichtman
@nirlichtman 2 ай бұрын
תודה! :)
@someone5781
@someone5781 2 ай бұрын
This was super dope! Loved this technical deep dive! I learned a ton!
@waldmensch2010
@waldmensch2010 3 ай бұрын
these videos are so cool and nerdy and the best of it you learn so much
@piano_arts_2007
@piano_arts_2007 2 ай бұрын
I didn't know untill now that there's a lot of stuff under the hood just to print something on the screen but with all of this it really makes sense on why is this. Really cool video btw.
@yonatanelizarov6747
@yonatanelizarov6747 3 ай бұрын
Thanks man, really useful. Keep up the great work!
@vojtech_richter
@vojtech_richter 2 ай бұрын
This is so cool. Thank you very much Nir for these linux deepdives!
@MyWatermelonz
@MyWatermelonz 3 ай бұрын
Dang breh aside from just screen printing, I learned some gdb and vim. Lots of good stuff.
@notyourfox
@notyourfox 3 ай бұрын
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.
@galisma
@galisma 17 күн бұрын
Your content is great, I'm glad I found this channel :D
@orestissabethai830
@orestissabethai830 3 ай бұрын
We are going to need some more of that gdb magic you are doing. Nice video!
@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.
@cocogus
@cocogus 2 ай бұрын
Short and descriptive. Great video.
@yahiaghadiry9885
@yahiaghadiry9885 4 ай бұрын
Amazing video But I have a question, all those boot logs before printing the H, how are those printed.
@jameskuo2822
@jameskuo2822 3 ай бұрын
printk(); in kernel space, in (very, very) shorts. I do believe they use different ways to printf() to implement printk().
@Akronymus_
@Akronymus_ 3 ай бұрын
Finally found this vid. I clicked on a different one when seeing this in the periphery and was searching for it ever since.
@JohnnySacc
@JohnnySacc 3 ай бұрын
That was awesome, I'd love a full series of this
@eitantal726
@eitantal726 4 ай бұрын
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 4 ай бұрын
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 4 ай бұрын
@@thebuggerdev So the is full process something like this? (let's say, XTerm) printf -> kernel -> parent process -> x11
@thebuggerdev
@thebuggerdev 4 ай бұрын
@@eitantal726 yes, in this example XTerm is a parent process
@thebuggerdev
@thebuggerdev 4 ай бұрын
@@eitantal726 and to be precise: communication of xterm with x11 is also done by kernel's functions
@atharvakamble5785
@atharvakamble5785 3 ай бұрын
This video is insanely good, not many like these!
@h3ssan
@h3ssan Ай бұрын
Delicious content! Need more of this, Thank You!
@golarac6433
@golarac6433 3 ай бұрын
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 3 ай бұрын
That's a good point, added information about this in the pinned comment.
@LeandroCoutinho
@LeandroCoutinho 3 ай бұрын
Amazing video! Linux kernel + gdb + qemu = ❤ I hope you manage to build more videos like this. =D Hardware and software interaction would be great. 😃
@Samstercraft77
@Samstercraft77 3 ай бұрын
Now THIS is top quality content
@whamer100
@whamer100 3 ай бұрын
wow i didnt expect displaying text to be so complicated, that's interesting
@MadMathMike
@MadMathMike 3 ай бұрын
You're a freaking wizard, Nic. Great video! 👍😊
@Jonathan-ru9zl
@Jonathan-ru9zl 4 ай бұрын
You back!
@AK-vx4dy
@AK-vx4dy 3 ай бұрын
Excellent job and crazy skills 🤯
@ricozhuang7625
@ricozhuang7625 3 ай бұрын
That is deeper than I thought
@callummacleod2177
@callummacleod2177 3 ай бұрын
Excellent information presentation 👌
@VaibhavSharma-zj4gk
@VaibhavSharma-zj4gk 3 ай бұрын
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 3 ай бұрын
Depends on which parts you were and weren't able to follow. Any GDB tutorial will be a good place to start
@nirlichtman
@nirlichtman 3 ай бұрын
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
@pablote325
@pablote325 3 ай бұрын
this is an insanely good video.... thanks
@Swampdragon102
@Swampdragon102 3 ай бұрын
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 3 ай бұрын
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 3 ай бұрын
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.
@saurabhrajguru1636
@saurabhrajguru1636 2 ай бұрын
beautifully broken down. thanks!
@cosmiclattemusic
@cosmiclattemusic 3 ай бұрын
this is why I love KZbin
@gustawitresh
@gustawitresh 3 ай бұрын
idk why, but this is fun to watch.
@Samstercraft77
@Samstercraft77 3 ай бұрын
THE HELLO WORLD TYPING SPEED IS CRAZY
@Joker9586
@Joker9586 3 ай бұрын
Very interesting insight! Great content, thank you sir
@pal-v3d
@pal-v3d 2 ай бұрын
Hoping more videos like this. ❤
@MO-fg2cm
@MO-fg2cm 3 ай бұрын
Damn the knowledge I got through this video is amazing
@dovonun
@dovonun 3 ай бұрын
You are an absolute legend 🤯
@iyar220
@iyar220 4 ай бұрын
Yayyy
@valerys.219
@valerys.219 3 ай бұрын
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.
@theforeskinsnatcher373
@theforeskinsnatcher373 3 ай бұрын
some cool gdb tricks I didn't know. But I think I'll use the tui/disassembly view instead of jumping to addresses
@ghostsdefeated4078
@ghostsdefeated4078 3 ай бұрын
this channel is cracked
@eliphazbouye
@eliphazbouye 4 ай бұрын
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 4 ай бұрын
Thanks! Check out my welcome page for more information and recommended resources (link on my channel)
@eliphazbouye
@eliphazbouye 3 ай бұрын
@@nirlichtman Very awesome thank you 🙏
@iflux8821
@iflux8821 2 ай бұрын
This is great! Thank you very much!
@YRBYD
@YRBYD 3 ай бұрын
Great video!
@skylarmorknerbrown
@skylarmorknerbrown 3 ай бұрын
This man is making some of the most informative and interesting Linux videos on all of youtube... using Windows 10
@muhammadmahad
@muhammadmahad 3 ай бұрын
Thanks for such an amazing video.
@muhammadmahad
@muhammadmahad 3 ай бұрын
Could you please share the tips to become good in low level things just like you?
@nirlichtman
@nirlichtman 3 ай бұрын
Yes, there are a bunch of tips on my welcome page, link in the channel description
@muhammadmahad
@muhammadmahad 3 ай бұрын
@@nirlichtman Thank you Nir :)
@nathanielthomas4437
@nathanielthomas4437 3 ай бұрын
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()!
@为民程
@为民程 3 ай бұрын
learns a lot, thanks!
@BudgiePanic
@BudgiePanic 3 ай бұрын
Very cool. How do you get so comfortable with CLI tools? It's like you don't even need a mouse.
@nirlichtman
@nirlichtman 3 ай бұрын
Check the welcome link on my channel for recommended learning resources and additional information, I indeed prefer using the keyboard over mouse control in a lot of cases, but I wouldn't say a mouse is completely unneeded, for example for graphical stuff it is very useful.
@ecuas_7
@ecuas_7 3 ай бұрын
This is so cool, thank you
@MrMassaraksh
@MrMassaraksh 3 ай бұрын
Thank you! Good stuff
@farpurple
@farpurple Ай бұрын
You just went deeper and deeper, and when you met the floor, you just got smaller, and went even deeper between atoms, between quarks, between folds of reality...
@ElPikacupacabra
@ElPikacupacabra 3 ай бұрын
Why did it print 3 "H"? I tought it would continue with the other letters...
@nirlichtman
@nirlichtman 3 ай бұрын
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 3 ай бұрын
@@nirlichtman Ah, right. You did not update just the top byte.
@cyberbiosecurity
@cyberbiosecurity 3 ай бұрын
Awesome, thank you
@mimovk
@mimovk 2 ай бұрын
How did u acquire all of this knowledge? Any courses or routes you recommend? Thanks
@nirlichtman
@nirlichtman 2 ай бұрын
Check out the welcome link on my channel for recommended resources
@umikaliprivate
@umikaliprivate 3 ай бұрын
Could you make a video about how to make a simple wayland-based window manager?
@gustawitresh
@gustawitresh 3 ай бұрын
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 3 ай бұрын
"it's more fun to read" omg
@szaszm_
@szaszm_ 3 ай бұрын
what's crazy about that? You pretty much have your preference if you ever worked with x86 assembly.
@la.zanmal.
@la.zanmal. 3 ай бұрын
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".
@app3264
@app3264 3 ай бұрын
Love your videos!
@coshvjicujmlqef6047
@coshvjicujmlqef6047 2 ай бұрын
how does kernel printk work? i do not want to use format string but just write
@sezarstarscourge7368
@sezarstarscourge7368 3 ай бұрын
wonderful explaination ,
@kaankarakoc7680
@kaankarakoc7680 4 ай бұрын
thanks for another great video!
@GreeneThumbs
@GreeneThumbs 3 ай бұрын
This is fantastic
@sierra991
@sierra991 3 ай бұрын
i feel like i am linus torvalds after watching this video
@abdelrahmanyasser5720
@abdelrahmanyasser5720 3 ай бұрын
Great job, Thanks bro
@justinnamilee
@justinnamilee 3 ай бұрын
Oh damn, I'm coming in for another "Neat!"
@David-wh8zs
@David-wh8zs 4 ай бұрын
This is such a good video
@matematikaadit
@matematikaadit 3 ай бұрын
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?
@mickolesmana5899
@mickolesmana5899 3 ай бұрын
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 3 ай бұрын
*WSL :)
@mickolesmana5899
@mickolesmana5899 3 ай бұрын
@@nirlichtman WSL? EVEN BETTER
@soleroks
@soleroks 3 ай бұрын
Well done.
@doug9000
@doug9000 3 ай бұрын
would be cool to show how graphical virtual terminals work in low level too.
@Nop_Nop_0x90
@Nop_Nop_0x90 3 ай бұрын
Can you start a series on deeo dive into Linux kernal ? (A real detailed one)
@nirlichtman
@nirlichtman 3 ай бұрын
More kernel videos are planned :)
@joshjackson3471
@joshjackson3471 3 ай бұрын
Amazingly informative video, I was always interested in the deeper workings of printing text but I don't have the Linux knowledge yet to pursue it myselfSomething I noticed while watching, I think the reason why you couldn't modify the tc value in gdb was because it's a string or struct pointer; that's usually where I see the lvalue error in my own programming at least. Could probably dereference it and then set the value
@jayhanjaelee
@jayhanjaelee 3 ай бұрын
It’s so interesting👍
@conandoyle1859
@conandoyle1859 3 ай бұрын
great!
Making Simple Graphical Linux Distro from Scratch
17:19
Nir Lichtman
Рет қаралды 63 М.
Kernelless Kernel Programming (eBPF) - Computerphile
19:12
Computerphile
Рет қаралды 75 М.
小丑揭穿坏人的阴谋 #小丑 #天使 #shorts
00:35
好人小丑
Рет қаралды 38 МЛН
When u fight over the armrest
00:41
Adam W
Рет қаралды 16 МЛН
Diving into Windows Keyboard Driver
10:29
Nir Lichtman
Рет қаралды 86 М.
How Windows Kernel Draws Graphics
10:59
Nir Lichtman
Рет қаралды 50 М.
The 3 Laws of Writing Readable Code
5:28
Kantan Coding
Рет қаралды 683 М.
Signals. I spent 2 years to understand this part.
21:24
kimylamp
Рет қаралды 252 М.
The moment we stopped understanding AI [AlexNet]
17:38
Welch Labs
Рет қаралды 1,2 МЛН
Reading Kernel Source Code - Analysis of an Exploit
19:02
LiveOverflow
Рет қаралды 126 М.
How Do Linux Kernel Drivers Work? - Learning Resource
17:02
LiveOverflow
Рет қаралды 556 М.