Documentation
BufferSim
 
  • This documentation gives you an introduction to the visualization tool "BufferSim" used in project 1.
  • It lists the requirements that your buffer manager must meet in order to work with the tool.
  • Introduction

    BufferSim is a simulation tool that simulates buffer manager operations specified by an input file. It allows the user to step through execution and visually observe the changes in the buffer pool.

    Input File format

    The input file is a ASCII text. (See an example here) The first line must hold an integer value specifying the number of frames in the buffer pool. Subsequent lines consist of "commands" which drive the execution. These commands can be grouped into "micro-commands", "macro-commands", and "special commands".
     

    1. Micro-commands

    2. These commands specify a change of state of the buffer pool. More specifically, they indicate every assignment to the PageID, PinCount, and Dirty variable of a given frame. These are the commands that actually modify the state of the buffer, and whose effects show up in the visualization .

      Format of micro-commands:                                                                                Meaning
      (5 spaces)PageID(TAB)<page>(TAB)<frame>              <=  Bring page <page> into frame<frame>
      (5 spaces)PinCount(TAB)(TAB)<frame>(TAB)<pin>    <=  The PinCount of frame <frame> is <pin>
      (5 spaces)Dirty(TAB)(TAB)<frame>(TAB)<dirty>         <=  The Dirty variable of frame<frame> is <dirty>

      where <###> means the actual index for that item.
       

    3. Macro-commands

    4. These commands do not directly affect the state of the buffer pool. They serve to group micro-commands by a logical buffer operation.(For example, Pin a page).

      Format:
      Macro-commands don't have leading spaces, and if a PageID follows the command name, TAB is used to separate them. An end-record is necessary to "close" each macro-command. The end-record must consist of the sting "END" followed (with no space separation) by the exact text of the initiating macro-command.

      Supported Macro-commands:                                        Meaning
      Pin page(TAB)<page>                                  <==          Pin the page <page>
      Unpin page(TAB)<page>                             <==           Unpin the page <page>
      Free page(TAB)<page>                                <==          Free the page <page>
      New page(TAB)                                           <==          New a page(*)
      Flush page(TAB)<page>                               <==          Flush the page<page>
      Flush pages(TAB)ALL                                  <==          Flush all pages

      *The format for the ending of "New page" is "ENDNew page(TAB)<page>", where <page> is the new allocated page
       
       

    5. Special-commands

    6. Reading and writing page are special commands, because they differ from macro-commands (they are atomic) and from micro-commands (they don't change the state of the buffer pool).

      Format:
      (2 spaces)READ page(TAB)<page>
      (2 spaces)WRITE page(TAB)<page>

    Note that macro-commands can be nested, for example, if you want to free a pinned page, you have to unpin that page first, before you can deallocate it.
     

    Running BufferSim

     
    Requirements for BufferSim
    The file written out by the buffer manager should be in the same format of an input file for the BufferSim (see details and example above).
  • Whenever one of the PinCount, dirty, PageID variable is changed for a given frame, a micro-command should be written out to file using the output stream declared in main.
  • Whenever one of the  PinPage, UnpinPage, FreePage, NewPage, FlushPage, FlushAllPages functions (i.e.  the macro commands) are called, or the disk manager reads (or writes) a page to disk (via a special-command), the corresponding macro-commands and special commands should also be written to a output file using the output stream declared in main. Since processing each macro-command  calls several micro-commands, each micro-command called must be written into the  file before the end-record of the macro-command is written. The format should be as specified above.

  •