Okay, let's go and get start
Good afternoon, Everyone: So I good morning still still morning. yeah yeah So yeah, I'm gonna talk about things up so first off.
Just you know I have a
So a washer dryer is being delivered to my house like literally in like 5 min, so I might need to step out for a second.
So if the lecture gets paused or something, I will come back.
My you know my teenage kids are on it, and so hopefully they'll be able to take care of it.
But if not, I will have to intervene that's good yeah, that's good question.
Actually I wonder what it I wonder what else is running because i'm Sure, it's running something there's computers and everything nowadays.
So up,
So assignment 2 is graded. I just need a post
So
So midterms being graded sorry i'm behind that so i'm just getting, you know, just getting the tas out.
So i'm i'm just behind on things and assignment 3
So, and assignment 3 we're gonna talk about today because it's not quite done.
But I can tell you actually a lot about it. because
So yeah. So So looking at the deadlines right now I've extended the deadline for assignment for assignment 3 to November 20 first and assignment 4 to December seventh
tutorials you know i've been adjusted accordingly.
So yeah, you have more time for tutorials.
So 5 and 6 is for assignment. 3, 7 through 9 is for assignment 4.
So. So you do have more time, cause I built some time into schedule.
And now i'm definitely gonna need it so what we're gonna talk about today.
I have do have scheduling that I want to talk about.
But first what we're going to do is we're going to look at last year's assignment 3 because I'm actually basing it on this assignment this last year was actually do similarly so this is what
assignment. 3 is and i'm going to walk you through it today, because it's a I like this assignment.
I kind of want to give it to you but i'm making a modified version of it, because yeah, because there's a couple Yeah.
So i'll i'll explain so any more administrative things before I can start showing you this stuff
So feel free to look at assignment 3 from last year.
The solutions are there. Alright, well download lower case, uppercase D.
Changes the direction. Lower case D doesn't download so so it's kind of a little funny.
Okay. So
Okay. So now we have this thing called 3,000 makeup best,
So we have this 3,000. makeup fast sh so let me show you what it does, and then i'm going to explain how it works.
So first off what you do is you run it So you have to, you know, pseudo
Hold on 1 s Here.
Yeah. So the
Oh, oh, that's funny term color doesn't exist I have to look that up!
Why that? and there, that's the sign because i'm running in this weird terminal mode, so you should normally see this error.
But I will explain what's happening here. so what just happened. is I now have a directory.
I have like this. All these files and everything everything you know i've got a little prompt here, but things are kind of weird.
Because you'll notice that my file system is only 350 MB.
You definitely. Yeah, Okay, that's kind of weird thing and if I go into slash bin if I look at it, you'll notice here's a whole lot of symbolic links.
To too, busybox. So what this is
Okay, are They just they just showed up here so We'll if I have to duck out for a minute
I'm gonna I might need to get route Actually, I think we would get Roche in a second here.
Okay, can you hear embarking in the background. There he's parking out to bring him in here.
Okay, Good. Good. Okay. it's quite enough so so
I'll say slash
So we run this. we have this. It looks like this is entirely a computer
So this is part of the tech use to build Linux system.
So small Linux is, because if I go and
User. Soc: on a normal system. There are some symbolic links to other files. But mostly we're getting action separate programs.
But here we're just getting pointers to one program we did do a a change room.
Yes, we did. and that's that's part of what I want to talk about here is we're we're using a technology.
So
The key things you understand
So you've made a file system in a file
And there's this thing called change you know change route to make the new slash, and then
These are the 3 things you really need to understand so let's talk Busybox is probably easier thing to understand
This is the part you have to kind of go like. What this is.
A really cool little thing is that busy box is one binary, and that one by binary can basically be most of a Linux system, based all the user land stuff like it does everything
So here's what? So as inside of this is one program binary and inside of it, so like these are like it has all of this functionality in the one binary yeah, easy cat bees it to gzip you know, halt
I don't know. looking at this always makes me kind of go like what you can make file systems, hey?
Can. you can do networking it has sue ssu in it. So that's pseudo in it. I don't think it has pseudo in it.
But it has tail head touch right it's like it's a whole system.
So
Okay, So so let's let's explain that in a second here.
This is part of what we're Have to do so Why don't we use busybox all the time?
And you really, because the versions that are inside are pretty basic, but it has.
It has an editor, I think in it. Yeah. Vi. is built into it.
Is. so it has. Okay, so any other editors?
No, yeah but it's but it's kind of crazy that all the stuff here so
So remember that when you're
When you're using some like when you want to make a Linux system.
Oh, what are what are those Oh, what? Why are those at the beginning?
Because those are actual program binaries on a on a unix system.
I'll show you if I so we go so if I go here. let's go to the top here.
This should be at the top. Yeah, right there. see square bracket is right there.
It's a program binary I don't think i'm not seeing, you know just one thing is that sorry 1 s here
Hello!
I'll be right back I gotta be back in a second Okay, sorry
Okay, i'm back. Sorry about that I just found out there's complications.
There's always complications when things come when you get new appliances.
This is why having your house is just hey? Okay, So can you hear me?
Okay, okay, So back to where we were. So yeah. So square brackets actually a binary in there.
Yes, that exactly. Jen. you got it. Oh, okay, is that what double angle bracket. I a double square bracket.
That's good to know that it's just too is a different kind of That's good to remember that's not again.
Think that's understood by bash but that's not here So what I So you don't use busybox all the time.
But so what
So what is in a unix-like system, what actually happens?
So what you for, you know, so
I,
So there are 3 stages to understand what happens first
So first off you have the bootloader that's responsible for loading the kernel
Rob is the bootloader on most common system
But you can be a series of programs that start things up it doesn't just have to be, you know one after the bootloader
So we're gonna talk lots more about the colonel soon and exactly what how that fits into things.
But then
What does the Bios do? So this is what I was saying.
Is the boot, so
So so so What is
So init is very important in a unix system, because it is always got it down here.
So if you look here at my processes, you know they they keep creating, decreasing a number.
And then you notice process number one isn't it right here that's what I mean by it.
And they're always has to be a process number one and it is special because
So it's always process. Id one it is always its own pair of process.
The parent of one is one, and when it terminates the system shuts down, how is it running?
But taking 0% of memory
This is how much space is taking is it's only taking 12 MB on a 16 GB system.
So so calculate that as a percentage Yeah, yeah can you kill the in it process a terminal and manually cut shut everything down.
I'll take that as a typo they may shut everything down.
But yes, it it's exactly you can do that I definitely will not do that now.
Because yeah, yeah, yeah, the the big ass means sleep it? Yes.
Oh, so the yes, if you send the right signal to so in it will ignore a lot of signals.
It won't But if you're running as root like if if a regular process just sends a kill signal to in it, and it will just go like whatever.
But if Root sends a kill signal to one depending on the init, because there's different versions of it.
But definitely, and it may say, okay, i'll terminate and that's one way to shut your system down
So, especially
Most processes are sleeping most of the time they're not all running.
They're just waiting for something to do they're essentially seeing there.
If an event happens they're going to take care of it is this would be a safe way to shut down your system.
Not necessarily it's a little ungraceful it depends on what and it does which I mean what how your it is set up.
But most processes think most of the time if you look at them because think about it.
You have hundreds of processes, sometimes thousands. you only have a few cores.
Maybe you have 1, 2, 4, 8 16 you won't have many cores.
So that's the maximum number of processes that could be running at any time.
So everyone else has to wait their turn and they keep getting swap back and forth, and we're going to talk about that process more.
When I process a process of how to. So So this is, you know.
But this is this kind of like the pieces there and so what we're doing here when we go to the we're in this little environment.
Now, here's a thing. If I look at the process list all the processes on the system are here.
You know you can see all the processes here. Why can you see all the processes?
Because if you look at slash prompt everything is there so we're seeing the entire computer system here, But we look here, there's only a subset of files that's all there is
So you can't so you can't see any other file systems unless you mount them.
But if they're already mounted that yeah it gets a little complicated, but
Well, we can still see the rest of the system
So we aren't really isolated from things you know at all.
So
So what we want to so there's a concept of something called a container
Have you all heard of containers
Except have you all heard of Kubernetes
If you hurt you, Docker Docker as well.
Yes, Docker Docker. yeah, Docker Kubernetes and stuff.
These are all based on container containerization connector technologies.
So a container container is basically the same as as a true environment, except
So the idea is to make the system separate. so like, if in this environment, if I had made it so that when I did Psaux, and it only showed the processes that were running with this file system that would be a can be more like a
container and then you also do things and make sure the procedure.
I didn't take up too much space and stuff this is making a lesson fine. But now I can just type exit here, and i'm back to my regular terminal and I see i've got all the stuff I have on my
home system. so shit so change So one of the things that last time I was asking about was try to sew how change route isn't a full file system.
What i'm trying to do now with your new assignment 3 is show you how to make it more of a container, and there's a command I need to figure out if I can get that working then I can really show you
something cool. so i'm i'm really close and I just need to spend a little more time, and I think i'll get it working for you all, and then I think it will be fun for you to play with so let But
let's now look, let's not look through the shell scratch because it's not actually that complicated.
This is what the shell script is that sets up that whole environment.
So first of all we're, saying this is ben bash so it's there, and i've got some comments, and I've defined some variables, and then I have a little if statement.
That checks to see if A. If you Id equals 0 uid is the process.
I mean this is actually a shell variable that's defined by bash to to let us know whether we're with the uid of the current process, and if it's not user Id is not 0 we're not running
as root, and so says, Please run. The script is root next.
So this is signed to say, Yes, you have to run.
This is root, then it does some stuff here. so it first deletes the if.
If the image file, if it exists, then it does. A. Dd.
Command here to create one, and then it doesn't make file system. This all should be familiar to you from from tutorial 5 or 2, 18 which trail did you do that?
And I forgot now. so it's true I don't 5 yeah.
So say yes, you made a file system There and then we're now checking to see this is cleanup, so that you run the script more than once.
It should unmount everything that was there and Then sorry What's image image is a variable here defined 3,000 fs image here.
So these are just variables. So so we mount this we we, you know we unmount these unmount.
You know, just clean up, and then we make a new directory.
We mount the image there and then we see each of that directory, So, delete, if there's an old version there, we can delete it, and that's and then we you know, create this, and then we make a whole bunch
of directories. See all these directories? We make all these directories, and then we?
,
Sorry about that. They are delivering a washing a washer dry a washing machine.
They're now returning the washing machine because it's damaged
Yeah, anyway. back to where I was so so your question will be a question, Why is the is statement in square braces?
So actually, what's happening here is this is this What what this is after doing here is running the command left square bracket and left square bracket that is taking this is command line arguments Yeah, It's gosh
is not it's a very old fashioned programming environment. and it's got a lot of weird quirks and but it has.
Yeah, it is yeah. but you know once you figure it out it's not hard to do so.
So we checked to see it. So here we map, and then we make a bunch of directories. So these are all the directories that you expect to see on a normal system, you know, kind of things, and then we copy busybox to user
been, and by copying busy box user bin that's you know kind of thing.
And then we also copy a few other binaries here, and then do some stuff.
So the thing to understand here is we put busybox here i've also copied some of the things so busybox will run by itself.
But in order to get bashful to run, I have to also copy a bunch of other things.
So why do I? can? I just copy busybox, And that actually is everything I need.
But in order to get Bash to be there, I have to have all these other files.
There all this stuff here, all of these lines here are all to get Bash to work
Why is that? Well, it's very simple if we go to exactly you've got So if I do, an oh, sorry
Busybox is statically linked
Bash is dynamically linked. so when so that the bash binary depends upon all of these other things.
So all these things are as we copy bash but then we have to copy all the things Bash needs in order to work.
And so that's what all these lines are doing and then we make temp.
We give the permissions 1, 7, 7 on temp.
This is enabling the sticky bit on the temporary That's what the one here does that member.
That's if we go to
If you look at Temp directories, they always have our permissions that look like this.
Everyone can write to them. but when the sticky bit is set you can't remove files or belonging to another user, so that keeps things more peaceful in the temp directory, and then we have and then we copy
the password files. So we can do you know, So we actually have, you know, username and stuff, because otherwise we wouldn't have user names in this thing. And then we copy the
This term info thing is basically to copy the info on the terminal.
We're currently using So that that terminal information is there for bash to work properly, because remember, there's all these different types of tele types and other things and stuff.
Well, there's an entire database of them to tell what the different characteristics, and so that's those files off
Yeah, we we are discussing Bind Mouse Just yeah.
But first down. So then you copy, so then what i'm doing right here is I'm making a little shell script.
This will set up, and the idea is, I want this with this little shell.
Script is gonna run with busybox, but busybox running as sh.
And what we want to do is have busybox install itself in the new environment, and we want to run.
Ld config to basically configure the dynamic linker in that new environment.
And we want to make sure that these things get mounted.
So we make a little thing. Then we run, use chirop to run that program inside our new environment.
We get rid of the file, and then we change into it so now it's all set up.
So this is a whole thing of setting up a little environment and This is very much the kind of thing that docker containers do.
It's very much what you know kind of inside kubernetes cluster containers.
This is basically the setup they do the only difference is they're running them with more isolation.
Then you have here. This is much Latin. this is just has access to everything.
So that's the the basic idea of this of this government.
So I want to add the assignments going, to be based on something like this: I'm making a few enhancements to try to make it a little more isolated.
And so that's what I have to figure out because I think that will be a bit more interesting. But if I don't get that working, I will just do a variation on this.
So the business box is the file system that can do any same thing in the system can do It's not a file system.
It's a program, Remember, the file system is essentially a data structure for storing files that that is, that is, on a block device.
So when we rent. So if you go to if we go here when we run this, make Fs that is making a file system, that's what this one is doing.
And then we copy busy box into that file system
Does that make sense? Total program is using the file system. Look programs programs are files, right?
You have data files and your program binaries. busybox is interesting, because, so, if we
So look here now, we've checked we've changed rooted into here.
This is the file system. if you go into bin there's all these files here, but they're all symbolic links to busybox.
And what busybox does is it says what name am I being called as well?
I'm being called the zoom mount I will be you Mount today, and then, when you call it as touch it says, I will be touched today, so it can.
It essentially is a big giant case statement where it looks at the
Yeah, what's this? probably some sort of switch or something I'm not sure exactly how they do that.
But they're looking at the command line, argument what the program was they look at the command line 0, and say what was it called as, or does it specify some other way?
It says, based on that it does so there's all these little applets inside of busy boxes.
Let's it be a lot of different programs
Okay. So So what's interesting, busybox and something like minutes?
So minutes is Linux could use busybox.
But Linux, the Linux kernel.
For Linux, because Linux technically is just the kernel. so.
But like when we have something like the Posix standard or whatnot like.
So Posix, I guess, predates Linux. So all operating systems ideally fulfill a standard Api that has things like create a process, reserve memory, whatever whatever.
And so like in this case, busy box is just different because it's simlink.
These commands are part of the Posix standard is They Say it basically Posix is a standardized version of Unix, and Posix says you should have certain programs and part of Posix is things like you have Vi.
As an editor that's part of the project now i'm. Pretty sure I'm not talking sure, but certainly having a shell which understands basically shell commands ls as part of their cat is part of there all these things make up
a posix environment, and they should have certain submission busybox implement.
Most of that in one binary. Yeah, Posix is a yeah.
Posix is just a standard windows was windows was posix compliant, which meant it had a subsystem, and it still does actually.
Now. there's a different ways. but How I always had a subsystem which supported the posix standard.
Not that you did anything with it. and honestly, originally, the posix subsystem was there for.
Oh, for government contracts to basically say, do you have a posix environment?
Yes, not that you would ever run any software inside of it.
But technically you could now, of course, there's windows subsystem for Linux, which is basically a pot, a a very nice posix environment on that note about windows.
So when people say windows is a hybrid kernel, they just mean that it has an extended api that can handle more things than say the Linux kernel. i'm not sure what the I mean
Hybrid's kind of a funny term there is older versions of windows that's supported windows subsystem for Linux version.
One it actually supported the system calls of windows and Linux in one kernel.
But Wsl. 2 actually runs a separate Linux kernel.
I see, and on that note so you're talking about containerization. So like you have to install wsl 2 or whatever to run docker containers on a window system and I Guess there's these c.
Groups or whatever. there's a specific cisco that allocates memory and process isolation, and like it's a little just remember Wsl.
2 on windows is equivalent to running Linux and virtual box.
I see It's just no more nicely integrated you're running a full Linux system, and docker is a Linux technology.
So you need to run it on a Linux system.
So when you run docker on Mac Os or on windows, they are running a Linux system on top of it in a virtual machine makes sense.
Yeah, so if you didn't understand that you don't desktop.
So i'm so so, martin I want to get back to your question, your time with the difference between the loop back block device, and regular directory mountain tutorial 5.
So. So this all these files here they could be. Where do they live?
That is the question. Where are these files? In what file system?
Well, we know it's like df and df says we're in this file system.
This loop back file system. Now, whenever you see
Yeah, that's okay.
So whenever
So the so, Martin, do you see this loop back device here?
What it is it's a device that's associated with it so
It's a file system in a file. Yes, exactly so what this So here, all these things that I see here is really ever it's all in this file.
3,000 Fs. image
So if you see here, this is the size of the file system in bytes.
But you notice It's only taking up the you know it takes me up 24 MB.
But the file system actually is. Well, so this is yeah so this is all that's user.
But it's more that's used because it's yeah the numbers between here and here are are complicated because when you make a file system, it also occupies some of the blocks
A block device, just a file that represents a drive up.
Yes, it is it's a specific it it represents a drive in the sense of everything.
It's a drive that you access using a certain interface
Well, we have to explain special files, so I think this will make more sense.
We understand? Morehouse. yeah, what is the What does the integer represent?
Oh, Kashi, what is the integer represent in dev loopx!
It's just that there's a bunch of loop back devices
So like if I do a df dash a you'll notice that I actually have all these loop back devices, and they're all associated with snaps, because Snap is a container technology.
So it makes a bunch of little F has a bunch of file systems and files, and those all need to get mounted.
And so you know they're all these loop back devices so.
So other questions here? That's Why, i'd be a stupid question.
But what's the snap again? snap is a is a docker like technology for open to?
On my system you use on most on A, on a modern, to put 2 systems.
Most software comes packaged in a format called a deb which is essentially just an archive of files like a zip file that, you know, getting gets installed and have some scripts also for configuring things but they all
get mixed together. So all the things that use Ben user been all put together.
But snaps are allow you to install software that has been packaged by the software developer.
So on my system. Oh, I I can just say so if you're running a major browser
Firefox is not installed is not installed in user bit.
It's installed in snap bin
If we notice these are symbolic links to snap.
Would you go like? what? Why are they symbolic links to snap?
Because what you do is when you run these programs. it then redirects you to work.
Run firefox in the firefox container so because like what did I mean that there's a firefox container?
I'm saying that if you go into I go into my snap here and you go If I go into firefox.
Yeah, there's different versions there's an entire little file system here.
There's a user. there's a lib firefox there's all the libraries that firefox depends upon. there's a little program.
This is the Firefox launcher thing there's an icon there.
If you look in snap yeah some hooks is like there's all this stuff in here to make this stuff work, and it's all i'm in a separate file system here
So So the question is, why are we using this So how do you recognize a loop back device big by typing? Sp.
By checking to see what file system you're on by using Df: you can see like if I if I just go to slash.
I'm. Now in my main file, system if I go back here, I'm in this. So Df can tell you which file system you you're currently in or you can give it a director and i'll tell you what file system that is
part of so so containers
Cd. dash return she's the previous directory yes, and if you really want to do that, you can use push the and Pop D.
Then You're gonna have a whole stack of directories that you go in and come out of It's It's it can be useful.
There's lots of there are lots of shortcuts at the shell level to make life easy.
It's really a full interface that's very rich Yeah
So? why are fucking sugar
So this is the fundamental idea of using containers to distribute software.
It's because
So this is really the point of containers and this is why we're talking about is that when you when I type when I type Ls, as we've learned Ls would say which ls
Which else is this? And if I look at this, this is here.
So the functionality of Ls depends upon this binary.
Here in this program here depends on this file here, which is him a map. to this.
It depends on this one. it depends on this one, and then it may also.
And then this is just a started initially and then once it's running.
It may want other files. How do you know
So you could use it. So the loop yeah exactly you can use a loop back block device to set up a container to package a program. So that night reduce compile each. exactly.
That's exactly. why
So it Remember, the loop back device is just an abstraction over the disc, so
So
So when we look at Cont we look at a container.
Here, I go into, let's go into so if I go into 3,000 fs.
So let's say I go into town
And it says, this, here, is it so? If I do
It's my room. This command here
This is gonna run for a second. I now have taken up all the space in the container
What if I go here? I haven't run out of space by making these separate file systems as files?
I've isolated the files from each other including the total space allocated to it.
So if I fill up the file system or I do a thing to it, it doesn't mess with anyone else is to provide isolation.
So in multiple server pros that could running on the same computer using the same program. I'll connect the same loop back devices up.
There's a couple of different definitions of loop back that you're talking about here.
I think you're thinking also about network stuff carson i'm not gonna address that further because i'm not talking right now.
I I I get that it's like I get that sound networking. But, like, I think most people when they think of containers, they're thinking of like a docker container where you're say you have multiple data
centers around the world, and you need to replicate the same server at multiple data centers.
So you're containerizing it and putting in a container, and then I know, putting in an email or whatever
But the concept of loop back devices. So the loop back device is not about loop back devices.
I mean any any system you configure it's going to get the the containers going to have its own networking stack.
Actually it, a container can have its own. Ip Address: Okay, I see.
So because you can you can make it so that it's like. right now what i'm doing with this change route it doesn't have all those features, but when you talk when you do the you can you would containerize all
aspects of the system, so that it really does have its own.
Ip address. It has some ports, its own process table.
Its own users. Basically, everything makes sense thanks the only thing that's being shared is the kernel.
So for those of you who are a bit lost I know this stuff is a bit complicated. but that's why it's very important, and I want to make things concrete with the this program.
And what you really should do is go like what the heck is going on with each line, and when you get something like this, break it down and run it in pieces, you know.
Run one thing, Then run another thing. and say what is each of these commands doing because they're each doing something very discreet, especially when you're talking about shells and stuff. it's you know they're actually tend to be pretty
isolated. so it's like what is this doing so if you understand these commands individually, then you can start seeing.
Well, then, what are they doing collectively? So most of the stuff here, I think, is relatively straightforward.
It's the magic here gets in well so first of these echo things.
You should understand that this you should play with these commands.
But what this is doing is this just here i'm just outputting standard out here.
I'm outputting to stand it out but i'm using i'm appending, so i'm not erasing what was there.
So i'm just i'm just literally just doing these things to generate a file, and then i'm making that file executable.
And then you have to understand what this change. room. does so that's the specific thing that you want to do. and But what you could do is just try running this program by itself. But then you see, it's just running these commands yeah, So what
is 5 stand for. This is a very silly thing.
This is the end of an if statement Yes, so in in classic shell scripting there's like a case that you know you you do a
You do a keep like a case statement. How do you end the case?
Statement E sack, and you do a f if you if statement you end it with A.
So it's yes, if backwards so there's this thing that some some keywords are backwards to end it.
I mean it's it's a cute way of doing block structure.
We so don't do that anymore.
William. I do not know why they did not yeah I don't know why they were not consistent.
But honestly, if you're looking for shell scripting to be consistent, you're going to go nuts.
It's not
And we kind of agree with that anywhere, so I I so there's a couple of there's a lot of pieces parts that you have to kind of fit together in your head and get an idea of what's how they interact in order to
understand what's happened with the operating system and once you see them together like Oh, that's all that's happening.
But until you get to that point it's gonna be confusing and so you gotta spend time wrestling with this and try to figure out what's happening here.
What's that happening here now? in your to make things more concrete when we talk about bootloaders and Linux, and stuff like that?
If you look at your let's go to my yeah, So if we go here, and if I go to slash here on this is our computer here, there's a directory called boot in this boot directory this is
actually where the Linux kernel is. this Vm.
Liners to generic This is the linux kernel that I'm running on my computer right now.
I'm getting to the scheduling part
So am I cap we'd also see the version of the Kernel.
You're running on by looking at slash procl version, and it says, In fact, you're 55.15 there, 52, and if we look at the size of this file
You can see that he's files are pretty big but not that big.
So the entire Linux kernel here is running in 12 MB,
Yeah, So I i'm i'm not gonna talk about that yet.
So this is the linux kernel you say like it's only 12 MB that seems kind of small.
I would think that the Linux kernel was a bit bigger.
Well that isn't all the code turns out the rest of the code is in modules
So if I go 5, 15 dot 0 that's eric these are the modules here, I think a kernel
So ext 4. Now let's say so the all these ko files
So this is 774 MB
Can you open up a dot ko file and read that or read them?
You can, but it's just like looking at a dot o file.
You can disassemble it it's an object file Oh.
So when we talk about
So kernel space is running is the kernel and modules.
User space is those files
So the kernel is the system that allows other things to access files.
It's not the one that's accessing files mostly
Ko stands for kernel object 5 files we're gonna see Ko in in tutorial 8.
You'll see them you'll be making them so that's actually, in fact, true tutorial 8 9.
We're going to be writing kernel modules and loaded them into a kernel and with them, and adding functionality to it.
Oh, So we enter the system, the Colonel via 2 routes.
One is you basically by system, calls in, by interrupts.
Does it sound safe? it's not very safe and in fact, you will potentially trash your virtual machine by doing tutorials 8 9.
So you should do backups much. actually not that much safer, a little safer, but not much easier.
Modules are easier, but it doesn't actually reduce the power you have or change account.
The kernel is an or making it really mess up for the record
Table, here
Is there a way to back up things Yes, that's yeah exactly yeah tutorial.
One talks about making via backups. Yes, please do.
Backups. Vms. can get messed up for lots of reasons.
Oh, so when you're talking about making a system call what happens is in user space, you make a system. call the then in kernel space is the system called dispatcher gets run
You handle the system call, and then you call the schedule which finds a program that's in a real state and run it.
You could show up
It's what needs hardware interrupt Yes, Well, there are software interrupts, too.
So their hardware and software interrupts. If you make a second fault that will cause the kernel to run.
If you divide by 0, that will cause the kernel to run
Yes, in yes, implicit. And all this
You know that means hardware. So So what's your so you see this basic flow between making a system call and starting the dispatcher this and then coming back.
So when we are normally coding and compiling stuff, you're normally on just the left side of this diagram.
You're just you know this is happening here and you don't you aren't controlling your deal of this stuff on the right. The stuff on the right is what the kernel is doing and that's what we're going to
be starting to play with here. This is the thing that actually implements the kernel functionality
Really slash. Prokins slash Sis are an interface, 2 kernel data structures directly via I
So what I mean by that when I go Lsl.
Proc. This is a list of, you know. I mean, if I if I Ls. prox last 2, 9, 8, 4.
I am looking at the data structure. This is info the data structure that definitely the kernel has for process 2, 9, 8, 4, and these are all fields in that data structure.
And so we can read about things what it's doing it's got all kinds of information on a huge amount of information here. And really my goal now is not free to understand all this I don't understand all this Well, this call is
very complicated. but I want you to understand what's going on here so so i'm curious what this is let's look at
So this is a process user. Olive, Exec. Gv.
Fsd Metadata Okay, that's the program it's running.
Okay.
So we're out of we're almost out of time here. We just have a couple of minutes here, so let me start to show you a bit about. We'll start. we'll be talking more in depth about the next
tutorial 8 and 2 tutorial 9 starting next week.
But well starting Thursday, there's a lot to discuss because we basically are now talking about the kernel
Let's go to
Yeah, No: yeah. No one person understand the entire Linux kernel.
I put out these yeah, actually covering this? Yeah, I have to think about the order in which I cover these things.
Come like tutorial Schedules gotten off i'm actually getting ahead of myself.
We're gonna bounce around some
Oh, i'm looking at the wrong class it it's like i'm very confused.
Here. This is 2021 that's good to 2020 let let's go to the so tutorial 7 was
We're gonna talk about this one next so this tutorial seven's.
Next We're going to talk about ev and i'll explain stuff that we'll just watch again, give us a way of looking into Colonel for functionality and playing with that tutorial 8 We will make a simple character device
and real, you know. so we've got you this is actually kernel code.
We're running a a little kernel module here and then in 2,009.
We'll start doing some things looking at virtual memory but to trail 7.
What we're gonna do next is we're gonna talk about something called Adpf, which i'll start talking on Thursday, which is actually a cool thing for way of adding coach the kernel in a safe way
to understand what's happening in the kernel
Yeah, tutor, but that's tutorial 7 tutorial 5 and 2, 4 o 6 is all you need to know for the next assignment.
7, 8, 9. Yes, I assign assignment 4, yes, exactly
I think i'm done here I wanna before before you close that there.
So I know we already deal with like pseudo terminals and whatnot.
But just to be clear when you go into proc and you see a pid, and at all, sometime in a lot of device numbers like 1, 2, whatever, whatever, right?
So there's a complete abstraction between you know like, say, there's multiple programs that printed the screen, and they all connect, to say, pseudo device.
One which is the shell So there's a complete abstraction between the process and having control of a current given output device.
Right. Yes, There's a lot in what you just said though so So what's happening when you see so what you're talking about is Dev Pts right?
The pseudo terminals here, right and so right if we say
Well, that's not very helpful, but so here if I go here.
This bash here that i'm interacting with is pts 2 right?
So that's this specific file dev pts this device. is what i'm reading and right is what bash is reading and writing from. I mean, I interact when it interacts with this terminal.
So the question is, how does that get to the screen and that's complicated?
Because, in fact, how it's getting to the screen is bash rights to the pseudo tty who's on the other end of that pseudo tty.
Well, Emma's and emacs gets that information and says oh, i'm making a terminal thing what I How do I do this?
Then Emac has to talk on my computer I talk to a display server, cause i'm running i'm going expert on my system.
So That's talk to Xor then x org has to render the video to my screen.
I think, Okay, I think that makes sense. Some be online suggest to trying to go and say like echo, some string, and then carrying that to slash proc slash pty like Sorry I gotta look at my notes
here. Sorry to sending it to slash dev pts slash a given number and that doesn't seem to work for me.
So But I think what you said there give it that sort of makes sense given what you've just said, so it's you.
Can do things where you write directly to tty right directly to these teaching wise and do stuff, but it's not.
There's some funny semantics it in particular if you do that to things in that regular tty's here.
It'll work pretty straightforwardly dev pts is weird, because actually Dev Pts is its own file system, which is, which is weird.
And and, in fact, these you can't just create this device somewhere else, and have it work.
This file system is weird, so i'm not sure the historical reasons for it.
But I definitely try doing things with it. and that gets but if you yeah, it it. if you look at I mean I think if you ssh to no, i'm not sure if well, if you're on the console with the vms or the console things then those
tty work very conventionally. If you work on other ones, then trying to.
Actually, basically, if you try to ask them as normal everything's fine try writing them directly.
Weird things happen. Okay, makes sense thank you so it's a Anyway, i'm over time don't worry If you I mean, I definitely talked about some more advanced stuff.
This class than I. oh, was naturally going to feel free to skip that stuff.
We're gonna be going through it in more careful detail and you'll see the pieces parts particularly I think assignment 3 should help you understand
The container concepts, and then afterwards we're gonna go through the most of the rest of the class.
After this is going to be spending time on kernel concepts. So a lot.
I mentioned a lot of terms today, and we're going to go from a lot more detail, and there's so specific code of how things work.
So i'm hoping for things get more clear so see Thursday