‫Hello, everybody, in the last lecture, we created our very first use a land program in this lecture,
‫we are going to load the use program and execute it to begin remove this open code.
‫We don't need that anymore.
‫We also do not want to enable the system interrupts.
‫We will re-enable them when the first program loads.
‫So get rid of that.
‫Also, scroll to the very top and we're going to include some pedophiles.
‫We're going to include task test on Hajj and task process that Hajj.
‫Scroll back down just under an paging.
‫We're going to go process load now.
‫You can see we only have process Hlophe slot, so just go.
‫The process starts, see and you'll see process load here.
‫Just copy and paste the prototype and put it in the header file just so we have something we can use
‫outside of the source file for process Stazi.
‫So go back to Canada and see now we should be able to go process slow, which we can.
‫Brilliant.
‫So we're just going to go zero drives zero and the file is going to be blank.
‫Dobbyn OK, and we're going to do ampersand process here.
‫OK, so now we're going to go struct process process equals zero and we're going to go and address EQUASS
‫process load and now we're going to say if rest does not equal process all OK.
‫Then there was a problem.
‫Panic failed to load blank.
‫It's been OK.
‫Now just scroll up here because we're going to also need to include status start Hajj, OK, at the
‫very top by here.
‫So scroll back down and that should now be resolved.
‫Let's now just do a quick make clean bill that stage and we're going to run that.
‫And we can see it says failed to blanked up, and which is just what we wanted because we haven't actually
‫added the file to the file system yet.
‫So head over to the makefile.
‫We're just going to go pseudo copy and we're going to copy the program's, uh, blank.
‫I think it's called yes, blank.
‫And it's going to be blanked up in and we're going to copy that to Mandy, OK, so that should ensure
‫that our program can load that now just backed candidates.
‫See, there's a few things we need to fix up before we can continue if we look and process, load and
‫process.
‫Slow slob.
‫If we scroll down here.
‫You will notice a mistake has happened on line one six two, if there's an error rate in the task,
‫we set the response, but we don't leave the if statement.
‫So that's that's a bug.
‫So we so we should add, go to out by here.
‫OK, so if there's an error, it'll jump to the bottom here.
‫OK, so make sure you do that, guys, because that's something I forgot to do.
‫Now just go to test Asen, because there's some other things we need to fix up here.
‫If we go if we go through test ITSM, you can see here we go.
‫Pusztai, would Ebix plus four, this should be SBP plus four, because if we look up here, we are
‫saying Ebix equals plus four and we want to pass the struct registers to the Restall general-purpose
‫registers function.
‫So it shouldn't be Ebix.
‫That was a typo.
‫It should be EHP.
‫The final typo that I found is in restall general purpose registers.
‫We can see we push the base point, but we pop the stack pointer.
‫This is a mistake.
‫Should be popi BP.
‫So we go pushing BP.
‫We said all of our general-purpose registers and finally we restore the base pointer.
‫OK, so that is it for that.
‫That should ensure that that function works fine.
‫Now just go to test subsea and you'll see this task in it.
‫The task and the function.
‫We set stack segment here, but we forget to set the code segment.
‫This will cause a general protection fault if we try to run the use a program without doing this.
‫So we need to go test registers.
‫That code segment equals use a code segment.
‫OK, now that will ensure that that will not happen.
‫So you need to add this OK in the task and the function will not just change in the Stack segment.
‫We're also changing the code segment.
‫OK, great.
‫So go to Colonel Dot.
‫See, there's one more thing we need to do here, guys.
‫We just need to go task run first.
‫Eva task, simple as that.
‫And as you know what this will do, this will switch to the task head and it will basically call task
‫return on the task heads, registers, dropping it into use a land and executing the IP in the registers
‫that provided the task heads registers.
‫It will execute the IP here.
‫OK, so that's so perfect.
‫But there's one other thing.
‫When we do task new and guys, you need to do this because it won't work if you don't go to task.
‫New intestacy, you'll notice when the task head is.
‫Now we set the task head on the task tail, but we forget to set the current task.
‫So the task head is no, we should go task.
‫Current task equals task.
‫That's what we should do.
‫OK, and that ensures all three of those things are set correctly.
‫OK, so if we now go in here and we go make clean build S.H..
‫And we go CDPR in Kumu, we can see so far so good and now we're just going to go gdb target remote
‫kumu system i 386 dash hda stop and dash capitalis dash gdb studio.
‫And we're going to press to continue and we're going to press control.
‫See and what you see that we are executing address UKCS 400000.
‫If we go layout ASRM, we can see that our program is now running.
‫We are running our very first program, Blank Toppin and all it does is jump on itself.
‫So it's literally just looping forever.
‫So congratulations.
‫You just dropped in to use the land you have just run your very first use program.
‫So whilst you're running this user a program, if the program does anything bad like try to access hardware
‫within and out instructions, try to access memory that it's not allowed to access, it's going to cause
‫a exception to be thrown that your kernel can handle.
‫The correct thing to do in this scenario is to kill the program because they shouldn't be accessing
‫memory, they shouldn't be allowed to access.
‫So as you already are aware, we're not actually executing address 400000 while technically we are.
‫We're executing the virtual address.
‫But the physical address of our program is completely different.
‫And thanks to paging, we're able to do this if we just take a look at process start see process, map
‫memory, uh, process, map binary.
‫We can see here that it maps the program virtual address you 400000 and it maps that, uh, to the process
‫pointer that we created earlier.
‫OK, so that is how that's working guys.
‫Right.
‫So just keep in mind that this is virtual memory.
‫We can map these memory addresses anywhere we like so long as that page aligned.
‫And yet for the next few lectures, we'll start refining user processes will be communicating with the
‫kernel and so on.