Guest User

Untitled

a guest
Jan 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.91 KB | None | 0 0
  1. /*
  2.     File: frame_pool.H
  3.  
  4.     Author: R. Bettati
  5.             Department of Computer Science
  6.             Texas A&M University
  7.     Date  : 09/03/05
  8.  
  9.     Description: Management of the Free-Frame Pool.
  10.  
  11.  
  12. */
  13.  
  14. #ifndef _FRAME_POOL_H_                   // include file only once
  15. #define _FRAME_POOL_H_
  16.  
  17. /*--------------------------------------------------------------------------*/
  18. /* DEFINES */
  19. /*--------------------------------------------------------------------------*/
  20.  
  21. /* -- (none) -- */
  22.  
  23. /*--------------------------------------------------------------------------*/
  24. /* INCLUDES */
  25. /*--------------------------------------------------------------------------*/
  26.  
  27. /* -- (none) -- */
  28.  
  29. /*--------------------------------------------------------------------------*/
  30. /* DATA STRUCTURES */
  31. /*--------------------------------------------------------------------------*/
  32.  
  33. /* -- (none) -- */
  34.  
  35. /*--------------------------------------------------------------------------*/
  36. /* F r a m e   P o o l  */
  37. /*--------------------------------------------------------------------------*/
  38.  
  39. class FramePool {
  40. private:
  41.      /* -- DEFINE YOUR FRAME POOL DATA STRUCTURE(s) HERE. */
  42.      unsigned long base_frame_no;
  43.      unsigned long nframes;
  44.      unsigned long info_frame_no;
  45.      unsigned char* base_frame_pointer;
  46.      
  47.  
  48. public:
  49.    static const unsigned int FRAME_SIZE = 4096;
  50.    /* Size of a frame in bytes */
  51.  
  52.    FramePool(unsigned long _base_frame_no,
  53.              unsigned long _nframes,
  54.              unsigned long _info_frame_no);
  55.    /* Initializes the data structures needed for the management of this
  56.       frame pool. This function must be called before the paging system
  57.       is initialized.
  58.       _base_frame_no is the frame number at the start of the physical memory
  59.       region that this frame pool manages.
  60.       _nframes is the number of frames in the physical memory region that this
  61.       frame pool manages.
  62.       e.g. If _base_frame_no is 16 and _nframes is 4, this frame pool manages
  63.       physical frames numbered 16, 17, 18 and 19
  64.       _info_frame_no is the frame number (within the directly mapped region) of
  65.       the frame that should be used to store the management information of the
  66.       frame pool. However, if _info_frame_no is 0, the frame pool is free to
  67.       choose any frame from the pool to store management information.
  68.       */
  69.  
  70.    unsigned long get_frame();
  71.    /* Allocates a frame from the frame pool. If successful, returns the frame
  72.     * number of the frame. If fails, returns 0. */
  73.  
  74.    void mark_inaccessible(unsigned long _base_frame_no,
  75.                           unsigned long _nframes);
  76.    /* Mark the area of physical memory as inaccessible. The arguments have the
  77.     * same semanticas as in the constructor.
  78.     */
  79.  
  80.    void release_frame(unsigned long _frame_no);
  81.    /* Releases frame back to the given frame pool.
  82.       The frame is identified by the frame number. */
  83. };
  84. #endif
Add Comment
Please, Sign In to add comment