Page 199 - DCAP103_Principle of operating system
P. 199

Principles of Operating Systems



                   Notes         As  with  the  working-set  strategy,  we  may  have  to  suspend  a  process.  If  the  page-fault  rate
                                 increases and no free frames are available, we must select some process and suspend it. The
                                 freed frames are then distributed to processes with high page-fault rates.






                                                 Write a program for memory management



                                    #include <memory>

                                    #include <iostream>
                                    int main( ) {
                                       std::auto_ptr<int> a(new int(3));
                                       // a.get( ) returns the raw pointer of a
                                       std::cout << “a loc: “ << a.get( ) << ‘\n’;

                                       std::cout << “a val: “ << *a << ‘\n’;

                                       std::auto_ptr<int> b;

                                       b = a; // now b points to the int, a is null


                                       std::cout << “b loc: “ << b.get( ) << ‘\n’;
                                       std::cout << “b val: “ << *b << ‘\n’;
                                       std::cout << “a loc: “ << a.get( ) << ‘\n’;


                                       return 0;
                                    }
                                  Questions:

                                    1.  Give the brief about the pointer in memory.
                                    2.  Explain the Garbage collection (GC) in memory management.

                                                1.  Assuming a 1-KB page size, what are the page numbers and offsets for
                                                   the following address references (provided as a decimal numbers):
                                                   (  a)  2375
                                                   (  b)  19366
                                                   (  c)  30000
                                                   (  d)  256
                                                   (  e)  16385
                                                2.  C Program for First In First Serve Algorithm.






        192                               LOVELY PROFESSIONAL UNIVERSITY
   194   195   196   197   198   199   200   201   202   203   204