Вы находитесь на странице: 1из 4

Question 1 (General) (a) Explain the important design issues associated with cache management.

Ans: When a system writes a datum to cache, it must at some point write that datum to backing store as well. The timing of this write is controlled by what is known as the write policy. There are two basic writing approaches: Write-through - Write is done synchronously both to the cache and to the backing store. Write-back (or Write-behind) - Initially, writing is done only to the cache. The write to the backing store is postponed until the cache blocks containing the data are about to be modified/replaced by new content. (b) We have discussed two common models for inter-process communication the message passing model and the shared-memory model. What are the strength and weakness of the two approaches? Ans: Message passing is useful for exchanging smaller amounts of data, because no conflicts need be avoided. It is also easier to implement than is shared memory for inter computer communication. Shared memory allows maximum speed and convenience of communication, since it can be done at memory speeds when it takes place within a computer. Problems exist, however, in the areas of protection and synchronization between the processes sharing memory. (c) Why does an operating systems needs to provide system calls? Ans: There are certain tasks that can only be done if a process is running in kernel mode which is made possible by system calls. (d) In what way is the modular kernel approach the same as the layered kernel approach? Ans: Similarity of modular kernel approach to the layered approach In layered approach the operating system are divided in to number of layers. Here it is divided in lo system-and-user-level-programs. In modular kernel provide the communication between the client program and the various services that are also running in user space. Differences It provides the services for message passing and process scheduling. It also handles low-level network communication and hardware interrupts. The modular kernel approach coordinates the message passing between client application and application servers Question 2 (Process and threads) (a) What is a process? Describe all of the components that constitute a process. Ans: A process can be thought of as a program in execution, A process will need certain resources such as CPU time, memory, files, and I/O devicesto accomplish its task. A process is more than the program code, which is sometimes known as the text section. It also includes the current activity, as represented by the value of the program counter and the contents of the processor's registers. A process generally also includes the process stack, and a data section, which contains global variables. A process may also include a heap. (b) The Nachos Thread contains the Yield() and the Sleep() methods. Explain each method, and discuss their differences and similarities. Ans: Sleep() causes the currently executing thread to sleep (temporarily cease execution).

Yield() causes the currently executing thread object to temporarily pause and allow other threads to execute Both the function leads the thread to waiting state. (c) Nachos threads can be used to run procedures within the kernel. Explain how a procedure is attached to a thread and the thread is initialized so that context switching can occur. Ans: Nachos thread does a context switch it must save two sets of registers. This can be seen in the code for Scheduler::Run(), seen below. This function is usually called when the current threads quantum has expired, and a new thread needs to be switched in (d) Explain why it is faster to create or context switch a thread compared to a process. Ans: In process switch lots of work is to be done like storing the state of old process in its PCB and loading the saved state of new process which takes time and thus is complete overhead to CPU. Where in case of threads extensive sharing makes thread inexpensive. We just have to store register set information of thread no memory -management related work is to be done. Question 3 (Synchronization) (a) Two implementations of semaphores have been discussed a busy-wait implementation and a waiting queue implementation. Explain both implementation and discuss the advantages and disadvantages of both implementations. Ans: In busy waiting, when a process calls acquire(), it will continuously check the lock to see when it becomes available again. While this is simple to implement, it can be inefficient because the process is using CPU time to constantly check a lock which another process has control of. In wait queues, when a process calls acquire(), the OS places it on a wait queue. These processes will not be scheduled by the OS until the process currently using the lock calls release(). This is a more efficient approach, but the lock implementation needs to be very careful about how disabling and enabling interrupts is controlled as processes are put to sleep on the wait queue. (b) What is mutual exclusion? How is mutual exclusion ensured using a semaphore? Ans: Mutual Exclusion: A way of making sure that if one process is using a shared modifiable data, the other processes will be excluded from doing the same thing. The P (or wait or sleep or down) operation on semaphores S, written as P(S) or wait (S), operates as follows: P(S): IF S > 0 THEN S := S - 1 ELSE (wait on S) The V (or signal or wakeup or up) operation on semaphore S, written as V(S) or signal (S), operates as follows: V(S): IF (one or more process are waiting on S) THEN (let one of these processes proceed) ELSE S := S +1 It is guaranteed that once a semaphore operation has stared, no other process can access the semaphore until operation has completed. Mutual exclusion on the semaphore, S, is enforced within P(S) and V(S). If several processes attempt a P(S) simultaneously, only process will be allowed to proceed. (c) What is a race condition? Give an example of a race condition.

Ans: A situation like this, where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular order in which the access takes place, is called a race condition. Manipulating a variable counter concurrently by two process concurrently results in race condition. (d) What is a deadlock? Give an example of how a deadlock can occur. Ans: In an operating system, a deadlock is a situation which occurs when a process enters a waiting state because a resource requested by it is being held by another waiting process, which in turn is waiting for another resource. If a process is unable to change its state indefinitely because the resources requested by it are being used by another waiting process, then the system is said to be in a deadlock Suppose a computer has three CD drives and three processes. Each of the three processes holds one of the drives. If each process now requests another drive, the three processes will be in a deadlock. Each process will be waiting for the "CD drive released" event, which can be only caused by one of the other waiting processes. Thus, it results in a circular chain. Question 4 (Memory) (a) The Intel Pentium processors supports two page sizes 4KB and 4MB.What are the advantages of having two page size. Ans: The aim of this two-level scheme is to reduce the amount of RAM required for per-process Page Tables. The two-level scheme reduces the memory by requiring Page Tables only for those virtual memory regions actually used by a process. When page size are of be 4 MB instead of 4 KB in size). Extended paging is used to translate large contiguous linear address ranges into corresponding physical ones; in these cases, the kernel can do without intermediate Page Tables and thus save memory and preserve TLB entries. (b) On general purpose operating system why do programs use a logical address space and not the physical address space? Ans: Logical address is the address generated by the CPU. Whereas physical address is the actual address of the process in the memory. Logical address space ensure better portability of programs as difference machine may not have same physical address space but they can have same logical address space. (c) What is a page fault? Describes the actions taken by the operating system when a page fault occurs. Ans: A page fault occurs when an access to a page that has not been brought into main memory takes place. The operating system verifies the memory access, aborting the program if it is invalid. If it is valid, a free frame is located and I/O is requested to read the needed page into the free frame. Upon completion of I/O, the process table and page table are updated and the instruction is restarted. (d) What is the locality model of program execution. How is it used to avoid thrashing? Ans: The locality model states that, as a process executes, it moves from locality to locality. A locality is a set of pages that are actively used together. A program is generally composed of several different localities, which may overlap. To avoid thrashing processes must be given as many frames as they need. We can use the locality of reference principle to help determine how many frames a process needs: Question 5 (File Systems)

(a) What is the purpose and result of executing the open() and close () system routines? Ans: Open creates memory buffers, creates data control blocks, and creates other data structures needed for the I/O. If file is new, it also allocates space, and enters name in directory. Close outputs last buffer of information. Deletes buffers, data control blocks, and other data structures. (b) Name two(2) on disk data structure that can be found in a file system. And briefly describe what they are used for. Ans: The simplest method of implementing a directory is to use a linear list of file names with pointers to the data blocks. This method is simple to program but time-consuming to execute. Another data structure used for a file directory is a hash table. With this method, a linear list stores the directory entries, but a hash data structure is also used. The hash table takes a value computed from the file name and returns a pointer to the file name in the linear list. (c) There are three main methods to allocate storage for file: contiguous allocation, linked allocation and indexed allocation. List the advantage and disadvantage of each method. Ans: Advantages: a. Contiguous allocation: Fastest, if no changes are to be made. Also easiest for random access files. b. Linked allocation: No external fragmentation. File can grow without complications. c. Indexed allocation: Supports direct access without external fragmentation. Disadvantages: a. Contiguous: The disadvantage of contiguous allocation is that it is often difficult to find free space for a new file. b. Linked allocation: The major problem is that it is inefficient to support direct-access; it is effective only for sequential-access files. To find the ith block of a file, it must start at the beginning of that file and follow the pointers until the ith block is reached. c. Indexed allocation: Large overhead is required for metadata. (d) What is the difference between hard links ad soft links in Unix. Unix will not allow the creation of hard link to a directory. Why is this? Ans: Hard Links 1. Hard Links have same inodes number. 2. Links have actual file contents 3. You cannot create a hard link for a directory. Soft Links 1. Soft Links have different inodes numbers. 2. Soft Link contains the path for original file and not the contents. 3. A soft link can link to a directory. Hard links are not permitted because they would lead to cycles. Once you allow cycles to form, you must perform a mark-and-sweep garbage collection to detect when isolated cycles of directories (no longer reachable from the root) can be finally deleted - this is extremely expensive on disk.

Вам также может понравиться