Basic CS-Operating System [3i Infotech Placement]: Sample Questions 63 - 64 of 89

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

Question 63

Operating System
Edit

Describe in Detail

Essay▾

Explain the concept of re-entrancy.

Explanation

  • Subroutine is reentrant if it can be interrupted in the middle and then be safely called again ( “re-entered” ) before its previous invocations complete execution.
  • Useful memory-saving technique for multiprogrammed time-sharing systems.
  • Allows multiple clients to share a single copy of a program during similar period.
  • 2 keys requirements:
    • The program code cannot modify itself.
    • The local data for each user process is stored separately.

Implementations

  • The permanent part is the code, and temporary part is the pointer back to calling program and local variables used by that program.
  • Temporary phase associated with each activity is the activation record.
  • Every instance of execution is called activation.
  • Execute code is in the permanent part, but with its own copy of variable.
  • The activation record is kept on the stack.

Question 64

Operating System
Edit

Describe in Detail

Essay▾

Can you dynamically allocate arrays in a single call to malloc?

Explanation

Understanding of Malloc Function
  • malloc can be used to allocate memory for single variable also,
  • p = (int ⚹) malloc (sizeo (int) ) ;
  • Allocates space for a single int, which can be accessed as ⚹ p.
  • Single variable allocations are just special case of array allocations.
  • Array with only one element.

Developed by: