Basic CS-Operating System [3i Infotech Placement]: Sample Questions 38 - 39 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 38

Operating System
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 39

Operating System
Edit

Describe in Detail

Essay▾

What is shared memory? What is semaphore? How to use it?

Explanation

  • Shared memory allows program processes to exchange data more quickly than by reading and writing using the regular OS services.
  • Refers to an extra piece of memory attached to some addresses spaces for their owners to use.
  • Given figure shows two processes and their address spaces.
Two Processes and Their Address Space
  • A feature supported by UNIX System V, including Linux, SunOS and Solaris.
  • A shared memory segment is identified by a unique integer, the shared memory ID.

Semaphore

  • Semaphore is a simply a variable.
  • It is a shared resource in a multi-processing environment.
  • Provides signalling mechanism between the processes
  • Allows the processes to exclusively use certain shared structures- guaranteeing no disturbance from other processes.
  • The region of program that is to be run by only one process is called “critical section” . Critical section modifies shared state.
  • Semaphore provides simple and powerful mechanism to mutual exclusion among concurrent processes.
  • Two Types of Semaphore

    • Binary semaphore
    • Counting semaphore
Two Types of Semaphore
  • Binary semaphore:
    • Takes the value of 0 & 1.
    • Two major operations, wait and signal are defined on the semaphore.
    • Critical section controlled by the wait operation and exit from a critical region is taken by signal operation.
    • Used only mutex locks.
  • Counting semaphores:
    • Can take a count value instead of binary value.

Developed by: