Vous êtes sur la page 1sur 5

1. What is kernel? What are the main components of a kernel?

[ 5 +5 marks]
Answer: The kernel is a computer program that manages input/output requests from software and

translates them into data processing instructions for thecentral processing unit and other electronic components of a computer. The kernel is a fundamental part of a modern computer's operating system.[1] When a computer program (in this case called a process) makes requests of the kernel, the request is called a system call. Various kernel designs differ in how they manage system calls (time-sharing) and resources. For example, a monolithic kernel executes all the operating system instructions in the same address space to improve the performance of the system. A microkernel runs most of the operating system's background process in user space,[2] to make the operating system more modular and, therefore, easier to maintain.

Process management: This area is responsible for creating and terminating


processes and other activities of the kernel (software interrupts, tasklets, etc.). In addition, this is the area where interprocess communication (signals, pipes, etc.) takes place. The scheduler is the main component of process management. It handles all active, waiting, and blocked processes and takes care that all application processes obtain their fair share of the processor's computing time. Memory management: The memory of a computer is one of the most important resources. A computer's performance strongly depends on the main memory it is equipped with. In addition, memory management is responsible for allowing each process its own memory section, which has to be protected against access by other processes.

File systems: In UNIX, the file system assumes a central role. In contrast to other
operating systems (e.g., Windows NT), almost everything is handled over the filesystem interface. For example, device drivers can be addressed as files, and the Proc file system (see Section 2.8) allows you to access data and parameters within the kernel. These two functionalities can be used very effectively and elegantly, so that they are often used for debugging purposes. (See Appendix B.)

Device drivers: Device drivers abstract from the underlying hardware in every
operating system, and they allow you to access this hardware. The modular concept of Linux we will introduce in Section 2.4 offers a way to add or remove device drivers during a running operation, despite its monolithic kernel.

Network: All network operations have to be managed by the operating system,


because certain network operations cannot be allocated to a specific process, such as handling an incoming packet. Incoming packets are asynchronous events. They have to be collected, identified, and forwarded before a process can handle them. This is the reason why the kernel is responsible for the handling of packets across program and network interfaces.

2. What is mutual exclusion? What are its requirements? [ 5 +5 marks] Mutual Exclusion: Mutual exclusion is 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. That is, while one process executes the shared variable, all other processes desiring to do so at the same time moment should be kept waiting; when that process has finished using the shared variable, one of the processes waiting to do so should be allowed to proceed. In this fashion, each process using the shared data (variables) excludes all others from doing so simultaneously. This is called Mutual Exclusion. Mutual exclusion needs to be enforced only when processes access shared modifiable data - when processes are performing operations that do not conflict with one another they should be allowed to proceed concurrently. Requirements for mutual exclusion: Following are the six requirements for mutual exclusion. 1. Mutual exclusion must be enforced: Only one process at a time is allowed into its critical section, among all processes that have critical sections for the same resource or shared object. 2. A process that halts in its non critical section must do so without interfering with other processes. 3. It must not be possible for a process requiring access to a critical section to be delayed indefinitely. 4. When no process is in a critical section, any process that requests entry to its critical section must be permitted to enter without delay. 5. No assumptions are made about relative process speed or number of processors. 6. A process remains inside its critical section for a finite time only.

3. What are the two types of fragmentations? Illustrate them with block diagrams. [ 5 +5 marks]

External Fragmentation: External Fragmentation happens when a dynamic memory allocation algorithm allocates some memory and a small piece is left over that cannot be effectively used. If too much external fragmentation occurs, the amount of usable memory is drastically reduced. Total memory space exists to satisfy a request, but it is not contiguous.

Internal Fragmentation: Internal fragmentation is the space wasted inside of allocated memory blocks because of restriction on the allowed sizes of allocated blocks. Allocated memory may be slightly larger than requested memory; this size difference is memory internal to a partition, but not being used

4. List out the conditions that result in Deadlock situations. Illustrate deadlock situation with a simple graphical notation. [5 +5 marks]

Answer: In order for deadlock occur, four conditions must be true: Mutual exclusion Each resource is neither currently allocated to exactly one process or it is available. (Two processes canno9t simultaneously control the same resource or be in their critical section). Hold and Wait processes currently holding resources can request new resources.

No Preemption Once a process holds a resource, it cannot be taken away by


another process or the kernel.

Circular wait Each process is waiting to obtain a resource which is held by another
process. Each philosopher picks up his or her left fork and waits for the right fork to become available, but it never does. Deadlock can be modeled with a directed graph. In a deadlock graph, vertices represent either processes (circles) or resources (squares). A process which has acquired a resource is show with an arrow (edge) from the resource to the process. A process which has requested a resource which has not yet been assigned to it is modeled with an arrow from the process to the resource. If these create a cycle, there is deadlock. There are a number of ways that deadlock can occur in an operating situation. We have seen some examples, here are two more: Two processes need to lock two files, the first process locks one file the second process locks the other, and each waits for the other to free up the locked file. Two processes want to write a file to a print spool area of fixed size, and it fills up before either process finishes writing its file, so both wait for more space to become available.

5. Explain what is file structure? Explain the various access modes. [ 5 +5 marks] Answer: File Structure: Unix hides the "chunkiness" of tracks, sectors, etc. and presents each file as a "smooth" array of bytes with no internal structure. Application programs can, if they wish, use the bytes in the file to represent structures. For example, a wide-spread convention in Unix is to use the newline character (the character with bit pattern 00001010) to break text files into lines. Some other systems provide a variety of other types of files. The most common are files that consist of an array of fixed or variable size recordsand files that form an index mapping keys to values. Indexed files are usually implemented as B-trees.

Access Modes: Systems support various access modes for operations on a file.: Sequential. Read or write the next record or next n bytes of the file. Usually, sequential access also allows a rewind operation. Random. Read or write the nth record or bytes i through j. Unix provides an equivalent facility by adding a seek operation to the sequential operations listed above. This packaging of operations allows random access but encourages sequential access.

Indexed. Read or write the record with a given key. In some cases, the "key" need
not be unique there can be more than one record with the same key. In this case, programs use a combination of indexed and sequential operations: Get the first record with a given key, then get other records with the same key by doing sequential reads.

Note that access modes are distinct from from file structure e.g., a recordstructured file can be accessed either sequentially or randomly but the two concepts are not entirely unrelated. For example, indexed access mode only makes sense for indexed files.

6. With an example illustrate file access modes: Sequential, Indexed and Random modes. [ 3 +3+4 marks]

Answer: ACCESS MODES:System supports various access modes for operations on a file. Sequential: Read or write the next record or next n bytes of the file. Usually, sequential access also allows a rewind operation. Random: Read or write the nth record or bytes I through j. UNIX provides an equivalent facility by adding a seek operation to the sequential operations listed above. This packaging of operations allows random access but encourages sequential access. Indexed: Read or write the record with a given key. In some cases, the key need not be unique- there can be more than one record with the same key. In this case, programs use a combination of indexed and sequential operations: Get the first record with a given key, and then get other records with the same key by doing sequential reads.Note that access modes are distinct from file structure e.g., a record structured file can be accessed either sequentially or randomly-but the two concepts are not entirely unrelated. For example, indexed access mode only makes sense for indexed files.

Vous aimerez peut-être aussi