Friday 2 November 2012

Memory Organization - Memory Management Hardware



Memory  Management  Hardware

Memory  management  system  :  Collection  of   hardware  and  software  procedures  for  managing  the  various  programs  residing  in  memory.

Memory  management  software  is  a  part  of  an  operating  system  in  computers.  Thus,  the  hardware  unit  associated  with  the  memory  management  system  was  concerned.

The  basic  components  of  a  memory  management  unit  are:
·        A  facility  for  dynamic  storage  relocation  that  maps  logical  memory  references  into  physical  memory  addresses.
·        A  provision  for  sharing  common  programs  stored  in  memory  by  different  users.
·        Protection  of  information  against  unauthorized  access  between  users  and  preventing  users  from  changing  operating  system  functions.

The  dynamic  storage  relocation  hardware  is  a  mapping  process  similar  to  the  paging  system.  The  fixed  page  size  used  in  the  virtual  memory  system  causes  certain  difficulties  with  respect  to  program  size  and  the  logical  structure  of  programs.  Programs  and  data  is  divided  into  logical  parts  called  segments.  Segments  is  a  set  of  logically  related  instructions  or  data  elements  associated  with  a  given  name.  Segments  may  be  generated  by  the  programmer  or  by  the  operating  system.  A  subroutine,  an  array  of  data,  a  table  of  symbols,  or  a  user’s  program  are  some  of  the  example  of  segments.

The  sharing  of  common  programs  is  an  integral  part  of  a multiprogram-ming  system.  Other  system  programs  residing  in  memory  are  also  shared  by  all  users  in  a  multiprogramming  system  without  having  to  produce  multiple  copies. 

Multiprogramming  is  protecting  one  program  from  unwanted  interaction  with  another.  Another  aspect  of  protection  is  concerned  with  preventing  the  occasional  user  from  performing  operating  system  functions  and  thereby  interrupting  the  orderly  sequence  of  operations  in  a  computer  installation.  The  secrecy  of  certain  programs  must  be  kept  from  personnel  to  prevent  abuses  in  the  confidential  activities  of  an  organization.

The  address  generated  by  a  segmented  program  is  known  as  logical  address.  It  is  similar  to  virtual  address,  the  different  is  that  the  logical  address  space  is  associated  with  variable-length  segments  rather  than  fixed  length  pages.  The  logical  address  may  be  larger  than  the  physical  memory  address  in  the  virtual  address,  sometimes  maybe  equal  or  even  smaller.  In  order  to  relocation  information,  each  segment  has  protection  information  associated  with  it.  The  programs  which  are  share  are  placed  in  a  unique  segment  in  each  user’s  logical  address  space  so  that  a  single  physical  copy  can  be  shared.  The  function  of  the  memory  management  unit  is  to  map  logical  addresses  into  physical  addresses  similar  to  the  virtual  memory  mapping  concept.

Figure (A)  Mapping  in  segmented-page  memory  management  unit.


Segmented-Page  Mapping

The  property  of  logical  space  is  that  it  uses  variable-length  segments.  The  length  of  each  segment  is  allowed  to  grow  and  contract  according  to  the  needs  of  the  program  being  executed.  One  way  of  specifying  the  length  of  a  segment  is  by  associating  with  it  a  number  of  equal-size  pages.

Refer  to  Figure(A),  the  logical  addresses  is  partitioned  into  three fields.  The  segment  field  specifies  a  segment  number.  The  page  field  specifies  the  page  within  the  segment  and  the  word  field  gives  the  specific  word  within  the  page.  A  page  field  of  k  bits  can  specify  up  to  2k  pages.  A  segment  number  may  be  associated  with  just  one  page  or  with  as  many  as  2k  pages.  Thus,  the  length  of  a  segment  would  vary  according  to  the  number  of  pages  that  are  assigned  to  it.

The  mapping  of  the  logical  addresses  into  a  physical  addresses  is  done  by  means  of  two  tables  as  Figure(A)(i).  The  segment  number  of  the  logical  address  specifies  the  address  specifies  the  address  for  the  segment  table.  The  entry  in  the  segment  table  is  a  pointer  address  for  a  page  table  base.  The  page  table  base  is  added  to  the  page  number  given  in  the  logical  addresses.  The  sum  produces  a  pointer  address  to  an  entry  in  the  page  table.  The  value  found  in  the  page  table  provides  the  block  number  in  physical  memory.  The  concatenation  of  the  block  field  with  the  word  field  produces  the  final  physical  mapped  address.

The  two  mapping  tables  may  be  stored  in  two  separate  small  memories  or  in  main  memory.  In  either  case,  a  memory  reference  from  the  CPU  will require  three  accesses  to  memory  :
ü One  from  the  segment  table,
ü Another  one  from  the  page  table,
ü The  third  one  from  the  main  memory.

This  will  slow  down  the  system  significantly  when  compared  to  a  conventional  system  that  requires  only  one  reference  to  memory.  To  avoid  this  speed  penalty,  a  fast  associative  memory  is  used  to  hold  the  most  recently  referenced  table  entries.  The  first  time  a  given  block  is  referenced,  its  value  together  with  the  corresponding  segment  and  page  numbers  are  entered  into  the  associative  memory  as  shown  as  Figure(A)(ii).  Thus,  the  mapping  process  is  first  attempted  by  associative  search  with  the  given  segment  and  page  number.  If  it  succeeds,  the  mapping  delay  is  only  that  of  the  associative  memory.  If  no  match  occurs,  the  slower  table  mapping  of  Figure(A)(i)  is  used  and  the  result  transformed  into  the  associative  memory  for  the  future  reference.

Memory  protection  can  be  assigned  to  the  physical  address or  the  logical  address.  The  protection  of  memory  through  the  physical  address  can  be  done  by  assigning  to  each  block  in  memory  a  number  of  protection  bits  that  indicate  the  type  of  access  allowed  to  its  corresponding  block.  Every  time  a  page  is  moved  from  one  block  to  another  it  would  be  necessary  to  update  the  block  protection  bits.  The  logical  address  space  is  a  better  place  to  apply  protection  compare  with  the  physical  address  space.  This  can  be  done  by  including  protection  information  within  the  segment  table  or  segment  register  of  the  memory  management  hardware.

Descriptor  is  the  content  of  each  entry  in  the  segment  table  or  a  segment  register.  A  typical  descriptor  would  contain,  in  addition  to  a  base  address  field,  one  or  two  additional  fields  for  protection  purposes.  A  typical  format  for  a  segment  descriptor  is  shown  as  Figure(B).  The  base  address  field  gives  the  base  of  the  page  table  address  in  a  segmented-page  organization.  This  is  the  address  used  in  mapping  from  a  logical  to  the  physical  address.  The  length  field  gives  the  segment  size  by  specifying  the  maximum  number  of  pages  assigned  to  the  segment.  The  length  field  is  compared  against  the  page  number  in  the  logical  address.  A  size  violation  occurs  if  the  page  number  falls  outside  the  segment  length  boundary.  Thus,  a  given  program  and  its  data  cannot  access  memory  not  assigned  to  it  by  the  operating  system.

The  protection  field  in  a  segment  descriptor  specifies  the  access  rights  available  to  the  particular  segment.  In  a  segmented-page  organization,  each  entry  in  the  page  table  may  have  its  own  protection  field  to  describe  the  access  rights  of  each  page.  The  protection  information  is  set  into  the  descriptor  by  the  master  control  program  of  the   operating  system.  Some  of  the  access  rights  of  interest  that  are  used  for  protecting  the  programs  residing  in  memory  are  :
·        
     Full  read  and  write  privileges
This  are  given  to  a  program  when  it  is  executing  its  own  instruction.

·        Read  only(write  protection)
This  is  useful  for  sharing  system  programs  such  as  utility  programs  and  other  library  routines.  These  system  programs  are  stored  in  an  area  of  memory  where  they  can  be  shared  by  many  users.  They  can  be  read  by  all  programs,  but  no  writing  is  allowed.  This  protects  them  from  being  changed  by  other  programs.

·        Execute  only(program  protection)
This  protects  program  from  being  copied.  It  restricts  the  segment  to  be  referenced  only  during  the  instruction  fetch  phase  but  not  during  the  execute  phase.  Thus,  it  allows  the  users  to  execute  the  segment  program  instruction  but  prevents  them  from  reading  the  instruction  as  data  for  the  purpose  of  copying  their  content.

·        System  only(operating  system  protection)
The  operating  system  protection  condition  is  placed  in  the  descriptors  of  all  operating  system  programs  to  prevent  the  occasional  user  from  accessing  operating  system  segments.







Written by,
NG SWEE YAN A/P SURESH KUMAR
B031210103

2 comments:

  1. i am a student and i didn't get the proper meaning of memory managment hardware from above article ...plz resolve my problem if u can

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete