Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. //DETTE ER VORES KODE
  2. public void unpinPage(PageId pageno, boolean dirty) throws IllegalArgumentException {
  3.  
  4. FrameDesc fdesc = pagemap.get(pageno.pid);
  5.  
  6. if (fdesc == null || pageno == null || fdesc.pincnt == 0){
  7. throw new IllegalArgumentException("PageID or FrameDesc is null, or page is not pinned.");
  8. }
  9. if (fdesc.dirty == false && dirty == true){
  10. fdesc.dirty = true;
  11. }
  12. replacer.unpinPage(pagemap.get(pageno.pid));
  13. }
  14.  
  15. //DETTE ER JERES KODE
  16. public void unpinPage(PageId pageno, boolean dirty) throws IllegalArgumentException {
  17. FrameDesc fdesc;
  18. fdesc = pagemap.get(pageno.pid); // get the framedesc from pagemap
  19. if (fdesc == null || pageno == null || fdesc.pincnt == 0) {
  20. throw new IllegalArgumentException("Page is not present or pinned!");
  21. } else {
  22. fdesc.pincnt--; // decrease pincnt
  23. if (dirty) {
  24. fdesc.dirty = true;
  25. }
  26. if (fdesc.dirty == true && dirty == false) {
  27. fdesc.dirty = true;
  28. }
  29. if (fdesc.dirty == false && dirty == false) {
  30. fdesc.dirty = false;
  31. }
  32. clock.unpinPage(fdesc); // notify the clock
  33. pagemap.put(pageno.pid, fdesc); // put it back into pagemaps
  34.  
  35. }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement