Touge Operating System Homework 4.3: Segmented Page Memory Management Answer No Analysis

Level 1: First Page Fault

For version 1 kernel environment configuration details, please move to the first few levels~ Touge Operating System Homework 3.1: Process Description and Status

Start the gdb debugger:

b schedule
c

p task
p task[0]->pid
p task[1]->pid

p &current
p page_fault
quit

 Start the dbg debugger:

b 0xb124
c
x/wx 0x1fa20
creg

x/wx 0x0+16*4
x/wx 0xffe000+37*4
u/30

b 0xb15a
c
x/wx 0x0+16*4
x/wx 0xffe000+37*4
s
quit

Start the gdb debugger:

b 145
c
n

x/5i $eip
quit

 

The first level document answer:

 

Level 2: Implementation of shared memory communication between parent and child processes

programming requirements

The task of this level: rewrite the version 1.3 kernel, so that process 0 outputs lowercase letters a, b, c, . . It is required that the characters output by the two processes are associated and incremented, that is, if process 0 output characters last time a, then if process 1 runs this time, it should output characters B, and vice versa, the running screen is shown in the figure below. (It is required to use int 0x81 to output characters, and the implementation of int 0x81 cannot be modified)

 

Configure version kernel 1.3, pay attention to the copied file path~ the specific operation will not be repeated here. For details, please move to the following link~ Touge Operating System Classroom Exercise 4.1: Segmented Memory Management Answer_Blueberry Cream Dumpling Blog-CSDN Blog

 

Use VScode to modify the file:

(Note: The number of lines of code marked below may vary according to different environments. Please judge the position of adding or deleting code according to the context code when it is different~)

Open the main.c file under the path shown in the figure:

 Add code at line 62:

 Add code at line 114:

 Add code at line 150:

 Replace the code in the original file from lines 155 to 158 with the code in the box as shown in the figure:

 Replace the original file code on lines 171-174 with the code in the box as shown in the figure:

 

 Save the main.c file, and then use the same method to open the memory.c file under the path shown in the figure:

 Add the code on line 133 as shown in the figure:

 Comment or delete the 178 lines of code, and add the code in the red box:

Save the memory.c file, and recompile 1.3/linux on the command line, as shown in the figure:

 Finally, just run the virtual machine, as shown in the figure:

 

 

 

Guess you like

Origin blog.csdn.net/kercii/article/details/130608741
Recommended