Basic CS [3i Infotech Placement]: Sample Questions 112 - 113 of 243

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 112

Edit

Describe in Detail

Essay▾

What is the resident set and working set of a process?

Explanation

Resident Set

  • Portion of the process image that is actually in real-memory at a particular instant.
  • OS manages the size and allocation policies effecting the resident set.

    Two types of resident set size:

    • Fixed-allocation:
      • Gives a process a fixed number of pages within which to execute- When a page fault occurs, one of the pages must be replaced.
    • Variable- allocation:
      • Number of pages allocated to a process variable over the lifetime of the process.

Working Set

  • Subset of resident set that is actually needed for execution.
  • The size of the working set changes during the execution of the process depending on the locality of accesses.
  • If the number of pages allocated to a process covers its working set the number of page faults is small.
  • OS must schedule a process only with enough free memory to load its working set.

Question 113

Edit

Describe in Detail

Essay▾

Define pointer to function that take argument as character pointer and return void pointer.

Explanation

  • (void ⚹) (⚹ foo) (⚹ char) .

Declare a pointer to function:

  • int ⚹ ptrInteger;
    • here, ptrInteger is a pointer to integer.
  • int foo (int) ;
    • foo is a function that returns int and take one argument of int type.
    • A ⚹ operator between int and foo (int) should create a pointer to a function.
    • We have to bind operator ⚹ with foo.
  • int (⚹ foo) (int) ;
    • ⚹ operator is with foo which is a function name.
  • Like normal data pointer, a function pointer can be passed as an argument and also returned from a function.

Ex. .

void fun1 ()

{

print ( “Fun1” ) ;

}

void fun2 ()

{

printf ( “fFun2” )

}

void wrapped (void (⚹ fun) () )

{

fun () ;

}

int main ()

{

wrapper (fun1) ;

wrapper (fun2) ;

return 0;

}

  • We can use function pointer to avoid code redundancy.
  • Function pointers and void pointers, it is possible to use qsort for any data type.

Developed by: