Hello, in this video, we will wrap up the section by doing a simple test. Remember when we write the handler
in the trap.c file, we just halt the system if the exception or unknown interrupts occur.
At this point, we have exit and wait functions in the kernel. So we can force a process to exit
if it causes exceptions.
To achieve it, we first check to see if the exception is generated in the user mode.
If the lower 2 bits is equal to 3, then it is in the user mode. If that is the case, this is the error in the program,
we call function exit to kill the process and never return. When the wait function is called,
the process will be freed. Also we print message so that we can see which exception it generates
.
If the exception is generated in the kernel mode, we halt the system just as we did before.
In this example, we also change the user3 program,
as you see, it constantly prints message on the screen. So we remove the print function.
OK.
In the program user2,
We manually caused the exception by writing a value in the kernel space.
If everything goes as expected, we will not see the message of this process printed on the screen.
OK, let's test it out.
We copy the user programs in the boot folder
and we write them in the boot image.
OK, let's open the virtual machine.
you can see exception is 14, which is the PF exception, and the message process3 is not
printed in this case.
OK, that's it for this lecture.
See you in the next section.