We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Intermezzos

00:00

Formale Metadaten

Titel
Intermezzos
Serientitel
Anzahl der Teile
15
Autor
Lizenz
CC-Namensnennung 3.0 Unported:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen.
Identifikatoren
Herausgeber
Erscheinungsjahr
Sprache

Inhaltliche Metadaten

Fachgebiet
Genre
Ganze ZahlGüte der AnpassungSchedulingTranslation <Mathematik>MultiplikationsoperatorFormation <Mathematik>RechenschieberXMLUMLVorlesung/Konferenz
ProgrammierungSystemprogrammierungOperations ResearchPhysikalisches SystemSoftwareentwicklerKernel <Informatik>KreisflächeFAQZufallszahlenVerschlingungKreisringSichtenkonzeptQuellcodeSchreiben <Datenverarbeitung>ComputerZahlensystemWhiteboardDatenverwaltungMPMUmsetzung <Informatik>LaufzeitfehlerFormale SpracheMinimalgradNetzbetriebssystemProgrammierungPhysikalisches SystemKernel <Informatik>Projektive EbeneElement <Gruppentheorie>Twitter <Softwareplattform>ProgrammierspracheMereologieInformatikRechter WinkelDivergente ReiheNichtlinearer OperatorHecke-OperatorZahlensystemWeb logRadikal <Mathematik>ProgrammiergerätWeb SiteDigitale PhotographieData MiningCodeProblemorientierte ProgrammierspracheWeb-SeiteMultiplikationsoperatorTotal <Mathematik>NeuroinformatikNP-hartes Problem
Operations ResearchSystemprogrammierungMereologieFunktion <Mathematik>Physikalisches SystemSoftwareKernel <Informatik>HardwareDatenparallelitätAbstraktionsebeneSichtenkonzeptTDMAProgrammSystemplattformProzess <Informatik>AdressraumSpeicherschutzElektronische PublikationMusterspracheEndliche ModelltheorieFuzzy-LogikSpeicherabzugHardwareProgrammierungEin-AusgabePhysikalisches SystemAbstraktionsebeneVirtuelle MaschineDatenparallelitätAppletNetzbetriebssystemFormale SpracheTouchscreenMusterspracheKontrollstrukturGenerizitätMultiplikationsoperatorFunktionalRechter WinkelEinsSchnittmengeProgrammiergerätAdressraumMereologieInformatikKernel <Informatik>SoftwareWort <Informatik>VirtualisierungKartesische KoordinatenATMTypentheorieElektronische PublikationDifferenteProjektive EbeneArithmetisches MittelEndliche ModelltheorieTermersetzungssystemSystemplattformLie-GruppeHecke-OperatorMathematikerinSichtenkonzeptPhysikalismusProzess <Informatik>TDMAQuaderFuzzy-LogikFunktion <Mathematik>SpeicherabzugSpeicherschutzRechenwerkDatenausgabegerätDiagrammFlussdiagramm
Kernel <Informatik>ExistenzsatzPhysikalisches SystemComputerGrundraumPhysikalisches SystemDifferenteKernel <Informatik>TypentheorieLoopEreignishorizontProjektive EbeneProdukt <Mathematik>MultiplikationsoperatorPerfekte GruppeEindeutigkeitMarketinginformationssystemMixed RealityPunktFächer <Mathematik>NeuroinformatikNetzbetriebssystemRechter WinkelOntologie <Wissensverarbeitung>GrundraumDämpfungSchreiben <Datenverarbeitung>RechenschieberSystemprogrammierungNichtlinearer OperatorComputeranimation
GrundraumComputerGrundraumDämpfungProgrammierungPhysikalisches SystemNeuroinformatikPunktMessage-PassingNetzbetriebssystemProjektive EbeneComputeranimation
VideokonferenzProgrammierumgebungEmulationEmulatorAssemblerBinärdatenBinder <Informatik>Elektronische PublikationMarketinginformationssystemSichtenkonzeptSpeicherabzugViewerComputerLastKernel <Informatik>HardwareVerschlingungFunktion <Mathematik>ROM <Informatik>KontrollstrukturEin-AusgabeInformationE-MailTreiber <Programm>Demo <Programm>NetzbetriebssystemMixed RealityFunktion <Mathematik>Hecke-OperatorElektronische PublikationBootenEin-AusgabeWurm <Informatik>GarbentheorieGenerizitätMetadatenE-MailExogene VariableLastMereologieDienst <Informatik>HardwareSoftwareentwicklerSystemprogrammTypentheorieDifferenteEmulatorNeuroinformatikProjektive EbenePhysikalisches SystemFehlermeldungCodierungTouchscreenBinärcodeProgrammiergerätData MiningDemo <Programm>ProgrammierungKünstliches LebenBinder <Informatik>AssemblerWiederherstellung <Informatik>Web logQuick-SortSkriptsprachePixelVirtualisierungProgrammierumgebungBenutzerfreundlichkeitZweiunddreißig BitMultiplikationsoperatorBitInformationGrundsätze ordnungsmäßiger DatenverarbeitungATMMAPKernel <Informatik>NP-hartes ProblemTwitter <Softwareplattform>Computeranimation
SichtenkonzeptNabel <Mathematik>Hash-AlgorithmusBenutzerprofilBildschirmfensterVirtuelle MaschineHypermediaSchreiben <Datenverarbeitung>Freewarep-BlockVerzeichnisdienstSpezialrechnerElektronische PublikationFlächeninhaltPhysikalisches SystemSteuerwerkLASER <Mikrocomputer>Disk-ArrayBacktrackingThreadMultitaskingStrebePufferspeicherComputervirusPASS <Programm>SoftwaretestSchlussregelBitratePhysikalisches SystemPuffer <Netzplantechnik>CodeTreiber <Programm>NeuroinformatikSoftwaretestTouchscreenDatenstrukturOrtsoperatorProjektive EbeneProgram SlicingBitGenerizitätHochdruckNetzbetriebssystemDatenfeldAbstraktionsebeneZahlenbereichSechseckSchnittmengeHalbleiterspeicherWort <Informatik>GraphfärbungURLRechter WinkelGeradep-BlockDemo <Programm>RechenschieberKernel <Informatik>Spektrum <Mathematik>Komplex <Algebra>Nichtlinearer OperatorProgramm/QuellcodeComputeranimation
Nabel <Mathematik>SichtenkonzeptVerzeichnisdienstHilfesystemMultitaskingSteuerwerkHardware-in-the-loopEin-AusgabeNormierter RaumDynamisches RAMOvalBildschirmfensterVirtuelle MaschinePhysikalisches SystemCodep-BlockCodierungGüte der AnpassungVerschiebungsoperatorTypentheoriePunktTouchscreenRechter WinkelWort <Informatik>GraphfärbungQuick-SortKernel <Informatik>DickeHidden-Markov-ModellURLZahlenbereichNetzbetriebssystemDifferenzkernAbstraktionsebeneSoftwareentwicklerCompilerMereologieRohdatenProgram SlicingPuffer <Netzplantechnik>Physikalisches SystemMessage-PassingCodierung <Programmierung>Prozess <Informatik>Notepad-ComputerKünstliches LebenProgrammbibliothekSampler <Musikinstrument>Computeranimation
Nabel <Mathematik>SichtenkonzeptPhysikalisches SystemElektronische PublikationBildschirmfensterLesezeichen <Internet>CodeKernel <Informatik>SchlüsselverwaltungSchreib-Lese-KopfFrequenzPhysikalisches SystemCodeGraphfärbungNetzbetriebssystemNormalvektorDemo <Programm>Projektive EbeneSchreiben <Datenverarbeitung>SoftwareentwicklerTypentheoriePunktMultiplikationsoperatorRechter WinkelDefaultOrtsoperatorExpertensystemProgramm/QuellcodeComputeranimation
Ganze Zahl
Transkript: Englisch(automatisch erzeugt)
Hey everyone, as you might notice this is not a talk about rust in translation It's cool because it does say that on the schedule I'm gonna put pull in audible. Is that like a sports thing? All right, cool something like that and
and We're gone Hopefully we'll be back up in a second Is everyone having a good time at Rust Bell Rust? Yeah, I am extremely excited that Carol and Jake and the entire team decided to throw this There's some of my favorite people and I like coming to Pittsburgh a lot
so What's up with the slides? All right Hi If the trick is unplugging it and plugging it back in I'm gonna be pretty sad myself. All right, we're back
AV teams AV is so hard
Alright cool. So I'm actually giving a talk today about Inter Mesos, which is a teaching operating system and we'll get into that in a second But hi, my name is Ashley Williams. I go by AG dubs on Twitter. You may know me from that
I don't recommend you follow me on Twitter. I tweet too much And so I'm a little bit out of my element because I actually work for a company called NPM Does anyone here know what NPM is? Cool, no left pad jokes. I swear Take you out if you do that. Anyways, I work for a company called NPM
We're a package manager for JavaScript. I sit on the board of directors of a language called node JS Well, it's not really a language. It's a runtime. But again, these are details that don't matter You could say that I'm a JavaScript person and I was so glad to hear that conversation about tribalism earlier because
Sometimes in the rest community you hear grumbles about this lovely little language But I started out actually as a Rubyist and the language that I learned right after Ruby was actually Erlang In general you could say that I really really really love programming languages so much
And one of the reasons I like programming languages is because I really like thinking about thinking I don't have a computer science degree. My degree is in neuroscience and philosophy but that being said I do like thinking about the thinking that happens when people write code and
One of the things that this kind of desire of mine has led to is working on this really neat project called Intermesos and some of you got to be part of our very first workshop yesterday, but this project actually started From a little funny story But first I'll say Intermesos is a teaching operating system specifically focused on introducing systems programming concepts
To people who kind of know a programming language, but are not familiar with systems programming One of the ways that the people who work at it like to describe it is that it's like, okay You can write some JavaScript now. Let's write an operating system
And the way this kind of started was was sort of interesting So I started this with someone who will go completely unnamed, but he looks exactly like his Twitter photo Which you may or may not have seen and he he was like, hey Do you want to like stay in tonight put on some comfy pants and do a neat kernel tutorial? And I was like, oh, yeah. Heck. Yes, I do. Let's get close to the middle
Let's do this and then I was like, oh wait, wait Can I write an operating system? Should I write an operating system? Like I was so worried I baked a whole cake. Just kidding
I don't know how to bake a cake But I was nervous and part of this nervousness was coming from the fact that there's this amazing little website called OS dev.org has anyone been to this website? Keep your hands up if you were motivated and enthused by it All right, well, I'm gonna talk to you about a part that made me feel pretty terrible
All right, and it's this page called required knowledge and there's some really really special parts in this But just to make sure it's absolutely clear. I think that this page is garbage total garbage, so it starts off by saying that you need to have an understanding of Basic computer science, which includes being intimately familiar with hexadecimal and binary notation
Who here is intimately familiar with hexadecimal notation All right There were more people in Germany who felt like they were when I did this the other time But seriously, you want to be intimately familiar with ever. I don't know that is ridiculous
Alright, then they went ahead and said with programming experience that learning about programming with an operating systems project is Considered harmful. All right, let's just do away with considered harmful That's like not a cool thing to say and doesn't make any sense And lastly they let you know that failure to comply with any of this required knowledge
Would make you look silly And that's how you know, the website is mostly run by 15 year old boys I know this because I have at least one confirmed person who is a 15 year old boy who is really into this website So yes failure to comply will make you look silly. I mean looking silly maybe isn't all that awful
But anyways, this is not a cool idea I'm not into this at all And so what's interesting is that when we think about doing developing of operating systems or any systems level programming There's definitely this social feel that like this is for the elite programmers This is not for like, oh you like write CSS. Definitely don't write an operating system. Stay away. This is not for you
And that's really goofy and so to go back to the story when the intermesos project kind of came to its inception Was this kernel tutorial and this kernel tutorial was written by this awesome person named Philip Opperman And it was a series of blog posts called writing an operating system in rust
And you can check that out by going to this URL right here and it was super great The idea is that anybody can write an operating system and not only can anyone write one, but they should write one All right, so I was like, all right. Yeah, I can operating system and so can you this is great All right, let's do this
So I did that night we stayed in worked for like five or six hours and I got this Amazing very very very very very small Operating system that I wrote in rust and I was extremely excited to share this Of course you see here like okay. This is the operating system It looks like you printed holo world to the terminal and I did and it is an operating system
But there is a good question of like what what is operating system right? Like what the heck? You might be hard-pressed to actually kind of define what an operating system is and it turns out that a lot of people people Who are very respected in operating systems also struggle with defining it
So there's three definitions that we were able to find This first one comes from a book called modern operating systems and they say it's hard to pin down what an operating system is other than Saying it is the software that runs in kernel mode So that's like a bunch of words that they also haven't defined. So we have no definition so far And even that is not always true. So no definition. That's also not always true cool
Part of the problem is that operating systems perform two basically unrelated functions Providing application programmers a clean abstract set of resources instead of the messy hardware ones And then also managing these hardware resources. Okay, so we have something going on with the kind of like some abstractions hardware
The next but like they're not like really deciding, you know, I haven't really said anything for sure So the next one very short a book called three easy pieces and they say virtualization concurrency and persistence Those are good words
I Still don't understand what operating system is and then so here from something called exterminate all operating systems abstractions We see that an operating system is software that securely multiplexes and abstracts physical resources Wait for it We believe that the definition specifically
This definition specifically its view on the operating system as an abstract of hardware is crippling and wrong All right, so what's All right, we don't really have a definition what's going on So in in the intermesos book we have to deal with this question And so we define it like this and so of course a bunch of the people who we just read their definitions kind of
Say this is wrong But we say an operating system is a program that provides a platform for other programs It provides mainly two things to these programs Abstractions and isolation and abstractions and isolation kind of work as two sides of the same piece of paper here And so then the question is kind of like well
Abstractions, isn't that what we're doing all the time in computer science. Maybe it's what we're doing all the time always But what kinds of operating abstractions? So the common abstractions that an operating system is going to provide are going to be things like address spaces memory protection Processes files and sometimes input output devices So when we looked at my tiny little operating system what it was doing it was just dealing with
Outputting to the screen. And so yes, it was a very very small operating system But there's a kind of neat way of talking about these abstractions and why particularly the abstractions of an operating system are important So what you can imagine is that you have a program and you want that program to run on Hardware A
If you just have Hardware A writing a program just for Hardware A isn't all that difficult But it's also not all that interesting and it turns out that we have a lot of hardware so if we want to write a program for Hardware A and Hardware B What we need to do is we need to put an abstraction in the middle and what we see here
Is that operating system is going to be that exact abstraction? now You might also be familiar with the fact that you might want to write programs for more than one Operating system and then what you can see here is we follow the same pattern of abstraction and throw a virtual machine right there in The middle now again with the tribalism of languages, perhaps we don't have people who are so fond of Java here
But this is one of the awesome things that Java did with Java's virtual machine So these abstractions can and while they follow the same kind of pattern be really important and have huge implications so we have this kind of generic pattern of how these abstractions work where we say we have a an A is explicitly written for X, but I'd really like to support X and Y and so I'm going to put
abstraction B in the middle All right, so quick break If you get anything from this talk, I love throwing this quote in my talks This is a mathematician named George E. Box. And so we're talking about abstractions, right?
And so he has this amazing quote and he says remember All models or here we can understand the word abstractions remember all abstractions are wrong The practical question is how wrong do they have to be to not be useful?
So why am I saying this? I'm saying this is because my favorite definition of operating systems is an operating systems job is to lie All right, it is providing abstractions and is providing those abstractions and those abstractions are lies We're gonna tell the program that the program can use all of them, right? There's no other programs out there when it's running a program. I can just believe that
Alright now that's kind of heavy. And so if you're trying to get beginners excited about operating systems I mean depending on to the type of person maybe you could be like we're gonna build a program That's just full of lies and you're like, let's do it But instead instead we went with this word intermezzo Which is a noun that means a light dramatic musical or performance that's inserted between acts of a play
And this was a really great name for a lot of reasons first off It really played on that idea of abstractions that the abstractions is what you stick in the middle of something But also it's something kind of light. This is a hobby OS, right? We're not actually trying to like rewrite Linux or Unix. We don't want to do that
And so this is the name that we chose for the project Now the next question is or it maybe we kind of have an idea of what our operating system is What the heck is a kernel sometimes people say kernel and they mean operating system I think or kernel up. What is the difference? All right, so this is definitely a little bit fuzzy And you hear things like the software that runs in kernel mode
But even that's not always true The way I use the word kernel is just to mean this is like the kind of core part of the operating system So you have an operating system and the kernel it's kind of the middle part and if you have a super super small one Maybe the middle part is just the whole part So an operating system or a kernel I kind of use them interchangeably
And if you'd like to fight with me about that we can do it in the hallway All right, so a lot of things and this has become something that's kind of popular recently Is they're all different types of kernels. So one that you might be familiar with Unix monolithic kernel But there's also micro kernels and exo kernels and unit kernels and all these different types of kernels
I don't know. There's so many types Alright, what's the difference? I don't know So it's whatever someone recently said in medium and that joke was so good it broke the AV again Yeah, I don't know why the AV didn't work anymore
Alright Have you tried plugging it in? Let's see. I do not know so How cool is it that it's not raining today? Yeah All right, let's see and we're back. All right, that may or may not be happening every once in a while
So let's get used to it cool. So again, if you missed any of the important types of kernels, they're all listed here I did post my slides Please write medium think pieces on all of them But yeah, okay all these different types of kernels all these white dude actors have no idea what's going on And probably the people writing kernels don't know what's going on
So a big theme here is that systems programming is supposed to be so official and serious It was like most of the times we're just kind of making it up as we go We don't even have like a defined like ontology for how to even talk about these things Alright, so then the next question is alright, so you're gonna build an operating system. What kind of operating system?
You know what? Gosh, there's a lot of questions here a lot of questions and it turns out what kind of operating system it doesn't matter Alright, we could waste tons of time trying to design this perfect operating system We could spend time drawing it out writing all product specs But we'll never actually build it and the whole point of the intermezzles project Is that you're going in and getting dirty and just trying to figure some stuff out
Alright, the goal here is to learn and it's definitely not to make the best operating system that ever existed Recently when we were talking about like as we're continuing to build in our maze us out or like Oh, maybe we'll do like any kind of Unix style way, but then recently we've been talking about Futures is out and rust that's pretty cool What if we kind of modeled the the operating system on like v8 and the event loop and no
That'd be that'd be pretty neat and like is that gonna be the best operating system ever? Probably not but it's probably gonna be really interesting So again when we talk about what is operating system finally, I was like gosh this question. What is it? What is it and I came up with this because I'm a huge Carl Sagan fan
So what is operating system if you wish to computer from scratch you must first invent the universe I mean invent an operating system. The operating system is kind of the universe here and It's funny because I originally one of the first talks I ever gave is called if you wish to learn es6 from scratch It was first invent the universe and I realized last night
I'm pretty sure all the conference talks I've ever given are just slowly becoming the same talk So the whole like kind of message here that I really want to say is yes operating systems cool Let's do some stuff But you know if you want to be an awesome program or whatever you don't have to invent the universe But that's not really the problem It's it's the idea that if you want to a lot of people tell you you can't and I want to say no
If you want to invent the universe you absolutely can and if you want to You should And that's the whole point of intermesos So what we're doing here is like let's make the computer do a thing with like basically nothing else That's that's what building an operating system is when we're thinking about the intermesos project
And as I say get low you know it get low level programming. Yeah Sorry, I'm trying to delete it. I'm sorry Okay All right, so let's take a look at what intermesos actually looks like so we're gonna do some Awesome demo time in a second, but one of the tricky things about building an operating system
Is there's actually quite a few prerequisites. It's kind of complicated so what I'll quickly do before we do some demos It's talking about kind of getting up and running What our Linux dependencies are and some utilities that you can use to help yourself out? And so when I talk about getting up and running I absolutely love this tweet this from a colleague of mine from a few years ago
And he writes I wonder how many programmers went their entire career without ever getting their development environment Working anyone in here who still doesn't have their development environment working. Yeah, there. We go. Yeah, this stuff is so hard I was recently a friend visited me in New York City And we were kind of talking about the intermesos project, and he was like he finally was just like
How do you do that like don't you're already running an operating system on your computer? So how do you and it's like yeah, this is really really hard It's kind of even hard to conceive you don't even know what questions to really ask to figure out what tools So these are the tools that the intermesos project uses
There's something called NASM Which is the assembler there's been called LD which is the linker if you're working on a Mac You have to like use a different linker and that makes everything difficult Believe it or not the Mac operating system is by far the hardest one to get this stuff working on So for all of its like ease of use for all these other things
It was extremely difficult to get this kind of stuff started what I originally was working on Phil Opperman's tutorial I'm actually listed in his blog post now because I started trying to build it on my Chromebook pixel and couldn't forward the graphics And then I tried to get it up and running on the Mac And I eventually had to write like a vagrant file for it because it was just completely completely impossible
Luckily somebody has written an awesome script that usually can mostly take care of all the things you need Computers right how do they work so after the linker there's this thing called grub This is probably the one thing that you've maybe seen before if you haven't worked in any sort of operating systems development It's that thing that kind of shows up at the beginning of your like
I don't know probably this is like a decade ago It would show up at the beginning when you're booting up your computer If say you had like a rescue disk in there, and then you could select it It was like blue and white you knew that you were in trouble if you saw it Yeah, and then after grub. There's this amazing I Imagine it's X or ISO, but I really like calling it chorizo
So please confirm that I'm a hundred percent correct only I am not I don't want to be disabused of this idea But then finally the thing that really is what made it click for me as to how are you actually going to develop this? operating system is this super awesome thing called chemo which Depending on what type of operating system you are trying to run on what type of hardware on your computer is either just a virtualizer
Or an emulator so it's gonna let you be able to build things on to run operating systems like on a virtual hardware Or you could just you can also emulate different types of hardware, so you can try writing operating systems for those as well
So and then finally there's these neat utilities So something I do have to say about operating systems development And this is why it's so great that we're able to move some of it so much of our project into rust Is because when you're not in rust the error messages are really really bad Like just fill the screen with a bunch of garbage that does not make any sense
when I first gave this talk I actually did some assembly live coding and Messed up and was able to demonstrate just how terrible those errors are We won't be live coding assembly today, but take it from me the errors are pretty brutal but these are two pretty awesome utilities that you can install that will be able to
Let you kind of inspect the binaries and stuff that you end up creating and that can be nice So when we're thinking about building an operating system We kind of need to understand all right what happens when we turn on our computer And luckily we have a lot of us when we're doing development Don't have to think about these things, but in general what happens is
The first step is you have the hardware load something called BIOS which stands for basic input output Service all of these names sound like kind of like dystopian generic corporations to me and Then BIOS loads grub which I like to think of as like a cute little worm, but it stands for grand unified bootloader
Which definitely sounds fascist? And then lastly lastly then grub loads our kernel all right, and so we've done all of this And part of the reason this was able to work is because you use that thing called LD to link some stuff together And so this linking is talking about how sections and input files should be mapped to the output files
This is really like at least in the way. I understand it like pretty just fancy concatenation But what's important about this is that it just makes sure that the header info is up at the top So that grub knows what the heck is trying to load And you can understand these headers like similar to the way you think of requests and response headers in HTTP
It's really that it's just giving you some metadata about what you need to do And so what comes next after that and so this is a really complicated part And this is by far the hardest part that we've done in the operating system so far is Jumping into long mode does anyone here know what long mode is all right cool. We got some people
So when every computer starts up it originally thinks that it's in 32-bit mode Even though it could potentially be in 64-bit mode and so every time it starts up It needs to do this kind of impossible thing which is like I think I'm one thing and I am just going to dive into this impossible thing that I maybe can't do and then suddenly
Oh, I am okay. I could I could be 64-bit and when we were doing that workshop yesterday Steve said Is very endearing that my computer is willing to jump off a cliff for me every time it turns on So that's probably the best way to describe what long mode is Okay, so we've talked a lot about all these kind of different steps in the operating system
Let's take a look at what intermesos actually looks like so may the demo gods be with me Hopefully we also keep the AV All right, so Firstly I'll say I've posted all these slides and the demos to the github and tweeted them out
So if you're interested in playing around with these, but this is the actual intermesos code that you can also contribute to So the first thing I'm going to do is just going to load up our bare-bones kernel So we can see in here. This is actually running in rust. So we've written it out in rust and we can take a look
At This and so what we have right now Is here's our k-main and inside this safe block. We have a bunch of these lines and so what you can see here pretty much is happening is I'm defining a variable and This right here is the location on the screen that I want to put something and then right here is actually
a set of characters and color codes In hex Alright, so let's take a look at what this looks like so I can just run make run right here I'm gonna pop this up and
Here is the amazing operating system saying hi to rust belt rust This is the doge operating system. I Spent so long manipulating those little numbers to try and get it. It's ridiculous So but fundamentally like if we take a look at this
That code again This code is not great And so if you wanted, you know, I mean, this is basically just like the most technically complex MS paint ever Like extremely complicated. All I want to do is like put colors and words on the screen and I'm doing this instead
And so oh, there we go. It's alright. I know how to fix it I don't know what's going on. Do I have like an electromagnetic field around me? I Was not hating on MS paint at all that was that was all love trust me on that Love MS paint. All right, and we're back cool
Yes, so again, all I'm doing that is there are definitely ways that we can use rust To make this abstraction a lot nicer So let's take a look at that So one of the last I guess systems programming rust dates that I was on
We decided that we were like, let's let's write this VGA driver and let's write it in rust and let's test drive it and The reason that we're able to do this is because the way things are printed to the screen is just memory mapped so we can kind of abstract this idea of what we're printing onto the screen as a slice and
Then we can all we need to do is take that slice and then just stick it onto the screen and we'll create Write out all those characters. And so what we did is we abstracted out the VGA driver, which is here and I'll pull this up here And so again, this is another rust project and we have some tests And so like any good show a little bit of this is pre-baked
But if I run cargo test, all right We can see a one failure and this is this flush method and what the flush method is going to do is it's going to take a Slice that we have inside of a struct called VGA. I'll just pop that up here
Alright, so we're in here and we just have this simple struct We're kind of doing a fun thing with generics up there, which I'm not going to explain right now But we have this struct where we have this slice That is that fun generic then we have a buffer which is just this array of u8s
And then we have a position So again, we can kind of see what we saw on that previous screen where the position is really just where on the screen do We want to start placing something And then the buffer is going to be that data that we want to write to it and then the slice is going to be we're going to take that data in the buffer and we're gonna Put it onto the slice and the slice is going to be how it ends up getting written to the screen
And so the one method that we need to right now is that flush method? So based on what I just told you right now, we're just panicking As one should We're writing systems code. It's scary. It's not really all that scary And so with this flush method based on the structures that we've already built. All we need to do is say self dot slice
as mute And then we're going to clone from slice and we're just going to grab that Buffer data here and so writing this we can just save it and then I run cargo test
And we're passing yay I have to say being able to do systems programming in a test-driven way. It was like kind of awesome It gives you a lot more Security and like when we were originally doing it and I'll show you some screenshots from that where we're just throwing stuff out there And saying like well the computer light on fire. I have no idea
All right So now that we have our VGA Driver working we can now take this rust that we've written right here and we can drop it into that bare-bones kernel So let's go back to our bare-bones kernel here we are All right, clear this This big enough for everyone to see I tried to guess. All right, cool. Just shout at me if it's not
All right. So in here, we're gonna go into our main CD into yeah, good job, Ashley Live coding is scary. All right, so we have all of this Fascinating code inside this unsafe block
We're gonna get rid of all of that. Yeah. Yeah deleting code. It's fun Yay love to the encode Okay, so now inside this safe block what we're going to do is we're going to use our VGA crate So to use that we're gonna go into our cargo tommel and we're gonna add it as a dependency
Just get rid of that quickly. All right If you are new to us and didn't know that you can just kind of pass something to a path you can it's pretty neat So we can just point that to our VGA right there. And then we're also going to need our libc
Because basically what we're doing with that relationship between the slice and the buffer is just so they could basically a memcpy And so that's what we're going to be using here So we'll add that And then we'll go back into our main pull them in X turn create VGA
Right, and then I'm also going to need to use When we are doing this, we are also implementing the right trait. So I need to make sure that that is In Scope cool, so we should be ready now to use our VGA crate, of course
Someone out there is being like I'll see a typo and it's gonna break. Well, we'll find out That's what the compiler is for Alright so in here now instead of just writing out all those variables with like the totally indecipherable numbers Now we can say something like let VGA equal VGA
VGA new Alright, and then what is this going to take? This is gonna have to take some sort of Slice so we can make our slice here and That slice is going to be kind of this like kind of funky method from raw parts mute
And that's because we really don't have like a lot of stuff when we're writing a operating system So we have to kind of do it from nothing. And so this is gonna take two things. It takes a location and a length Yes, thank you, that would be brutal I'd be so sad mess it up. All right, so we're gonna give it the location of just the top part of the screen there
I always forget how many Zeros, I need it's very complicated. But luckily we're not doing as many complicated numbers as we were doing before we're gonna take this as
All right, I'm making a little smaller just so we can actually read it across the screen And then we're gonna give it that length of 4,000 All right, and so this slice we should be able to pass to our VGA And this needs to be mute pretty sure yes Alright, so with just this setup now instead of having to write all that stuff that I wrote before now
I could just tell my VGA to write a stir and so what should I have it say? Hello world That escalated quickly All
Right, all right, and so I should be able to write this and then I can say VGA flush All right The reason we do it in these two steps is because we wanted to write to the screen all at once and not in Some weird incremental way. All right So assuming that I haven't completely messed up all of this typing we should be able to now come in here say make run
Oh, all right. What did I do? Hmm I think I did a JavaScript thing. Probably that's usually what happens Yes, this is not JSON This be equals. All right
and Witness me All right, so that was a lot of typing and we did it really fast But the whole point was to say that when we use rust in the system development
We can take something that is like kind of really difficult and like fiddly and Give ourselves some nice abstractions to work with so that can be fun So now it's much easier to take this amazing operating system slash fancy MS paint and like write all sorts of colors and words To the screen. It's very fun Yeah, all right. So this is actually at the point like we are doing workshops with intermesos right now
And this is the place that we get to but the kernel is actually significantly further along And so just quickly I want to show you I'm getting yelled at but I want to show you where it's at right now And so what you can do in the kernel now is you can say
Hey rust belt rust So you can actually type in Shift doesn't work. So the only thing I can do is this weird like shouty winky face But yeah a shouty winky face from the kernel And so this is where the kernel is right now And if you're interested in playing around with this we have like quite a few Things that you can go for go to from here if you want to start playing with that
Alright, so that's the end of the demos and let me wrap it up with some some quick final thoughts So one of the key things about intermesos is that it's not just oh, let's write an operating system It's let's write a book alongside the operating system and that's pretty intense. So why would you do that?
And this is a really cool Cartoon that Leslie Lamport talks about in a talk called writing for developers and he says I'm about to read it. So we'll just do that because I don't have any time anymore But he says writing is nature's way of letting you know how sloppy your thinking is and for a very long time
I've kind of reappropriated that and I also like to say that teaching is Nature's way of letting you know how sloppy your understanding is And so the key point here is that When you're teaching yourself something new one of the best ways to really understand it is to write it down and then also try
And teach it to other people. So I want to encourage you to go write some irresponsible code and Then go teach somebody else to do the same Here is what this looked like when I was trying to work on scroll and I forgot to multiply how many columns I had By two as it scrolled down a big green thing started happening It was really really funny and just kind of made all this weird glitch art
And so just a lot of people have been really motivated by this intermesos Project and so when you're also doing these types of things you can also be motivating these people There is an audience out there. Even if you don't believe you're an expert in something There's an audience for the way you explain it. And so we had our very first intermesos workshop
Yesterday, which was super awesome and a lot of people participated and that was fantastic One of the fun things that I wasn't able to show you in your demo is that if you shift the position by one? It inverts the color codes in the characters and the color that we use for default is actually the smiley face
Character so if you messed it up, you just got a bunch of smiley faces Which is honestly what I think is the best it's like let's write some terrible code and have it smile at us. It's awesome So I want to encourage you contribute to intermesos We're only okay So the last time when I did my first talk on intermesos
It was nine months old and I thought that was kind of like a strange incubation period so I just said it again But it's ten months old now We've got lots of contributors and you don't have to just contribute code to contribute There's also the book which also accepts tons of contributors So we want to contribute to intermesos We think you're great whoever you are if you have that nagging feeling in the back of your head saying oh
I can't write an operating system tell it that you don't think so. All right, and if someone says failure to comply will make you look silly Alright, that's awesome. Cool. Let's all look silly. So yes, I can operating system and so can you thanks