‫Hello and welcome in this lecture, we're going to start implementing multitasking.
‫Just good idea to see.
‫So just by here in, I start to see we're going to say void eite clock just like that, OK?
‫And inside I did clock.
‫We're just going to go to this next switch to the next task, OK?
‫And just by here we're going to say I didn't register in callback 06 20.
‫I just clock now as you know, zero interest six twenty.
‫Where we mapped it is for the time I remember I showed you the timer before.
‫So essentially it causes an interrupt every quarter of a second or so like this.
‫And we will switch to the next task when that happens.
‫And it will allow two tasks to run at once.
‫So just to test this, what we're going to do is we're going to go to blank dot C and we're just going
‫to print out OK, V one or Aragvi zero actually would be absolutely fine.
‫And we're going to go to Canada at C and you'll notice we did the shell here.
‫OK, we're going to change this to blank off now, OK?
‫And we're going to inject the arguments, testing, and now we're going to start a new process.
‫So I want you to copy and paste this just like that.
‫OK, uh, and just like that.
‫OK, and get rid of argument here.
‫We've already done that.
‫So just like that.
‫OK, and we're going to change this to ABC.
‫So you should have a loading blank off into memory, injecting the testing argument into blank drouth
‫and then loading it again, creating a second process.
‫So we have two processes and then injecting ABC into that.
‫And then we go TASC run first EVA task.
‫OK, so that's what we're doing here.
‫All right.
‫And when we run the first of a task now, we should see them flicking between each other.
‫So allow protesting, then ABC testing, ABC testing, ABC and so on.
‫And it should work like that correctly because in Tazi we will be calling it ti clock, which switches
‫to the next task like that.
‫OK, every so often.
‫So just try and make clean in the build that S.H. and we'll try this out and see if everything works.
‫You can see us complaining about redefinition of rest, so just get rid of that.
‫Just look just like that.
‫So it's those rare slow switch and build that again.
‫And now we're going to go see Ben Kumu.
‫And there we go, you can see it says ABC, ABC testing and then it says no process to switch to.
‫Now the reason it says no process is to switch to is because they both killed themselves.
‫They both terminated and blanked out of.
‫What we can do is we can put a while loop around them like that, OK?
‫And then that'll make sure that constantly outputs that and constantly outputs the other one.
‫So there's one more thing we need to do before I forget.
‫Just good eyes to see and scroll up here and you'll see we do about six twenty six twenty.
‫We have to actually do that one manually inside H.T. clock because remember Tarsa next means that we
‫never return.
‫OK, so it never gets to the end of this entire panel where we say that you can send the next interest
‫to us right there next to the pic when we not we are not acknowledging the pic because when we run the
‫entire callback feisty clock, we go to the next task, which never returns.
‫Right.
‫So we just need to acknowledge it just before we switch to the next task by here.
‫OK, because if we if we don't do that, then it'll only take once and we don't want that.
‫So when I was just going to go on, want to go make a clean bill to the stage.
‫I'm going to go CD and we're going to run she BAMU.
‫And there we go, you can see ABC testing, ABC testing, ABC testing, ABC testing, and this goes
‫on forever.
‫OK, so you now have multitasking in your kernel, two processes of running at once.
‫Now, what I can suggest you take this further is giving each process some video memory, OK?
‫And then you can switch between them with the function keys or something like that.
‫OK, that's pretty nice design as you can easily switch between the videos of each process rather than
‫having everything checked in your face like this.
‫As you can see, multitasking is very unstable in this state because both the processes are using the
‫same screen and we don't want that.
‫Right.
‫So you can make some sort of abstraction where you can map the video memory to some physical memory
‫and memory somewhere.
‫And then when you switch to the process, you can then remap the video memory back to the real video
‫memory.
‫OK, and that will ensure that any rights to those addresses, zero zero zero zero and stuff to to write
‫the characters will be written into physical memory, some address somewhere in physical memory, if
‫it's not the current process and will be written into video memory if it is the current process.
‫And obviously when you switch to a new process, you would also copy from the video above into the real
‫video buffer as well, allowing us to see the entire screen that that that process has written.
‫OK, so that's just an idea for a design in the future and that's not so, so difficult to do.
‫OK, you just need to map the video memory to some physical memory and then map it back when we switch
‫back to that process.
‫It's not so hard.
‫If you take the mapping techniques we've already used, you can easily do that and you can talk to me
‫more about that if that's something you want to do and need an extra hand with that.
‫So you now have multitasking in your kernel and congratulations.