Hi there, I am following some guides on writing a toy OS and my source code is located at
https://github.com/hellobbn/bbnOSI am now writing the part of multi-threading and have 2 tasks: testA() and testB() in kmain.c, and the first time interrupt cause the os to execute the testA() function.
However, it triggers a #PF page fault exception immediately.
After some debugging of the code, I found that in testA(), there is a while loop and the assembly looked like this:
Code:
while (1) { 0x3234a jmp 0x3230b <testA+27> testA+90
print("- [testA] test A "); 0x32316 mov %ecx,(%esp) testA+38
0x32319 movl $0x0,0x4(%esp) testA+41
0x32321 movl $0xf,0x8(%esp) testA+49
0x32329 movl $0x0,0xc(%esp) testA+57
0x32331 mov %eax,%ebx testA+65
0x32333 mov %edx,-0xc(%ebp) testA+67
0x32336 call 0x32a90 <fb_print_color> testA+70
and in my fb_print_color() function there defines 2 static value x_pos and y_pos for tracking current print position, and the above code changes y_pos to a very large number, causing the #PF.
The error occurred when I am trying to move some global declaration to `global.c` . My code in master branch is ok and can be run using `make qemu`, however, the code in branch pf, which is 1 commit ahead addresses the issue.
Can someone help me with this, thanks!