CSE 451

Operating Systems

Spring 1998


Quiz #5 : Solution 

1. Suppose a system has a virtual address  containing  28  bits.
Suppose that the page size is 1024 bytes, that physical addresses
contain 24 bits, and that the system uses  a  segmented-and-paged
scheme with 256 segments and a segment size of one megabyte.

(1)
 
 segment#  virtPage#    byte#
+--------+----------+----------+
+ 8 bits | 10 bits  | 10 bits  +  virtual address
+--------+----------+----------+
 

+------+
+ stbr + ------> segment table
+------+        +--------------+
          |     +              +
   2^8 entries  +              +
     segments   + page tbl addr+ ----------------> page table
          |     +              +                +--------------+
                +              +         |      +              +
                +--------------+  2^10 entries  +   physical   +
                  - 14 bits  -    virtual Pages + Page Address +--->
                                         |      +              +   |
                                                +              +   |
                                                +--------------+   |
           page                                    - 14 bits -     |
   |    +-------+ <----------------------------------------------<-|
  byte  +  1K   +
 offset +       +
   |    +_______+
 
 

   physPage#      byte
+--------------+----------+
+ 14 bits      | 10 bits  +   physical address
+--------------+----------+

(2) The maximum size of a segment is 2^20 bytes (1MB)

(3)  1.  Total of 3 memory references. One memory reference to
             access the segment table, one to access the page table and
             one to access the data.
        2. Total of 5 references if only the user page table is in virtual
             memory (2 references more to access the kernel segment
             and page table entries to access the user page table entry)
             Various answers are possible depending on the assumptions
             you make.
 
(4)  Sharing can be done by segment or page:

  1. segment - One segment is shared when one entry in the segment tables
of two different processes point to the same page table.

  2. page - One page is shared when one entry in the page tables of two
different processes point to the same page.  You would have to share at least
1K (page size), becasue the page size is fixed.
 

(5)  Since the segment size is 1MB and only 4800 bytes are used, only 5 pages
will be allocated for this segment. Therefore 320
bytes will be wasted in he 5th page of the segment (internal
fragmentation) .

(6)  The owner wishes to use 5000 bytes. Since 5 pages (5120 bytes) are already
allocated for the previous 4800 bytes, the OS need not change the page tables.
It might have to change the length of the segment in the segment table. In a pure
segmentation based system, the OS might have to move the segments around so
that it can make space for enlarging the segment.

(7) The owner wishes to use 5500 bytes. The OS will have to enlarge the
segment to 6 pages since 5 pages is only 5120 bytes. This is done by
allocating a new physical page and making the 6 th page table entry point to
the physical page.  The segment size also have to be changed.