Basic CS [3i Infotech Placement]: Sample Questions 219 - 220 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 219

Edit

Write in Short

Short Answer▾

Which function should be used to free the memory allocated by calloc () ?

Explanation

  • free () is a function used to free the memory allocated dynamically, by both malloc and calloc functions.
  • free (ptr) ;
  • ptr is a pointer to a memory block which has already been created by malloc or calloc.
  • The memory we give back by calling free () is immediately available to other parts of program.
  • When we program exits, any allocated memory not freed is automatically released by the operating system.
  • Used data is prepended to the allocated block to manage the heap. If memory pointed to was not allocated by a heap allocation function as malloc () or calloc () , then the data preceding the block will be management data.

Question 220

Edit

Describe in Detail

Essay▾

What is thrashing?

Explanation

Graph this Indicate Thrashing
  • Thrashing is little progress in a computer system because memory or other resources are either exhausted or limited to perform needed operations.
  • Caused in virtual memory schemes when the processor spends most of its time swapping pages- due to page faults.
  • It is caused when pages in memory refer other pages.
  • The large “working set” of active processes cannot be all accommodated in the real memory.
  • Virtual memory systems allows placing some pages on virtual memory- only bringing required page on demand into the RAM.
  • A thrashing system is either a very slow system might come to a halt.
  • Generally occurs when enough frames are not allocated to a process than are needed.

Two Ways to Prevent Thrashing

  • Instruct mid-term scheduler to swap out some of the process to recover from thrashing
  • Instructing the dispatcher not to load more processes after a threshold

Developed by: