Page faults

This is a discussion on Page faults within the Tech Board forums, part of the Community Boards category; Consider the two dimensional array A: int A[ ] [ ] = new int [50] [50] where A[0] [0] is ...

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    1

    Page faults

    Consider the two dimensional array A:
    int A[ ] [ ] = new int [50] [50]
    where A[0] [0] is at location 400, in a paged system with pages of size 400. A small process is in page 0 (locations 0 to 399) for manipulating the matrix; thus, every instruction fetch will be from page 0.
    For three page frames, how many page faults are generated by the following array-initialization loops, using LRU replacement, and assuming page frame 1 has the process in it, and the other two are initially empty:
    for (int j = 0; j < 100; j++)
    for (int i = 0; i < 100; i++)
    A[i][j] = 0;
    My answer:I workout 625 faults for above.Anyone correct me if i am wrong.
    Last edited by jackhuman; 06-25-2011 at 01:45 PM.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,417
    > int A[ ] [ ] = new int [50] [50]
    ...
    > for (int j = 0; j < 100; j++)
    So what about segmentation faults when you access memory outside of your array bounds?

    Are you assuming anything about the size of an integer?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A huge page faults problem
    By g4j31a5 in forum C++ Programming
    Replies: 12
    Last Post: 10-22-2008, 03:42 AM
  2. It seg faults right away
    By Brimak86 in forum C Programming
    Replies: 6
    Last Post: 01-31-2008, 09:40 PM
  3. It seg faults
    By Brimak86 in forum C Programming
    Replies: 2
    Last Post: 01-15-2008, 08:06 PM
  4. Whats the deal with page faults?
    By Deo in forum Game Programming
    Replies: 5
    Last Post: 06-10-2005, 10:13 PM
  5. Invalid Page Faults with Command Line Args
    By KneeLess in forum C++ Programming
    Replies: 5
    Last Post: 09-29-2003, 05:40 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21