// allocated to satyaprakash 

class PageTable {

 public:


   int set_page_size (int size); // selects page size for this experiment e.g. 4 KB
   int set_memory_width (int w); // data width per address -- how many bytes? 
   int set_main_memory_size (int size); // selects main memory size for this experiment
   int set_logical_address_width (int w); // decides logical address width in bits

   int alloc (int pid, int k); // allocates k pages to a process 
   int free (int pageid, int pid); // frees given logical page 

   void create_a_process (int pid, int m);  // creates a process with m kb as default req.

   int get_page_id (int logical);  // given logical address, gives page id
   int get_frame_id (int pageid);  // given page id, gives frame id

   int validate (int pid, int la); // will the la for the given pid generate a segmentation fault? 

   void print_info (int pid);  // just dump page table of process given by 'pid'  --- pageid : frameid ---- and size of page table?


};



int main () {

PageTable pt;

  pt.set_page_size (4);  // 4 kb
  pt.set_main_memory_size (1024); // 1 gb 
  pt.set_memory_width (2); //  2 bytes
  pt.set_logical_address_width (16); // 16 bits

  pt.create_a_process(0,1);
  pt.create_a_process(1,4);
  pt.create_a_process(1,4);

  pt.alloc (0, 4); // for 0th process, 4 pages 

  int pgid = pt.get_page_id (103); 
  
  int frmid = pt.get_frame_id(pgid);

 
  int v = pt.validate (0, 200000); 

  pt.print_info (1);
   
}

