1 00:00:00,780 --> 00:00:07,020 Hello, in this video, we will wrap up the section by doing a simple test. Remember when we write the handler 2 00:00:07,450 --> 00:00:12,990 in the trap.c file, we just halt the system if the exception or unknown interrupts occur. 3 00:00:13,440 --> 00:00:19,830 At this point, we have exit and wait functions in the kernel. So we can force a process to exit 4 00:00:19,830 --> 00:00:23,040 if it causes exceptions. 5 00:00:26,760 --> 00:00:33,150 To achieve it, we first check to see if the exception is generated in the user mode. 6 00:00:33,150 --> 00:00:39,450 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, 7 00:00:39,450 --> 00:00:45,250 we call function exit to kill the process and never return. When the wait function is called, 8 00:00:45,270 --> 00:00:53,030 the process will be freed. Also we print message so that we can see which exception it generates 9 00:00:53,040 --> 00:00:53,880 . 10 00:00:58,880 --> 00:01:04,190 If the exception is generated in the kernel mode, we halt the system just as we did before. 11 00:01:06,040 --> 00:01:08,920 In this example, we also change the user3 program, 12 00:01:12,800 --> 00:01:17,750 as you see, it constantly prints message on the screen. So we remove the print function. 13 00:01:20,940 --> 00:01:21,380 OK. 14 00:01:23,340 --> 00:01:24,840 In the program user2, 15 00:01:26,500 --> 00:01:30,070 We manually caused the exception by writing a value in the kernel space. 16 00:01:32,750 --> 00:01:37,840 If everything goes as expected, we will not see the message of this process printed on the screen. 17 00:01:39,550 --> 00:01:40,780 OK, let's test it out. 18 00:01:52,350 --> 00:01:54,630 We copy the user programs in the boot folder 19 00:02:10,030 --> 00:02:11,700 and we write them in the boot image. 20 00:02:14,030 --> 00:02:15,650 OK, let's open the virtual machine. 21 00:02:21,290 --> 00:02:28,370 you can see exception is 14, which is the PF exception, and the message process3 is not 22 00:02:28,370 --> 00:02:29,660 printed in this case. 23 00:02:30,670 --> 00:02:32,290 OK, that's it for this lecture. 24 00:02:32,710 --> 00:02:34,000 See you in the next section.