Touge Operating System Classroom Exercise 4.1: Segmented Memory Management Answers

Level 1: The logical address and linear address of the mynext variable of process No. 1

programming requirements

According to the relevant knowledge, modify the version 1.3 kernel to answer the question: find the answer through gdb debugging, and fill in the answer of the first level /data/workspace/myshixun/第一关.txt.

  1. What is the address of the first assembly instruction corresponding to the function call output_char() of process No. 1?

  2. What is the segment address and segment offset of the mynext variable of No. 1 process? How many descriptors does this segment address correspond to? In which segment descriptor table (GDT/LDT) is it stored?

  3. What is the starting address of the ldt array in the process control block of process No. 1? What are the segment start addresses stored in No. 1 and No. 2 descriptors?

  4. What is the linear address of the mynext variable of process No. 1?

#配置1.3内核环境
cp /data/workspace/myshixun/exp1/1.3.tgz ~/os/
cd ~/os/linux-0.11-lab/
tar -zxvf ../1.3.tgz
rm -rf cur
ln -s 1.3 cur
cd 1.3/linux
make
cd ../..

 

 Open the gdb debugger and enter:


b 155 
c
p &mynext #查看变量mynext所在的段内偏移
x/6i $eip #反汇编
p/x $ds
p $ds>>3
p/x current->ldt #查看进程的LDT
p &current->ldt

 The first level document answer:

 

Level 2: Logical address and linear address of mynext variable in process 0

programming requirements

According to the relevant knowledge, modify the version 1.3 kernel to answer the question: find the answer through gdb debugging, and fill in the answer of the second level /data/workspace/myshixun/第二关.txt.

  1. What is the address of the first assembly instruction corresponding to the function call output_char() of process 0?

  2. What is the segment address and segment offset of the mynext variable of No. 0 process? How many descriptors does this segment address correspond to? In which segment descriptor table (GDT/LDT) is it stored?

  3. What is the starting address of the ldt array in the process control block of process 0? What are the segment start addresses stored in No. 1 and No. 2 descriptors?

  4. What is the linear address of the mynext variable of process 0?

The version 1.3 kernel environment configuration is the same as that of the first level, so I won’t go into details here.

Open the gdb debugger, and type:

b 172
c
x/6i $eip
p &mynext
p/x current->ldt
p &current->ldt

 The screenshot of the running effect is as follows:

The second level document answer: 

Guess you like

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