‫Hello, welcome back, everybody.
‫You'll notice if we just scroll up and see, you'll see the process function, we made a few lectures
‫ago.
‫Well, unfortunately, that will always return.
‫No, because we haven't yet set the current process.
‫We just basically made a Gedda method, which will get a function, which is what process current actually
‫is.
‫It gets the current process running.
‫We never actually set the current process.
‫So for those of you that tried to do the keyboard functionality, if you tried to keep or push and pop,
‫you would have noticed it didn't work.
‫However, I just wanted to let you know that that is to be expected because we haven't yet set the current
‫process.
‫So we're going to do that in this lecture.
‫And then finally after this lecture, we'll be ready to continue implementing the keyboard.
‫So essentially, what we need to do is we need to create a process which function, which is basically
‫responsible for switching to another process that's running.
‫OK, so what we're going to do then, we're just going to say in ID process, which struck process process,
‫OK, now what we might do at this point in time is save the current process.
‫So maybe it has its own separate video memory, something like that.
‫Right.
‫But as this is a training exercise, we're going to be using the same video memory for all the processes,
‫which will mean if one process prints, another one will see that as well.
‫It'll be on the same screen.
‫Basically, they won't have separate views of the video memory.
‫Just imagine on Linux that maybe every process prints to the same terminal because it's the same sort
‫of thing.
‫We're not going to worry about separate video memory, at least not at the moment.
‫But anyway, in process switch, all we want to do is switch the current process.
‫So all we do is we say current process, EQUASS process is as simple as that.
‫Now, as I said, we would probably save the state of the process before we did this.
‫However, there would be no need to do it, not in our implementation, because, as I said, there's
‫nothing unique about the processes.
‫They they all share the same video memory.
‫And we know that that task has been saved because we're in the kernel.
‫And so there's really nothing to worry about, about saving the processes at this point.
‫So then we just return zero.
‫OK, so that's how that works.
‫So now whenever a new process is started, we use process switch.
‫OK, it's as simple as that.
‫Now we're just going to scroll down.
‫We're going to create a new function just by process load, OK?
‫We're basically going to call it process lodestars.
‫So we're going to go in a process slow start our new accounts, file, name, struct process, process.
‫And I'll tell you what, don't call it process, slow start.
‫Call it process, load, switch, and that'll switch to the process loaded and then switch it.
‫OK, so all we do is we say in address equals process load and we're going to pass the filename in the
‫process in here.
‫OK, if the rest is equal to zero that means everything went OK.
‫So then we just go process switch and we simply do asterisk process as simple as that.
‫OK, we do ask this process because right here someone's done an ampersand on their pointer and past
‫just address so we can change the process.
‫Right.
‫So we do ask this process here to access the actual process because this is a multidimensional pointer.
‫As you can see down here.
‫We're just going to go over to address.
‫OK, now, it really is as simple as that.
‫So if we just copy and paste process load, switch into the head of file and just pasted above this
‫load, we're also going to do the same for process switch, copy and paste that prototype.
‫And we're going to pass that by here, OK?
‫And I would just get the terminal open and we're going to go build that S.H..
‫And we can see that works absolutely fine.
‫So now go to Canada and see here when we do process.
‫We're going to change this to process load switch.
‫OK, so that allowed the process and switch the current process to that process.
‫So if there's already a process that's loaded and running, it'll switch the view to that process.
‫OK, well, not really the view because as I said, they share the same video memory, but the the kernel
‫will see that process as the priority one.
‫The one and the one, in our view, essentially, OK.
‫The current process.
‫So when we type on the keyboard, it's that process that will receive the keys, not the previous process
‫we loaded.
‫OK, even though they all share the same video memory and they print to the same terminal, they are
‫separate processes and it's important we understand that.
‫So by calling process switch, we change the process variable, which will change the process that certain
‫actions happen on, such as keyboard events, keyboard presses and stuff.
‫So, OK, what we're going to do here now, then we're just going to go keyboard push a and we're just
‫testing this generic functionality here now, OK, to make sure everything works as expected.
‫Now, at this point in time, we can only push we'll probably have problems if we try to pop.
‫And the reason for that is because pulping requires a task to be running because we pop from the task
‫that is running.
‫However, at this point in time, no task has ever been run because we haven't called test run first
‫of a task yet.
‫So what we will have problem trying to pop from the keyboard at this point in time, but we should be
‫able to push without problems.
‫So let's load the load the debugger gdb we're going to go add single file builds kernel 4.0, Xerox
‫one one, two, three, four, five.
‫And we're just going to go break kernel that C one six one.
‫OK, and now just go target remotes and we're going to pipe this out to Kimeu.
‫OK, you know the drill.
‫I'm only just going to press and I forgot these guys make sure you do an ass by there or you will have
‫problems.
‫And I did this.
‫OK, let's run that again.
‫OK, there we I was just a minor bug, so I'm going to press to continue now.
‫We can see it's now broken line one six one comes see if I now press next and I now examine the process,
‫the process keyboard.
‫We can see there's a in the buffer so that's perfect.
‫We can see that our generic keyboard functionality works absolutely fine and we can see our tail is
‫one.
‫So this was important to test this.
‫Now that we know the generic functionality works fine and the current process can be set, we know that
‫we are ready to continue implementing our keyboard driver and receiving keyboard interrupts.
‫Thanks for watching.