Guest User

Untitled

a guest
Dec 11th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. int x;
  2. x = calculateConvergence();
  3. while (x == 1) {
  4.  
  5. int i;
  6. struct page *examplePage;
  7. for (i=0; i<noPages; i++) {
  8.  
  9. //get page
  10. examplePage = &pageArray[i];
  11.  
  12. //get first in page.
  13. struct page *inPage;
  14. struct node *currNode;
  15. currNode = examplePage->inPagesBase;
  16. int noOfOuts, z;
  17. float prevPValue;
  18. float sumOfInPages = 0;
  19. for(z=0; z<noPages; z++) {
  20.  
  21. if (currNode = NULL) {
  22. break;
  23. }
  24. else {
  25.  
  26. //get page
  27. inPage = currNode->page;
  28.  
  29. //get prev p value
  30. prevPValue = inPage->currentPValue;
  31.  
  32. //get nmber of outs
  33. noOfOuts = inPage->noOutPages;
  34.  
  35. //perform caluclation p(n-1)INPAGE/noOfOuts
  36. sumOfInPages = sumOfInPages + (prevPValue/noOfOuts);
  37.  
  38. //move to next node
  39. if (currNode->nextNode == NULL) {
  40. break;
  41. }
  42. else {
  43. currNode = currNode->nextNode;
  44. }
  45. }
  46. }
  47.  
  48. float sumOfInPagesTimesD;
  49. sumOfInPagesTimesD = D*sumOfInPages;
  50.  
  51. float firstHalf;
  52. firstHalf = ((1-D)/noPages);
  53.  
  54. float totalPValue = firstHalf + sumOfInPagesTimesD;
  55.  
  56. //set in struct
  57. examplePage->previousPValue = examplePage->currentPValue;
  58. examplePage->currentPValue = totalPValue;
  59. }
  60.  
  61. // x = calculateConvergence();
  62. }
  63.  
  64. return 1;
Add Comment
Please, Sign In to add comment