Sunteți pe pagina 1din 14

B.E/B.Tech DEGREE EXAMINATION,MAY/JUNE 2012.

Fourth Semester Computer Science and Engineering CS2254/141404/CS45/CS1253/10144CS405/080250012-OPERATING SYSTEMS (Common to Information Technology) (Regulation 2008) Time : Three hours PART A-(10*2=20 marks) 1. What are the main purposes of an operating system? The purpose of an operating system is to provide an environment in which a user can execute programs. The primary goal of an operating system is thus to make the computer system convenient to use. A secondary goal is to use the computer hardware in an efficient manner. 2. What are the difference between user level-threads and kernel-level threads? User-level threads are threads that the OS is not aware of. They exist entirely within a process, and are scheduled to run within that process's timeslices. The OS is aware of kernel-level threads. Kernel threads are scheduled by the OS's scheduling algorithm, and require a "lightweight" context switch. 3. What is the difference between preemptive and nonpreemptive scheduling? In non-preemptive scheduling, once a process has been allocated the CPU, the process keeps the CPU until it releases the CPU either by terminating or by switching to the waiting state. In preemptive scheduling, CPU is switched from an active process to a process in the ready queue as a result of an interrupt or end of time quantum. Maximum : 100 marks

4. What are the four necessary conditions that are needed for deadlock can occur? A process will be deadlock if all the four condition hold simultaneously in a system 1) 2) 3) 4) Mutual Exclusion. Hold And Wait. No pre-emption. Circular Wait.

5. Consider a logical address space of eight pages of 1024 words each,mapped onto a physical memory of 32 frames. How many bits are there in the logical address and in the physical address? Answer: a. Logical address: 13 bits

b. Physical address: 15 bits 6. What is the advantage of demand paging? Advantages of demand paging Only loads pages that are demanded by the executing process. As there is more space in main memory, more processes can be loaded reducing context switching time which utilizes large amounts of resources. Less loading latency occurs at program startup, as less information is accessed from secondary storage and less information is brought into main memory. Does not need extra hardware support than what paging needs, since protection fault can be used to get page fault. 7. What are the i. A tree-structured directory that allows a user to create subdirectories to organize his files; ii. A general graph structure that allows complete flexibility in the sharing of files and directories, but sometimes requires garbage collection to recover unused disk space. 8.What is garbage collection? Garbage collection is determining what le space is available, and making it available for users. It is the systematic recovery of pooled computer storage that is being used by a program when that program no longer needs the storage. This frees the storage for use by other programs (or processes within a program). It also ensures that a program using increasing amounts of pooled storage does not reach its quota (in which case it may no longer be able to function). 9. What is seek time? It is the time for the disk arm to move the heads to the cylinder containing the desired sector.

10. What characteristics determine the disk access speed? The factors that determine the disk access speed are Seek Time , Latency (rotational delay) and Disk bandwidth

Part B 11. (a) (i) Define the e4ssential properties of the following types of operating systems: (1)Batch (2)Time sharing (3)Real time (4)Distributed (8)

Answer : Refer page 1.3 to 1.10 of this book.

(ii) List five services provided by an operating system. Explain how each provides convenience to the users. Explain also in which cases it would be impossible for user-level programs to provide these services. (8) Answer: 1. Program execution - the operating system will schedule on behalf of the user. This service could not be handled by the user because you need access to the hardware. 2. I/O operations - This makes it easy for user's to access I/O streams. this means the user does not need to know the physical access of data in the machine. If there were not interface provided the user could not do this on their own. 3. File-system manipulation - This means the user does not need to worry about accessing and updating the file system table. Such access is best handled by the operating system because of this complexity. 4. Communications - in the case of memory mapping this is extremely beneficial for the OS to handle access and control to memory regions. The user could not in this case access such a system to share the map. 5.Error detection - If there is some error on one of the lower levels the user is notified so that they can take action. if there is no memory left on the heap for instance. The user could not do this because it is simply too much work for the user.

OR

(b) (i) What two advantages do threads have over multiple processes? What major disadvantages do they have? Suggest one application that would benefit from the use of threads. (8) Provide two advantages of threads over multiple processes. 1. Lower overhead of context switch. 2. Easier to share data. Disadvantages of threads over multiple processes. 1. The crash of a process may not affect other processes, since they have separate address spaces. The crash of a thread often crashes other threads in the same address space. 2. Processes can have different privileges whereas threads in the same address spaced 3

share the same privilege. Suggest an application that would benefit from the use of threads. A parallel application such as a parallelized matrix-multiply running on a shared memory multiprocessor. (ii) Explain the various issues associated with the thread in detail. (8) Refer page 1.54 of this book.

12. (a) (i) What is a Gantt chart? Explain how it is used? A Gantt chart is the graphical representation of the order of execution of processes. It is in the form of a rectangle divided into portions. Each portion indicates the time units allocated to a process. Generally, a Gantt chart is used to determine the average waiting time and turnaround time for individual processes.

(ii) Consider the following set of processes, with the length of the CPU-burst time given in milliseconds: Process P1 P2 P3 P4 P5 Burst Time 10 1 2 1 5 Priority 3 1 3 4 2

The processes are assumed to have arrived in the order P1, P2, P3, P4, P5, all at time 0. (1). Draw four Gantt charts illustrating the execution of these processes using FCFS, SJF, a nonpreemptive priority (a smaller priority number implies a higher priority), and RR (quantum = 1) scheduling. (2). What is the turnaround time of each process for each of the scheduling algorithms in part a? (3). What is the waiting time of each process for each of the scheduling algorithms in part 4

a? (4). Which of the schedules in part a results in the minimal average waiting time (over all processes)?

Answer: (1).The four Gantt charts are

(2). Turnaround time

(3). Waiting time (Turnaround time Burst time )

(4). Shortest Job First results in the minimal average waiting time ( 3.2 ms). OR b.(i) What is the meaning of the term busy waiting? What other kinds of waiting are there in an operating system? Can busy waiting be avoided altogether? Explain your answer. Answer: Busy waiting is waiting without giving up the CPU. A preferred type of waiting is to wait on a non-running queue. A process is waiting for an event to occur and it does so by executing instructions. A process is waiting for an event to occur in some waiting queue (e.g., I/O, semaphore) and it does so without having the CPU assigned to it. It might be possible to avoid busy waiting by changing the critical section code so that it blocks processes.

(ii) Consider the following snapshot of a system: Allocation Max Available

ABCD ABCD ABCD P0 P1 P2 P3 P4 0012 0012 1520 1000 1750 1354 2356 0632 0652 0014 0656

Answer the following questions using the bankers algorithm: a. What is the content of the matrix Need? b. Is the system in a safe state?

c. If a request from process P1 arrives for (0,4,2,0), can the request be granted immediately?

Solution (a) What is the content of the matrix Need? Content of the need matrix Process P0 P1 P2 P3 P4 A 0 0 1 0 0 B 0 7 0 0 6 C 0 5 0 2 4 D 0 0 2 0 2

b) Safe sequence i) In the given example, need of process Po is (0,0,0,0) and available is (1,5,2,0), so Need 5 Available True. P0 completes its operation. New available = (1, 5, 3, 2). ii) Need for process is (0, 7, 5, 0) is greater than available, so system move towards next process. P2 process need is (1, 0, 0, 2) and available is (1, 5, 3, 2). So need is less than available. Process P2 comples its operation and new available is (2,8,8,6). iii) P3 process need is (0, 6, 3, 2) and available is (2, 8, 8, 6). Again need is less than available. Allocation of process P3 is released all the resources and new available is (2, 14, 11, 8). Process P4 need is (0, 0, I, 4) and available with system is (2, 14, 11, 8). Need is less than available. P4 completes its operation and new available is (2,14,12,12). vi)Again the system take the process P1 for consideration. Need of P1 is (0,7,5,0) and available is (2, 14, 12, 12). So process P1 complete its operation and release all the resource. New available is (3, 14, 12, 12). Therefore the Safe state is (P , P2 , P3 , P4 , ). c) Assume that, request of PI is granted. Then new need is P0 P1 P2 P3 0 0-0=0 1 0 0 7-4,3 0 0 0 5-2=3 0 2 0 0-0=0 2 0

P4

Available A 1 B 1 C 0 D 0

Again calculate safe sequence i) Need of P0 (0, 0, 0, 0) Available (1, 1, 0, 0) Need < Available New available = (1, 1, 0, 0) + (0, 0, I, 2) = (1, 1, 1, 2) ii) Need of P1 (0, 3, 3, 0) Available (1, 1, 1, 2) Need > Available move to next process. iii)Need of P2 (1, 0, 0, 2) available (1, 1, 1, 2) Need < Available New available = (1, 1, 1, 2) + (1, 3, 5, 4) = (2, 4, 6, 6) iv)Need of P3 (0, 0, 2, 0) Available (2, 4, 6, 6) Need < Available New available = (2, 4, 6, 6) + (0, 6, 3, 2) = (2, 10, 9, 8) v)Need of P4 (0, 0, 1, 4) Available (2, 10, 9, 8) Need < Available New available = (2, 10, 9, 8) + (0, 0, 1, 4) = (2, 10, 10, 12) vi)Again for process P1 P1 process need (0, 3, 3, 0) Available (2, 10, 10, 12) Need < Available New available = (2, 10, 10, 12) + (1, 14, 2, 0) Available = (3, 14, 12, 12) This leaves the system in safe state hence the request can be granted. 13. (a) (i) Why are segmentation and paging sometimes combined into one scheme? (4) Answer : Segmentation and paging are often combined in order to improve upon eachother. Segmented paging is helpful when the page table becomes very large. A large contiguous section of the page table that is unused can be collapsed into a single segment table entry with a pagetable address of zero. Paged segmentation handles the case of having very long segments that require a lot of time for allocation. By paging the segments, we reduce wasted memory due to external fragmentation as well as simplify the allocation. (ii) Consider the following page reference string: 1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6. How many page faults would occur for the following replacement algorithms, assuming one, two, three, four, five, six, or seven frames? Remember all frames are initially empty, so your first unique pages will all cost one fault each. _ LRU replacement _ FIFO replacement

_ Optimal replacement Answer:

Number of frames 1 2 3 4 5 6 7

LRU 20 18 15 10 8 7 7

FIFO 20 18 16 14 10 10 7

Optimal 20 15 11 8 7 7 7

10

OR

(b) (i) Consider the following segment table Segment 0 1 2 3 4 Base 219 2300 90 1327 1952 Length 600 14 100 580 96

What are the physical addresses for the following logical addresses? (1) 0, 430 (2) 1, 10 (3) 2,500 (4) 3,400

Solution: Find the physical address of the following logical address (1) 0,430 Segment 0, offset 430 Phy add=Base address + offset seg 0 Base address=219 219 + 430 = 649 (2) 1,10

11

Segment 1, offset 10 phy add =2300 +10 =2310 (3) 2,500 Phy add= 90+500 =590 -> Trap to OS Addressing error (4) 3,400 Phy add=1327+400 =1727 (ii) Discuss briefly about memory management in LINUX. Refer page number 3.37 of this book.

14. (a) (i) Explain the various attributes of a file. (4)

Refer page number 4.1 of this book.

(ii) Consider a file currently consisting of 100 blocks. Assume that the file control block (and the index block, in the case of indexed allocation) is already in memory. Calculate how many disk I/O operations are required for contiguous, linked, and indexed (single-level) allocation strategies, if, for one block, the following conditions hold. In the contiguous allocation case, assume that there is no room to grow in the beginning, but there is room to grow in the end. Assume that the block information to be added is stored in memory. a. The block is added at the beginning. b. The block is added in the middle. c. The block is added at the end. d. The block is removed from the beginning. e. The block is removed from the middle. f. The block is removed from the end.

12

Answer: a. b. c. d. e. f. Contiguous 201 101 1 198 98 0 OR Linked 1 52 3 1 52 100 Indexed 1 1 1 0 0 0

(b) (i) Explain the various schemes used for defining the logical structure of a directory. (8) Refer page number 4.17 of this book. (ii) Describe the approaches used in free space management. (8) Refer page number 4.25 of this book.

15. (a) (i) Consider the following I/O scenarios on a single-user PC. (1) A mouse used with a graphical user interface (2) A tape drive on a multi tasking operating system (assume no device preallocation is available) (3) A disk drive containing user files (4) A graphics card with direct bus connection, accessible through momory-mapped I/O For each of these I/O scenarios, would you design the operating system to use buffering, spooling, caching, or a combination? Would you use polled I/O, or interruptdriven I/O? Give reasons for your choices. (8) Answer: 1. A mouse used with a graphical user interface . Buffering may be needed to record mouse movement during times when higher priority operations are taking place. Spooling and caching are inappropriate. Interrupt driven I/O is most appropriate. 2. A tape drive on a multitasking operating system (assume no device pre allocation is available) Buffering may be needed to manage throughput difference between the tape drive and the source or destination of the I/O, Caching can be used to hold copies of data that resides on the tape, for faster access. Spooling could be used to stage data to the device when multiple users desire to read from or write to it. Interrupt driven I/O is likely to allow the best performance. 3. A disk drive containing user les. Buffering can be used to hold data while in transit from user space to the disk, and vice versa. Caching can be used to hold disk-resident data for improved performance. Spooling is not necessary because disks are shared-access devices. Interrupt driven I/O is best for devices such as disks that transfer data at slow rates. 4. A graphics card with direct bus connection, accessible through memory-mapped I/O

13

Buffering may be needed to control multiple access and for performance (double buffering can be used to hold the next screen image while displaying the current one). Caching and spooling are not necessary due to the fast and shared-access natures of the device. Polling and interrupts are only useful for input and for I/O completion detection, neither of which is needed for a memory-mapped device. (ii) How do you choose a optimal technique among the various disk scheduling techniques? Explain. (8) Refer page number 5.29 of this book. OR (b) (i) Describe the various disk scheduling techniques. (8) Refer page number 5.24 of this book. (ii) Describe the various levels of RAID. (8) Refer page number 5.35 of this book.

14

S-ar putea să vă placă și