remzi-arpacidusseau / ostep-homework

1.99k stars 959 forks source link

Fix bug when checking seg fit or overlap in the phys memory #32

Open thasinaz opened 3 years ago

thasinaz commented 3 years ago

segments mayoverlap or out of the phys memory

out of phys memory:

> ./segmentation.py -a 16 -p 128 -A 1,14,15 --b0 127 --l0 2 --b1 0 --l1 2 -c
ARG seed 0
ARG address space size 16
ARG phys mem size 128

Segment register information:

  Segment 0 base  (grows positive) : 0x0000007f (decimal 127)
  Segment 0 limit                  : 2

  Segment 1 base  (grows negative) : 0x00000000 (decimal 0)
  Segment 1 limit                  : 2

Virtual Address Trace
  VA  0: 0x00000001 (decimal:    1) --> VALID in SEG0: 0x00000080 (decimal:  128)
  VA  1: 0x0000000e (decimal:   14) --> VALID in SEG1: 0x-0000002 (decimal:   -2)
  VA  2: 0x0000000f (decimal:   15) --> VALID in SEG1: 0x-0000001 (decimal:   -1)

and overlap:

./segmentation.py -a 16 -p 128 -A 1,15 --b0 64 --l0 2 --b1 66 --l1 5 -c
ARG seed 0
ARG address space size 16
ARG phys mem size 128

Segment register information:

  Segment 0 base  (grows positive) : 0x00000040 (decimal 64)
  Segment 0 limit                  : 2

  Segment 1 base  (grows negative) : 0x00000042 (decimal 66)
  Segment 1 limit                  : 5

Virtual Address Trace
  VA  0: 0x00000001 (decimal:    1) --> VALID in SEG0: 0x00000041 (decimal:   65)
  VA  1: 0x0000000f (decimal:   15) --> VALID in SEG1: 0x00000041 (decimal:   65)