Tuesday, March 20, 2018

Banker's Algorithm

#include 
struct file  { 
  int all[10]; 
  int max[10]; 
  int need[10]; 
  int flag; 
  }; 
  void main() 
  {
    struct file f[10];
    int fl;
    int i, j, k, p, b, n, r, g, cnt=0, id, newr; 
    int avail[10],seq[10]; 
    printf("Enter number of processes -- "); 
    scanf("%d",&n);
    printf("Enter number of resources -- "); 
    scanf("%d",&r);  for(i=0;i    {
      printf("Enter details for P%d",i);
      printf("\nEnter allocation\t -- \t");
      for(j=0;j      scanf("%d",&f[i].all[j]);
      printf("Enter Max\t\t -- \t"); 
      for(j=0;j      scanf("%d",&f[i].max[j]);
      f[i].flag=0; 
     
    } 

    printf("\nEnter Available Resources\t -- \t"); 
    for(i=0;i    scanf("%d",&avail[i]);
    printf("\nEnter New Request Details -- "); 
    printf("\nEnter pid \t -- \t"); 
    scanf("%d",&id); 
    printf("Enter Request for Resources \t -- \t"); 
    for(i=0;i    { 
      scanf("%d",&newr); 
      f[id].all[i] += newr;
      avail[i]=avail[i] - newr; 
          } 
    for(i=0;i    { 
      for(j=0;j      { 
       f[i].need[j] = f[i].max[j] - f[i].all[j];
       if (f[i].need[j] < 0)
       f[i].need[j] = 0;
      }
   }

cnt = 0;
fl = 0;
while (cnt != n)
  {
    g = 0;
    for (j = 0; j < n; j++)
      {
 if (f[j].flag == 0)
   {
     b = 0;
     for (p = 0; p < r; p++)
       {
  if (avail[p] >= f[j].need[p])
    b = b + 1;
  else
    b = b - 1;
       }
     if (b == r)
       {
  printf ("\nP%d is visited", j);
  seq[fl++] = j;
  f[j].flag = 1;
  for (k = 0; k < r; k++)
  avail[k] = avail[k] + f[j].all[k];
  cnt = cnt + 1;
  printf ("(");
  for (k = 0; k < r; k++)
    printf ("%3d", avail[k]);
  printf (")");
  g = 1;
       }
   }
      }
    if (g == 0)
      {
 printf ("\n REQUEST NOT GRANTED -- DEADLOCK OCCURRED");
 printf ("\n SYSTEM IS IN UNSAFE STATE");
 goto y;
      }
  }

printf ("\nSYSTEM IS IN SAFE STATE");
printf ("\nThe Safe Sequence is -- (");
for (i = 0; i < fl; i++)
  printf ("P%d ", seq[i]);
printf (")");
y:printf ("\nProcess\t\tAllocation\t\tMax\t\t\tNeed\n");
for (i = 0; i < n; i++)
  {
    printf ("P%d\t", i);
    for (j = 0; j < r; j++)
      printf ("%6d", f[i].all[j]);
    for (j = 0; j < r; j++)
     
printf ("%6d", f[i].max[j]);
    for (j = 0; j < r; j++)
      printf ("%6d", f[i].need[j]);
    printf ("\n");
  }
}


INPUT 

Enter number of processes – 5
Enter number of resources -- 3 
Enter details for P0 
Enter allocation -- 0 1 0 
Enter Max -- 7 5 3
Enter details for P1 
Enter allocation -- 2 0 0 
Enter Max -- 3 2 2 
Enter details for P2
Enter allocation -- 3 0 2 
Enter Max -- 9 0 2 
Enter details for P3 
Enter allocation -- 2 1 1 
Enter Max -- 2 2 2
Enter details for P4 
Enter allocation -- 0 0 2 
Enter Max -- 4 3 3 
Enter Available Resources -- 3 3 2 
Enter New Request Details -- Enter pid -- 1 
Enter Request for Resources -- 1 0 2 

OUTPUT

P1 is visited( 5 3 2) 
P3 is visited( 7 4 3) 
P4 is visited( 7 4 5) 
P0 is visited( 7 5 5) 
P2 is visited( 10 5 7)
 
SYSTEM IS IN SAFE STATE

The Safe Sequence is -- (P1 P3 P4 P0 P2 ) 

Process       Allocation         Max            Need 
P0              0 1 0                  7 5 3           7 4 3 
P1              3 0 2                  3 2 2           0 2 0 
P2              3 0 2                  9 0 2           6 0 0
P3              2 1 1                  2 2 2           0 1 1
P4              0 0 2                  4 3 3           4 31

Friday, March 9, 2018

UNIT-III PPT

OS WEEKLY TEST QUESTIONS (12-3-18)



DESCRIPTIVE QUESTIONS

1. A) Define page fault. When does a page fault occur?
    B) Describe the action taken by OS when page fault occurs with diagram.

2. A)Consider the following page reference string
        7,0,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0   Assuming three frames, how
     many page faults would occur in each of the following cases:
         i) LRU                ii) FIFO

    B) State and Explain Belady’s anomaly with an example.


Fill in the blanks

1. Virtual memory is
(a) Large secondary memory (b) Large main memory
(c) Illusion of large main memory (d) None of the above

2 . Optimal page – replacement algorithm is difficult to implement, because :
a) it requires a lot of information b) it requires future knowledge of the reference string
c) it is too complex d) it is extremely expensive

3. The two methods how LRU page replacement policy can be implemented in hardware are COUNTER,REFERENCE BIT.

4. LRU stands for__________________________________________.

5. OPTIMAL PAGE REPLACEMENT yields the lowest of all possible page-faults,

Sunday, February 4, 2018

OPERATING SYSTEMS QUESTION BANK FOR FIRST MID


Unit-1
2 marks Questions
1.       Define operating system.
2.       List any four types of system calls.
3.       Define user view of OS.
4.       Define time-sharing systems.
5.       Define interrupt.
6.       Describe User Interface.

3 marks  Questions
1.       List any four functions of operating system.
2.       List the memory hierarchy available in operating system.
3.       Describe Client-Server Computing.
4.       Differentiate between Application and System Program.
5.       Describe different Multiprocessor System.
6.       Describe Design Goals of Operating System.

10     Marks questions
1.      (a) Explain the memory hierarchy available in a computer system.     
(b) Discuss services of an operating System with neat diagram.
2.      (a) Differentiate between user mode and kernel mode operations of the operating system with diagram.
            (b) Discuss  system call. Explain different types of system calls with examples?
3.      Describe different types of Computer System Architecture.
4.      Compare different types of Operating System Structure.
5.      (a)Classify System Program.
            (b) Identify system calls to copy File content from source to destination.
6.      (a) Compare different User Interfaces.
            (b) Differentiate between the client-server and peer-to-peer computing?


Unit-2
2 marks Questions
1.       Define process.
2.       Define Thread.
3.       What is a ready Queue.
4.       Define fork() function.
5.       Define exec() function.
6.       Define Inter Process Communication.

3 marks Questions
1.       List out component of Process in memory.
2.       List various states of Process.
3.       Describe Device queue.
4.       List requirement to satisfy critical section problem’s solution.
5.       Differentiate between Binary and Counting Semaphore.
6.       Draw general structure of Critical Section.

10 marks Questions
  1. (a) Discuss Life Cycle of Process with state transition diagram.                 
  2. (b) Describe operations on Processes.                                                              
  1. (a) Compare different types Process Schedulers?                                                                      
  2. (b) Consider the following set of processes.
Process
Arrival Time
Burst Time
P1
0
6
P2
1
1
P3
3
2
P4
4
3
P5
5
5

 Calculate Average waiting time and Average Turn Around Time using FCFS, SRTF Scheduling.    
                                                                                                    
3.       Describe Shared Memory System and Shared Memory System with example.
4.       (a) Discuss Peterson’s solution.
            (b)Explain   solution of Dining-Philosophers Problem using Semaphore.
5.       (a) Discuss Monitors with  diagram.
 (b) Explain   solution of Dining-Philosophers Problem using Monitor.
6.      (a) Describe Context Switching in Process Scheduling.
(b) Explain Process Control Block using Diagram.













Unit-3

2 marks Questions

1.      Define Cache Memory.
2.      Define Registers.
3.      What is Logical address space.

3 marks Questions

1.      Draw hardware protection diagram using base and Limit register.
2.      Summarize Dynamic loading.
3.       Differentiate between Compile Time and Load Time Address Binding.

10 marks Questions
1.       (a) Discuss Logical vs Physical address  space.
(b) Explain dynamic linking and Shared Library.
2.        (a) Compare different   memory allocation Strategies.
 (b) Explain different types of Fragmentation.   

Thursday, January 25, 2018

OPERATING SYSTEMS QUESTIONS FOR WEEKLY TEST -4

DESCRIPTIVE QUESTIONS

  1. Define Process. Explain Life Cycle of Process with state transition diagram.    
  2. Explain operations on Processes?   
  3. Explain Process Schedulers?                                                                      
  4. Consider the following set of processes.
Process
Arrival Time
Burst Time
P1
0
10
P2
1
1
P3
3
2
P4
4
1
P5
5
5








                                                                           Calculate Average waiting time and Average Turn Around Time using FCFS, SJF (Non-Preemptive ) Scheduling.              

BITS

1.      Process creation in UNIX  is made by means of the kernel system call.    [ ]                                                                                                                                                        a)create()   b)join()            c)fork()            d)delay()

2.      The Time elapsed between , process submission to its total completion is known as ---_______.                                                  [                  ]
            a) Wait time    b)Response time          c)Turn around time     d)Throughput

3.      PCB stands for ____________________________________.

4.      __________________ is a light weight process.

            5.      The ­­­­­­­­­­­­­­­­­­­_______ is the module that gives control of the CPU to the process selected by                         The  scheduler.                                                                                          

OPERATING SYSTEMS NOTES UNIT-I,II