libckpt


 
Thread Tools Search this Thread
Operating Systems Solaris libckpt
# 1  
Old 04-30-2010
libckpt

i am not understanding this piece of code if anyone could help me out wid this, it wld b really appreciated

Code:
/**************************************************************
 * function: write_heap
 * args: map_fd  -- file descriptor for map file
 *       data_fd -- file descriptor for data file
 * returns: no. of chunks written on success, -1 on failure
 * side effects: writes all included segments of the heap to ckpt files
 * misc.: If we are forking and copyonwrite is set, we will write the
          heap from bottom to top, moving the brk pointer up each time
          so that we don't get a page copied if the
 * called from: take_ckpt()
 *************************************************************/
static int write_heap(int map_fd, int data_fd)
{
  Dlist curptr, endptr;
  int no_chunks=0, pn;
  long size;
  caddr_t stop, addr;

  if(ckptflags.incremental){       /*-- incremental checkpointing on? --*/
    endptr = ckptglobals.inc_list->main->flink;
 
    /*-- for each included chunk of the heap --*/
    for(curptr = ckptglobals.inc_list->main->blink->blink;
        curptr != endptr; curptr = curptr->blink){

      /*-- write out the last page in the included chunk --*/
      stop = curptr->addr;
      pn = ((long)curptr->stop - (long)sys.DATASTART) / PAGESIZE;

      if(isdirty(pn)){ 
        addr = (caddr_t)max((long)curptr->addr,
                            (long)((pn * PAGESIZE) + sys.DATASTART));
        size = (long)curptr->stop - (long)addr;

        debug(stderr, "DEBUG: Writing heap from 0x%x to 0x%x, pn = %d\n",
                                                   addr, addr+size, pn);
        if(write_chunk(addr, size, map_fd, data_fd) == -1){
          return -1;
        }

        if((int)addr > (int)(&end) && ckptflags.enhanced_fork){
          brk(addr);
        }
        no_chunks++;
      }

      /*-- write out all the whole pages in the middle of the chunk --*/
      for(pn--; pn * PAGESIZE + sys.DATASTART >= stop; pn--){
        if(isdirty(pn)){
          addr = (caddr_t)((pn * PAGESIZE) + sys.DATASTART);
          debug(stderr, "DEBUG: Writing heap from 0x%x to 0x%x, pn = %d\n",
                                                 addr, addr+PAGESIZE, pn);
          if(write_chunk(addr, PAGESIZE, map_fd, data_fd) == -1){
            return -1;
          }
          if((int)addr > (int)(&end) && ckptflags.enhanced_fork){
            brk(addr);
          }
          no_chunks++;
        }
      }

      /*-- write out the first page in the included chunk --*/
      addr = curptr->addr;
      size = ((pn+1) * PAGESIZE + sys.DATASTART) - addr;

      if(size > 0 && (isdirty(pn))){
        debug(stderr, "DEBUG: Writing heap from 0x%x to 0x%x\n", addr, addr+size);
        if(write_chunk(addr, size, map_fd, data_fd) == -1){
          return -1;
        }

        if((int)addr > (int)(&end) && ckptflags.enhanced_fork){
          brk(addr);
        }
        no_chunks++;
      }
    }
  }
  else{  /*-- incremental checkpointing off! --*/
    endptr = ckptglobals.inc_list->main->blink;

    /*-- for each included chunk of the heap --*/
    for(curptr = ckptglobals.inc_list->main->flink->flink;
        curptr != endptr; curptr = curptr->flink){
      debug(stderr, "DEBUG: saving memory from 0x%x to 0x%x\n", 
                         curptr->addr, curptr->addr+curptr->size);

      if(write_chunk(curptr->addr, curptr->size, map_fd, data_fd) == -1){
        return -1;
      }
      if((int)addr > (int)(&end) && ckptflags.enhanced_fork){
        brk(addr);
      }
      no_chunks++;
    }
  }

  return no_chunks;
}


Last edited by jim mcnamara; 04-30-2010 at 10:51 AM.. Reason: code tags please
# 2  
Old 04-30-2010
Quote:
Originally Posted by aks_icon
i am not understanding this piece of code
Looks like poorly formatted still quite readable and documented C code.
What part are you failing to understand ?
# 3  
Old 04-30-2010
here's another thread to the same piece of code, with a little more clarity. can you go through it? and let me know your response
Code to write the heap into a file
thanks
# 4  
Old 04-30-2010
You might start reading that:
http://www.cs.utk.edu/~plank/plank/p...USENIX-95W.pdf

What exactly are you failing to understand ? The checkpointing concept ? The heap one ? This function implementation ?
# 5  
Old 04-30-2010
libckpt

hi i m actually not understanding how the heap is written and how the contents are written to the checkpoint files,... i need a lil more clarity on how that piece of code works,... i.e.,have u worked on libckpt and made it run on solaris???

---------- Post updated at 10:35 AM ---------- Previous update was at 10:26 AM ----------

Thanks for the PDF,...i got an idea somewhat,...in libckpt u know i m not able to recover from the checkpoints once they r created thats another issue i wanted to ask,... these are the commands i type to execute the libckpt,it is available here in the link below
http://www.cs.utk.edu/~plank/plank/www/libckpt.html
the steps i followed to run it were,...

make
make example
./mult
./mult =recover --this is wr i get the error sayin CKPT:unable to re-openfiles during recovery

i got an idea from the link which u sent really appreciate it,... this is just another query if u can help me run the library on opensolaris i wld b very thankful to u,... i ve bin struggling to run the code for almost a month or so....i hope ll get a response very soon cheers!!
# 6  
Old 04-30-2010
No, I'm not a user a this library. What it does is certainly not something common or easy to debug. It looks more like a research area. I would love to have this library to run on OpenSolaris but I have unfortunately not the spare time required to complete that, and possibly neither enough Solaris internal knowledge to port it.
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question