Sie sind auf Seite 1von 9

Summer 2012 Master of Computer Application (MCA) Semester 2 MC0070 Operating Systems with Unix 4 Credits (Book ID:

ID: B0682 & B0683) Assignment Set 1 (60 Marks) Answer all Questions Book ID: B0682 1. Discuss the following with respect to Operating Systems: o Operating System Components o Operating System Services Ans. Operating System Components Even though, not all system have the same structure many modern operating system hare the same goal of supporting the following types of system components. Process Management The operating system manages many kinds of activities ranging from user programs to system programs like printer spooler, name servers, file server etc. Each of these activities is encapsulated in a process. A process includes the complete execution context (code, data, PC, registers, OS resource in use etc.). It is important to note that a process is not a program. A process is only ONE instant of a program in execution. There are many processes can be running the same program. The five major activities of an operating system in regard to process management are: 1. Creation and deletion of uer and system proceses. 2. Suspension an resumption of proceses. 3. A mechanism for process synchronization. 4. A mechanism for process communication. 5. A mechanism for deadlock handling. Main-Memory Management Primary-memory and main-memory is a large array of word or bytes. Each word or byte has its own address. Main-memory provides storage that can be access directly by the CPU. That is to say for a program to be executed, it must in the main memory. The major activities of an operating in regard to memory-management are: 1. Keep track of which part of memory are currently being used and by whom. 2. Decide which processes re loaded into memory when memory space becomes available. 3. Allocate and de-allocate memory space as needed. Memory Management A file is a collection of related information defined by its creator. Computer can store file on the disk (secondary storage), which provides long term storage. Some examples of storage media are magnetic tape, magnetic disk and optical disk. Each of these media has its own properties like speed, capacity, data transfer rate and access methods. A file system normally organized into directories to ease their use. Tee directories may contain files and other directions. The five main major activities of an operating system in regard to file management are: 1. The creation and deletion of files. 2. The creation and deletion of directions. 3. The support of primitives for manipulating files and directions.

4. The mapping of files onto secondary storage. 5. The backup of files on stable storage media. I/O System Management I/O subsystem hides the peculiarities of specific hardware devices form the user. Only the device driver knows the peculiarities of the specific device to whom it is assigned. Secondary-Storage Management Generally speaking systems have several levels of storage, including primary storage, secondary storage and cache storage. Instructions and data must be places in primary storage or cache to be reference by a running program. Because main memory is too small to accommodate all data and programs, and its data are lost when power is lost, the computer system must provide secondary storage to back up main memory. Secondary storage consists of tapes, disks and other media designed to hold information that will eventually be accessed in primary storage is ordinarily divided into bytes or word consisting of a fixed number of bytes. Each location in storage has an address; the set of all addresses available to a program is called an address space. The three major activities of an operating system in regard to secondary storage anagement are: 1. Managing the free space available on the secondary-storage device. 2. Allocation of storage space when new files have to be written. 3. Scheduling the requests for memory access.

Operating System Services Following are the five services provided by operating systems for the convenience of the users. Program Execution The purpose of a computer system is to allow the user to execute programs.So the operating system provides an environment where the user can conveniently run programs. The user does not have to worry about the memory allocation or multitasking or anything. These things are taken care of by the operating systems. I/O Operations Each program requires an input and produces output. This involves the use of I/O. The operating systems hides from the user the details of underlying hardware for the I/O. All the users see that the I/O has been performed without any details. So the operating system, by providing I/O, makes it convenient for the users to run programs. For efficiently and protection users cannot control I/O so this service cannot be provided by user-level programs. File System Manipulation The output of a program may need to be written into new files or input taken from some files. The operating system provides this service. The user does not have to worry about secondary storage management. User gives a command for reading or writing to a file and sees his/her task accomplished. Thus operating system makes it easier for user programs to accomplish their task. Communications There are instances where processes need to communicate with each other to exchange information. It may be between processes running on the same computer or running on the different computers. By providing this service the operating system relieves the user

from the worry of passing messages between processes. In case where the messages need to be passed to processes on the other computers through a network, it can be done by the user programs. Error Detection An error in one part of the system may cause malfunctioning of the complete system. To avoid such a situation the operating system constantly monitor the system for detecting the errors. This relieves the user from the worry of errors propagating to various part of the system and causing malfunctioning. This service cannot be allowed to be handled by user programs because it involves monitoring and in cases altering area of memory or de-allocation of memory for a faulty process, or may be relinquishing the CPU of a process that goes into an infinite loop. These tasks are too critical to be handed over to the user programs. A user program if given these privileges can interfere with the correct (normal) operation of the operating systems.

2. Describe the theory behind Paging and Segmentation in Operating Systems. Ans. Paging and Segmentation Both paging and segmentation have their strengths, so they are often combined to benefit from the advantages of both. In a combined paging/segmentation system, a user program is broken into a number of segments, at the discretion of the programmer, which is in turn broken up into a number of fixed-size pages. From the programmers point of view, a logical address still consists of a segment number and a segment offset, as before in pure segmentation, while from the systems point of view the segment offset is viewed as a page number and a page offset for a page within the specified segment.

Figure shows the address translation in the combined scheme. Each process is associated with a segment table and a number of page tables, one for each segment. For a running process, a register holds the starting address of the segment table for the process. Presented with a virtual

address, the processor uses the segment number portion to index into the segment table to find the page table for that segment. Then the page number portion of the virtual address is used to index the page table and look up the corresponding frame number. It is then combined with the offset portion of the virtual address to produce the desired real address. Operating system software The operating system is the other part that is engaged in virtual memory implementation besides the hardware part in the microprocessor for address translation. If we have a look at the popular operating systems over the history, we may find out that except for MS-DOS and specialized systems, all important operating systems provide virtual memory support. And they usually use paging or the combination of paging and segmentation for virtual memory subsystem. The reason why pure segmentation is seldom used is that a segment in a program is still a large unit for memory management,which may lead to large external fragments in main memory. Since paging is always an issue that the operating system designers have to face, this section will focus on the algorithms for paging. Even when segmentation mechanism is used as well, the segment level usually make sense for sharing or protection. The unit of size that is managed by virtual memory is always a page or a frame.

Before we proceed to various algorithms regarding virtual memory, we should first make it clear what the goal of such a kind of algorithm is. The goal is of course to enable the execution of processes whose sizes are larger than the size of physical main memory. However this is a trivial requirement for those algorithms. To distinguish them from each other, we actually need to tell which is better. Thus the key issue here is performance. In detail, we would like to minimize the rate at which page faults occur. A page fault occurs when a referenced page does not exist in main memory and needs to be brought in .

Why could the page fault rate be the key factor measuring the performance? Because without page faults, no access to secondary memory is needed. And page faults cause considerable software overhead, including deciding which page to replace, and the I/O operation for exchanging pages. Since I/O operations are slow, another process may have to be scheduled to run. The context switching also brings overhead more or less. 3. Describe the theory behind Space Management in File systems. Ans. In computer operating systems, paging is one of the memory-management schemes by which a computer can store and retrieve data from secondary storage for use in main memory. In the paging memory-management scheme, the operating system retrieves data from secondary storage in same-size blocks called pages. The main advantage of paging is that it allows the physical address space of a process to be noncontiguous. Before paging, systems had to fit whole programs into storage contiguously, which caused various storage and fragmentation problems. Paging is an important part of virtual memory implementation in most contemporary generalpurpose operating systems, allowing them to use disk storage for data that does not fit into physical random-access memory (RAM). The main functions of paging are performed when a program tries to access pages that are not currently mapped to physical memory (RAM). This situation is known as a page fault. The operating system must then take control and handle the page fault, in a manner invisible to the program. Therefore, the operating system must: 1. 2. 3. 4. 5. Determine the location of the data in auxiliary storage. Obtain an empty page frame in RAM to use as a container for the data. Load the requested data into the available page frame. Update the page table to show the new data. Return control to the program, transparently retrying the instruction that caused the page fault.

Book ID: B0683 4. Discuss the following concepts with reference to Unix Operating System: a. Unix Architecture b. Process Control Mechanisms c. Environment Variables and Shells d. Layers of UNIX Operating System Unix Architecture

Kernel The kernel is the master program that provide file related activities, process scheduling, memory management, and various other operating system functions through system calls. In other words we can say that it control the resources of the computer system, allocate them to different users and to different tasks. The major portion of the kernel is written in C language. Therefore, it is easy to understand, debug, and enhance it. As it is written in C language, therefore, it is portable in nature. As you can see in the diagram that it is written or placed between hardware and utility program (Like shells, editors, vi or sed) so it work between the two. Moreover, the kernel maintains various data structure to manage the processes. Each process has its own priority. A higher priority process is execute first than the lower priority process. Kernel is divided into two parts: 1. Process management 2. File management The primary task of the process management is to manage the memory management activities and process related activities at different states of the execution creation/deletion of processes, scheduling of the processes and provision of mechanism for synchronization, communication and deadlock handling of the processes. Where as the task of the file management is to manage the file related activities. Since Unix is such kind of operating system which treats the I/O devices as a file. Therefore each I/O devices has its own file, known as device drivers, to derive it. The file management pat of the kernel handles these device drivers and store these files in the directory /dev under root directory. If we attach any new I/O device to the Unix than it is necessary to create a file for that device in /dev directory. Then we write down its characteristics; such as its type (character oriented or block oriented), address of the driver program, memory buffer reserved for the device and some other, in that specific file.

Shells In Unix we cannot directly deals with kernels. It is the shell, one of the utility program, that starts up the kernel when the user logs in. the shell sends a prompt symbol. The shell prompt waits for input from users. Now when you type a command and press Enter key, the shell obtained your command, execute it if possible and display the prompt symbol again in order to receive your next command. That is why the shell is also called as the Unix system command interpreter. Moreover, when we want to access the hardware, we will request for the shell, the shell will request to kernel, and finally the kernel will request to hardware. Basically the shell handles the user interaction with the system. Some built in commands are part of shell and the remaining commands are separated programs stored elsewhere . There are three types of shells that are widely used and are exist in the Unix OS: 1. Bourne shell: This shell was designed by Stephan Bourne of Bells Lab. It is most powerful an most widely used shell. The prompt symbol of Bourne shell is $ (Doller) sign. 2. The C Shell: the C shell was developed at University of California. It is designed by Bill Joy. C shell gets its name from its programming language, which resembles the C programming language in syntax. The prompt symbol of C shell is Percent (%) sign. 3. Korn Shell: Like Bourne shell, the Korn shell was also developed at Bells Lab of AT & T. This shell gets its name from its inventor David Korn of Bells Lab. Moreover, the shells provide the meta characters like *, [ ], ? and so on. For better searching of files.

Utility programs The Unix system contains large number of utility and application programs like editors (ed, ex, vi, sed) and so on. These utility programs and the application programs developed in Unix environment are also easily portable to another machine having same environment.

Process Control Mechanism 5. Discuss the concept of File substitution with respect to Managing data files in Unix. Ans. File Substitution Works It is important to understand how file substitution actually works. In the previous examples, the ls command doesnt do the work of file substitution the shell does. Even though all the previous examples employ the ls command, any command that accepts filenames on the

command line can use file substitution. In fact, using the simple echo command is a good way to experiment with file substitution without having to worry about unexpected results. For example, $ echo p* p10 p101 p11 When a metacharacter is encountered in a UNIX command, the shell looks for patterns in filenames that match the metacharacter. When a match is found, the shell substitutes the actual filename in place of the string containing the metacharacter so that the command sees only a list of valid filenames. If the shell finds no filenames that match the pattern, it passes an empty string to the command. The shell can expand more than one pattern on a single line. Therefore, the shell interprets the command $ ls LINES.* PAGES.* as $ ls LINES.dat LINES.idx PAGES.dat PAGES.idx There are file substitution situations that you should be wary of. You should be careful about the use of whitespace (extra blanks) in a command line. If you enter the following command, for example, the results might surprise you: What has happened is that the shell interpreted the first parameter as the filename LINES. with no metacharacters and passed it directly on to ls. Next, the shell saw the single asterisk (*), and matched it to any character string, which matches every file in the directory. This is not a big problem if you are simply listing the files, but it could mean disaster if you were using the command to delete data files! Unusual results can also occur if you use the period (.) in a shell command. Suppose that you are using the $ ls .* Command to view the hidden files. What the shell would see after it finishes interpreting the meta character is $ ls . .. .profile which gives you a complete directory listing of both the current and parent directories. When you think about how filename substitution works, you might assume that the default form of the ls command is actually $ ls * However, in this case the shell passes to ls the names of directories, which causes ls to list all the files in the subdirectories. The actual form of the default ls command is $ ls .

6. Discuss the following: o File Substitution o I/O Control Ans. File Substitution

Das könnte Ihnen auch gefallen