Showing posts with label Operating systems. Show all posts
Showing posts with label Operating systems. Show all posts

Sunday, August 18, 2013

Operating Systems 03

21. Resources are allocated to the process on non-shareable basis is
[Paper II June 2012]
(A) mutual exclusion
(B) hold and wait
(C) no pre-emption
(D) circular wait

22. Cached and interleaved memories are ways of speeding up memory access between CPU’s and slower RAM. Which memory models are best suited (i.e. improves the performance most) for which programs?     [Paper II June 2012]
(i) Cached memory is best suited for small loops.
(ii) Interleaved memory is best suited for small loops
(iii) Interleaved memory is best suited for large sequential code.
(iv) Cached memory is best suited for large sequential code.
(A) (i) and (ii) are true.
(B) (i) and (iii) are true.
(C) (iv) and (ii) are true.
(D) (iv) and (iii) are true.

23. Consider the following page trace: 4,3, 2, 1, 4, 3, 5, 4, 3, 2, 1, 5
Percentage of page fault that would occur if FIFO page replacement algorithm is used with number of frames for the JOB m = 4 will be                       [Paper II June 2012]
(A) 8                (B) 9
(C) 10             (D) 12


24. Given memory partitions of 100 K, 500 K, 200 K, 300 K and 600 K (in order) and processes of 212 K, 417 K, 112 K, and 426 K (in order), using the first-fit algorithm, in which partition would the process requiring 426 K be placed ?                  [Paper II December 2012]
(A) 500 K
(B) 200 K
(C) 300 K
(D) 600 K

25. The problem of indefinite blockage of low-priority jobs in general priority scheduling algorithm can be solved using:   [Paper II December 2012]
(A) Parity bit
(B) Aging
(C) Compaction
(D) Timer

26. Which of the following memory allocation scheme suffers from external fragmentation?
[Paper II December 2012]
(A) Segmentation
(B) Pure demand paging
(C) Swapping
(D) Paging

27. In UNIX, which of the following command is used to set the task priority?      
[Paper II December 2012]
(A) init
(B) nice
(C) kill
(D) PS




SOLUTIONS
21. A

22.

23. C
The first 4 page references will cause page faults and they are brought into the 4 page frames available. The sequence is shown below
4 - page fault, brought to frame. Page Frame : 4
3 - page fault, brought to frame. Page Frame : 4, 3
2 - page fault, brought to frame. Page Frame : 4, 3, 2
1 - page fault, brought to frame. Page Frame : 4, 3, 2, 1
4 - available in the frame, no page fault occurs. Page Frame : 4, 3, 2, 1
3 - available in the page frame, no page fault occurs. Page Frame : 4, 3, 2, 1
When the fame is full and a page fault occurs, then the page that was first brought in is removed and the referred page is brought in to the frame.
5 - not in the page frame, page fault. 4 is removed and 5 is brought is. Page Frame : 5, 3, 2, 1
4 - not in the page frame, page fault. 3 is removed and 4 is brought is. Page Frame : 5, 4, 2, 1
3 - not in the page frame, page fault. 2 is removed and 3 is brought is. Page Frame : 5, 4, 3, 1
2 - not in the page frame, page fault. 1 is removed and 2 is brought is. Page Frame : 5, 4, 3, 2
1 - not in the page frame, page fault. 5 is removed and 1 is brought is. Page Frame : 1, 4, 3, 2
5 - not in the page frame, page fault. 4 is removed and 5 is brought is. Page Frame : 1, 5, 3, 2

24. A
100 K, 500 K, 200 K, 300 K and 600 K (in order) and processes of 212 K, 417 K, 112 K, and 426 K
According the to the first fit algorithm, the memmory will be scanned to find out the memory portion that is enough for the arriving process, The first such portion found is allocated to the process. In the given example when process of size 212K arrives it is placed in memory portion with size 500K. This leaves an unused space of 288K. Now 417K arrioves it is placed inportion with size 600K, leaving 183K unused. Now 112K arrives and this can be placed in the un used sopace of 183K. Atlast the process of 426K arrives, we dont have memory block large enough to hold this, so we need to remove some already allocated process and allocate that block. 500k block is the one suitable if we do a linear search.
25. B

26. A

27. B
init - Init is the parent of all processes. Its primary role is to create processes from a script stored in the file
nice - run a program with modified scheduling priority
kill - terminate a process

ps - report process status

Saturday, July 27, 2013

Operating Systems 02

11. The maximum amount of information that is available in one portion of the disk access arm for a removal disk pack (without further movement of the arm with multiple heads) [Paper II December 2011]
(A) a plate of data
(B) a cylinder of data
(C) a track of data
(D) a block of data

12. Which of the following is scheme to deal with deadlock?      [Paper III June 2012]
(A) Time out
(B) Time in
(C) Both (A) & (B)
(D) None of the above

13. A computer system supports 32 bit virtual address as well as 32 bit physical addresses. Since the virtual address space is of same size as that of physical address space, if we want to get rid of virtual memory, which one of the following is true?                                              [Paper III June 2012]
(A) Efficient implementation of multi-user support is no longer possible.
(B) The processor cache can be made more efficient.
(C) Hardware support for memory management is not needed.
(D) CPU scheduling can be made more efficient.

14. A user level process in Unix traps the signal sent on a Ctrl + C input and has a signal handling routine that saves appropriate files before terminating the process. When a Ctrl + C input is given to this process, what is the mode in which the signal handling routine executes?              [Paper III June 2012]
(A) User mode
(B) Kernel mode
(C) Superuser mode
(D) Privileged mode

15. Consider the methods used by processes P1 and P2 for accessing their critical sections. The initial values of shared Boolean variables S1 and S2 are randomly assigned, 
          P1                                             P2
while (S1 = = S2);                  while (S1 = = S2);
critical section                         critical section
S1 = S2;                                 S1 = S2;
Which one of the following statements describes the properties achieved?        [Paper III June 2012]
(A) Mutual exclusion but not progress
(B) Progress but not mutual exclusion
(C) Neither mutual exclusion nor progress
(D) Both mutual exclusion and progress

16. What is the meaning of ‘Hibernate’ in Windows XP/Windows 7? [Paper III June 2012]
(A) Restart the computers in safe mode.
(B) Restart the computers in normal mode.
(C) Shutdown the computer terminating all the running applications.
(D) Shutdown the computer without closing the running applications.

17. Which one of the following options is not a shell in UNIX system?  [Paper III June 2012]
(A) Bourne Shell
(B) C Shell
(C) Net Shell
(D) Korn Shell


18. What deletes the entire file except the file structure?                     [Paper II June 2012]
(A) ERASE                 (B) DELETE
(C) ZAP                      (D) PACK

19. Which command is the fastest among the following?                     [Paper II June 2012]
(A) COPY TO <NEW FILE>
(B) COPY STRUCTURE TO <NEW FILE>
(C) COPY FILE <FILE 1> <FILE 2>
(D) COPY TO MFILE-DAT DELIMITED

20. In round robin CPU scheduling as time quantum is increased the average turn-around-time            [Paper II June 2012]
(A) increases
(B) decreases
(C) remains constant
(D) varies irregularly



SOLUTIONS
11. B
Data is read from disk by positioning the arm on the correct track and then rotating the disk to read data in the track. Same tracks in different plates form a cylinder. So data can be read from a cylinder without further moving the arm provided it has multiple heads for reading.
Disk showing track and cylinder


12. A
One of the for necessary conditions required for deadlock to occur is hold-and-wait. This can be avoided by adding time-out for the resource or the process. That is a process waiting for more than a fixed amount of time should stop waiting and release all the resources acquired by that. Or any resource that is held by a process for more than a fixed amount of time should be released.

13. A

14. ?

15. C
As both S1 and S2 are assigned random values initially, both can be same, in which case both processes wait indefinitely without entering critical section. Even if S1 != S2 initially, when one process executes the critical section and exits S1 is equated to S2, Neither process P1 or P2 can enter critical section after this. So there is no progress.
Now considering mutual exclusion, when S1 !=S2, suppose P1 enters critical section and is executing it, at the same time P2 checks for the values of S1 and S2, finds they are same and enters the critical section. So there is no mutual exclusion also. This can be solved by modifying the code as 
          P1                                             P2
while (S1 = = S2);                  while (S1 = = S2);
S1 = S2;                                 S1 = S2 = true;
critical section                         critical section
S1 = !S2;                                S1 = !S2; 

Here both processes P1 and P2 sets S1=S2 before entering the critical section, so no other process can enter. So Mutual exclusion is attained, Also once the execution of critical section is over, the process makes S1!=S2, so that any waiting process can enter.

16. D

17. C


The shell provides you with an interface to the UNIX system. It gathers input from you and executes programs based on that input. When a program finishes executing, it displays that program's output.A shell is an environment in which we can run our commands, programs, and shell scripts.
In UNIX there are two major types of shells:
  • The Bourne shell. If you are using a Bourne-type shell, the default prompt is the $ character.
  • The C shell. If you are using a C-type shell, the default prompt is the % character.
There are again various subcategories for Bourne Shell which are listed as follows:
  • Bourne shell (sh)
  • Korn shell (ksh)
  • Bourne Again shell (bash)
  • POSIX shell (sh)
The different C-type shells follow:
  • C shell (csh)
  • TENEX/TOPS C shell (tcsh)
18. C
PACK: Shrinks file into one small (compressed) file so that it does not take as much space up.
ZAP: Removes all records from a table, leaving just the table structure.
ERASE/DELETE is a command used to remove files from your computer's hard drive or other writeable media.

19. ?

20. B
The round-robin scheduling algorithm is designed especially for time-sharing systems. It is similar to FCFS scheduling, but pre-emption is added to switch between processes. A small unit of time, called a time quantum or time slice, is defined. When a process finishes the time quantum it is switched and the next process in queue is taken for execution.
Turnaround Time is the time elapsed from when process is submitted to when it is completed. It includes execution time and waiting time and switching time between processes.
When the time quantum is increased, the no. of times the process is switched decreases reducing the switching time between processes. So Average turn around time gets reduced

Wednesday, July 17, 2013

Operating Systems 01

1. Match the following: [Paper III December 2012]
     List – I              List – II
a. Critical region 1. Hoares Monitor
b. Wait/signal 2. Mutual exclusion
c. Working set         3. Principal of locality
d. Dead lock 4. Circular wait
Codes :
        a b c d
(A) 2 1 3 4
(B) 1 2 4 3
(C) 2 3 1 4
(D) 1 3 2 4

2. Which of the following features will characterize an OS as multiprogrammed OS?
(a) More than one program may be loaded into main memory at the same time.
(b) If a program waits for certain event another program is immediately scheduled.
(c) If the execution of a program terminates, another program is immediately scheduled.
                                                                                                                       [Paper III December 2012]
(A) (a) only
(B) (a) and (b) only
(C) (a) and (c) only
(D) (a), (b) and (c) only

3. A thread is a light weight process. In the above statement, weight refers to:    [Paper III December 2012]
(A) time
(B) number of resources
(C) speed
(D) All the above

4. Everything below the system call interface and above the physical hardware is known as ______.
                                                                                                                        [Paper III December 2012]
(A) Kernel
(B) Bus
(C) Shell
(D) Stub

5. Which of the following operating system is better for implementing client-server network?
                                                                                                                        [Paper III December 2012]
(A) Windows 95
(B) Windows 98
(C) Windows 2000
(D) All of these

6. Consider a system having m resources of the same type. These resources are shared by 3 processes A, B and C which have peak demands of 3, 4 and 6 respectively. For what value of m deadlock will not occur?                                                                                                                           [Paper III December 2012]
(A) 7
(B) 9
(C) 10
(D) 13

7. Consider n processes sharing the CPU in round robin fashion. Assuming that each process switch takes s seconds, what must be the quantum size q such that the overhead resulting from process switching is minimized but, at the same time each process is guaranteed to get its turn at the CPU at least every t seconds?                                                                                                         [Paper III December 2012]
(A) q ≤ (t – ns)/(n – 1)
(B) q ≥ (t – ns)/(n – 1)
(C) q ≤ (t – ns)/(n + 1)
(D) q ≥ (t – ns)/(n + 1)

8. Dijkestra banking algorithm in an operating system, solves the problem of 
[Paper II December 2011]
 (A) deadlock avoidance
(B) deadlock recovery
(C) mutual exclusion
(D) context switching

9. The multiuser operating system, 20 requests are made to use a particular resource per hour, on an average the probability that no request are made in 45 minutes is [Paper II December 2011]
(A) e–15               (B) e–5
(C) 1 – e–5           (D) 1 – e–10

10. On receiving an interrupt from an I/O device, the CPU   [Paper II December 2011]
 (A) halts for predetermined time.
(B) branches off to the interrupt service routine after completion of the current instruction.
(C) branches off to the interrupt service routine immediately.
(D) hands over control of address bus and data bus to the interrupting device.




SOLUTION
1.  A
Critical region: In concurrent programming, a critical section/region is a piece of code that accesses a shared resource that must not be concurrently accessed by more than one thread of execution. Some synchronization mechanism is required at the entry and exit of the critical section to ensure exclusive use (Mutual exclusion), for example a semaphore.
Hoare’s Monitor: Monitors used for synchronization were invented by C. A. R. Hoare
A program's working set W(t,T) at time t is the set of distinct pages among the T most recently referenced pages.
Necessary Condition for deadlock to occur: Hold and wait, Circular wait, Mutual exclusion, No pre-emption

2. D

3. B

4. A

5. C

6. D
Deadlock occurs when one process is holding a resource and another is waiting for it, which continues in a circular fashion. In short there is a possibility of deadlock when a process acquires the resources that it need partially and waits for another resource acquired by another process. Here the peak demand for each processes A, B and C is given as 3, 4 and 6 respectively. Suppose the peak demand for all the three processes happens simultaneously then we will require 3 + 4 + 6 = 13 resources to satisfy the demand. So to avoid the hold and wait condition we require 13 resources. But Hold and wait alone will not cause deadlock (refer solution to Question 1). We also need a circular wait condition. What can be the maximum number of resources that can be allocated and still a circular wait occur? It is 10. Suppose A gets 2 resources and wait for the third from B which has got 3 resources and is waiting for the forth from C, which got 5 and waits for the sixth from A. But when we have 11 resources any one of the processes get sufficient number of resources and the circular wait chain breaks resulting in the avoidance of deadlock. So the minimum number of resources that can avoid deadlock is 11. But we don’t have that option here, so the answer is 13.

7. B