Important Announcement
PubHTML5 Scheduled Server Maintenance on (GMT) Sunday, June 26th, 2:00 am - 8:00 am.
PubHTML5 site will be inoperative during the times indicated!

Home Explore CU-BCA-SEM-III-System software and operating system-Second draft

CU-BCA-SEM-III-System software and operating system-Second draft

Published by Teamlease Edtech Ltd (Amita Chitroda), 2021-04-14 13:23:01

Description: CU-BCA-SEM-III-System software and operating system-Second draft

Search

Read the Text Version

2. Utilization of Multiple Processor Architecture: The different threads can run parallel on the multiple processors hence; this enables the utilization of the processor to a large extent and efficiency. 3. Reduced Context Switching Time: The threads minimize the context switching time as in Thread Context Switching, the virtual memory space remains the same. 4. Economical: The allocation of memory and resources during process creation comes with a cost. As the threads can distribute resources of the process it is more economical to create context-switch threads. 3.8 REAL TIME OPERATING SYSTEM SUMMARY Real time operating system is totally depending upon the clock interrupts. This system produces the Interrupt Service Routine (ISR) interrupts. RTOS implemented the Priority system for executing all types of process. Entire RTOS is synchronized with the process, and they can make communication in between all process. Figure 3.7: Real time operating system Types of Real Time Operating System (RTOS) Soft Real Time Soft Real Time O/S allows few delays with using this operating system, but in this SRT (Soft Real Time) O/S defines the deadline to particular jobs. In this system, do not allow delay in 51 CU IDOL SELF LEARNING MATERIAL (SLM)

large amount of time, so due to that mechanism their deadlines are managed by the Soft Real Time O/S. Examples are: Cameras, smart phones, data management, online transaction, online bid in stock exchange etc. Firm Real Time In Firm Real Time O/S accepts the more deadline rules. so, occurrences of the missing deadlines are not getting more impact but could be show some unpredictable outputs, and due to that can be reduced the quality of all products. Some examples are: Automation system in the industry sector like as visual inspection, Multimedia products. Hard Real Time In the Hard Real Time, all feeding tasks must be begun to execute on predefined scheduling time, and their given all tasks must be done within allotted time duration. So due to that in this RTOS, all deadlines are managed with strictly. Examples: Automobile control system like as Antilock & Air Bag, Airline Control System. Components of Real Time Operating System (RTOS)  Scheduler  Synchronization mechanism  Memory Management  Function Library  Interrupt Service Mechanism  I/O Management  Fast dispatch latency  User-defined data objects and classes  Hardware abstraction layer  Development Environment 52 CU IDOL SELF LEARNING MATERIAL (SLM)

Advantages of Real Time Operating System  RTOS produces the more accurate result while getting maximum consumption of the all using resources, so it does not contain the down time.  RTOS contains very low time frame for shifting all task in own system.  In this type of RTOS, mainly focus on their currently running part instead of waiting stages. Due to this mechanism, they produce the exact output on the behalf of their execution task.  RTOS is error free operating system.  RTOS can be used in the embedded system equipment because it is small size in nature.  RTOS is a more optimize operating system so this O/S can use in such product which are online all time like as refrigerator etc.  RTOS has more systematically memory allocation for every parts of the operating system. Disadvantages of Real time Operating System  Real Time OS can execute only limited task at same time frame.  Real Time OS consumes huge resources of the system, and due to this it become more expensive.  It has not capable for performing the multi-tasking and multi-threading for long time, so it can execute only fewer tasks.  It has poor thread priority.  Hire most experienced designer for writing their algorithms because RTOS’s algorithms are very complicated.  Require specific device drivers and interrupts signals for giving request rapidly to interrupts. Examples  Internet Technology  Medical Sector 53 CU IDOL SELF LEARNING MATERIAL (SLM)

 Automobile Sector such as Anti-Lock Brake and Air Bag  Traffic Control System  Complex Multimedia System  For military as a Defence system such as RADAR 3.9 EMBEDDED OPERATING SYSTEM Embedded Operating System refers as a combination of software and hardware. Embedded Operating system is written with programming code, and it helps to convert hardware language into software language like as C, C++, and finally it produces the result that easily can be understandable by human being in the different formats like as pictures, text, and voice. Embedded operating system helps to improve entire efficiency for controlling all hardware resources as well as decreasing the response times for specific task devices were made for. Figure 3.8: Embedded operating system Applications of Embedded Operating Systems Embedded operating systems are used in several applications. Here, few embedded OS which are used in mobile; like as-  Symbian: Used in Nokia mobile. 54 CU IDOL SELF LEARNING MATERIAL (SLM)

 BlackBerry Operating System: Used only for BlackBerry Phones  Embedded Linux: Used in Android mobile and other devices like printers  IOS: Used in Apple devices.  Windows Mobile Operating System: Used in only Windows mobiles. Advantages of Distributed Operating System  It can share all resources such as (CPU, disk, network interface, nodes, computers, and more) from one site to another site, and it increases the data availability on entire system.  It enhances the speed of data exchange from one site to another site.  It reduces the probability of data corruption because all data are replicated on all site, if any site gets fail then user can access data from other running site.  It is openness system because this system can be accessed from local and remote sites.  Entire system works independently from each other and due to this feature if any one site gets crash, then entire system does not halt.  Well protective system because in distributed operating system, every user has unique UID and with using this UID all users can use every system. Due to UID, no chance hack data from this system. Disadvantages of Distributed Operating System  If centre hub gets fails then entire network will halt.  Distributed operating system is designed with such language, which is not well defined till now.  This system is more costly because it is not easily readable, and it contains the huge infrastructure.  Sometime security issues can be arising while sharing data on entire networks.  Some data packet can be corrupted due to following in the large networks.  Its maintenance is more costly because it is distributed across multiple servers. 55 CU IDOL SELF LEARNING MATERIAL (SLM)

3.10 DISTRIBUTED OPERATING SYSTEM Distributed operating system allows distributing of entire systems on the couples of center processors, and it serves on the multiple real time products as well as multiple users. All processors are connected by valid communication medium such as high-speed buses and telephone lines, and in which every processor contains own local memory along with other local processor. According this nature, distributed operating system is known as loosely coupled systems. Figure 3.9: Distributed operating system This operating system involves multiple computers, nodes, and sites, and these components are linked each other with LAN/WAN lines. Distributed OS is capable for sharing their computational capacity and I/O files with allowing the virtual machine abstraction to users. Types of Distributed Operating System  Client-Server Systems  Peer-to-Peer Systems  Middleware Applications of Distributed Operating System  Telecommunication networks  Internet Technology  Peep-to-peer networks system 56 CU IDOL SELF LEARNING MATERIAL (SLM)

 Airline reservation Control systems  Distributed databases System  Distributed Object Based System 3.11 CLUSTERED SYSTEM OPERATING SYSTEM Cluster systems like as parallel systems because both systems use multiple CPUs. But main difference is that clustered systems are made by two or more individual systems but they are connected with each other. They have independent computer system along with shared storage medium and all systems perform all tasks together. All nodes of clusters implement two different techniques for making communication with each other like as message passing Interface (MPI) and Parallel virtual machine (PVM). Figure 3.10: Clustered operating system Cluster Operating systems are mixer of software and hardware clusters. Hardware cluster provides help to share of ultra-performance disks in between all computer systems, and Software cluster offers better environment for all system to work together. Cluster system has several nodes, and they contain individual cluster software. This software helps to monitor entire cluster system. When, any one node of cluster system gets halt, then other nodes manage of its storage system as well as resources, and then you can try to restart this system. 57 CU IDOL SELF LEARNING MATERIAL (SLM)

Advantages of Clustered System  Clustered system provides much better performance for entire system because in which multiple computers are merged with each other, and they perform their tasks as parallel unit.  Clustered system is better fault tolerance system, if anyone node gets fail then entire system does not halt.  Clustered system has great scalability because we can easily add new node with this system.  It can be stopped server while managing over load from one server to another server. It is more reliable and easier to configure.  It can recover automatic from failure without user intervention. Disadvantages of Clustered System  It is more costly because it contains expensive hardware and its design.  Required multiple servers and other hardware components for making one  It is very hard to monitor and maintenance this system. 3.12 SUMMARY  An operating system is the most important program in a computer system. This is one program that runs all the time, as long as the computer is operational and exits only when the computer is shut down. Operating systems are the programs that make computers operational, hence the name. Operating systems are computers’ resource manager.  The time-sharing environment, we decide a time that is called time quantum and when the process starts its execution then the execution continues for only that amount of time and after that, other processes will be given chance for that amount of time only. In the next cycle, the first process will again come for its execution and it will be executed for that time quantum only and again next process will come.  In a Distributed Operating System, we have various systems and all these systems have their own CPU, main memory, secondary memory, and resources. These systems are connected to each other using a shared communication network. Here, each system can perform its task individually. The best part about these Distributed 58 CU IDOL SELF LEARNING MATERIAL (SLM)

Operating System is remote access i.e., one user can access the data of the other system and can work accordingly.  An Embedded Operating System is designed to perform a specific task for a particular device which is not a computer. The Embedded Operating System allows the access of device hardware to the software that is running on the top of the Operating System.  Real-time OS is a time-sharing system that is based on the concept of clock interrupt. So, whenever you want to process a large number of requests in a very short period of time, then you should use Real-time Operating System. For example, the details of the temperature of the petroleum industry are very crucial and this should be done in real- time and in a very short period of time. A small delay can result in a life-death situation. 3.13 KEYWORDS  Distributed system: A distributed system is a collection of processors that do not share memory, peripheral devices, or a clock.  Monitors: A monitor is software synchronization tool with high-level of abstraction that provides a convenient and effective mechanism for process synchronization.  Multiprocessor System: It is a computer system that has an array of a number of processors.  Multiprogramming: The rapid switching back and forth of CPU among processes is called multiprogramming.  Batch Processing: A mode of data processing in which a number of tasks are lines up and the entire task set is submitted to the computer in one go 3.14 LEARNING ACTIVITY 1. Explain why Java programs running on Android systems do not use the standard Java API and virtual machine. ___________________________________________________________________________ ____________________________________________________________________ 3.15 UNIT END QUESTIONS A. Descriptive Questions Short Questions 59 CU IDOL SELF LEARNING MATERIAL (SLM)

1. Define operating system. 2. What is time sharing systems? 3. What are the goals of an operating system? 4. Differentiate between multiprocessor systems and clustered systems. 5. What is the difference between single processing system and batch processing system? Long Question 1. Describe the architecture of a layered operating system. 2. Explain the working of an operating system with regard to resource management. 3. Explain different types of computer systems with examples. 4. Discuss the role of device controller in I/O structure. 5. Compare and contrast user mode and monitor mode. B. Multiple Choice Questions 1. Which is the Linux operating system? a. Private operating system b. Windows operating system c. Open-source operating system d. Closed-source operating system 2. In which of the following OS, the response time is very crucial? a. Network operating system b. Real time operating system c. Batch operating system d. Unix operating system 60 CU IDOL SELF LEARNING MATERIAL (SLM)

3. Embedded operating system used 61 a. On a mainframe b. On a PDA c. On a desktop operating system d. On a networked PC 4. Multi programming systems a. Are used only on large mainframe computers b. Are easier to develop than single programming systems c. Execute more jobs at the same time d. Execute each faster 5. What is not true about a distributed system? a. It is a collection of processors b. All processors are synchronized c. They do not share memory d. None of these 6. What are characteristic of Network Operating Systems? a. Users are aware of multiplicity of machines b. They are transparent c. They are simple to use d. All of these CU IDOL SELF LEARNING MATERIAL (SLM)

7. What is true about thread? a. Thread switching does not need to interact with operating system b. All threads can share same set of open files, child processes c. Multiple threaded processes use fewer resources d. All of these 8. A thread is also called? a. heavyweight process b. lightweight process c. data segment process d. overhead process 9. Which of the following is an example of a single task operating system? a. android b. Windows c. IOS d. CP/M 10. Which of the following becomes a limiting factor while an application program has to be complete? a. memory b. peripheral c. input d. output Answers 62 CU IDOL SELF LEARNING MATERIAL (SLM)

1 c,2 b,3 b, 4 c,5 b,6 a,7 d,8 b,9 d, 10 a 3.16 REFERENCES  A. Silberschatz P.B. Galvin, Gange (2002). Operating System Concepts, 6th Ed., Addison Wesley Publishing Co., Boston.  H.M. Deitel (1990). An Introduction to Operating Systems, Addison Wesley Publishing Co., Boston.  D.M. Dhamdhare (2002). Operating System. Tata McGraw Hill, New Delhi.  A.S. Tanenbaum (2000). Operating Systems: Design and Implementation, Prentice Hall of India, New Delhi.  Nutt (2005). Operating Systems, 3rd Edition, Pearson Education, Delhi. 63 CU IDOL SELF LEARNING MATERIAL (SLM)

UNIT - 4: OPERATING SYSTEM COMPONENTS 1 Structure 4.0 Learning Objectives 4.1 Introduction 4.2 System Calls 4.2.1 System Calls for Process Management 4.2.2 System Calls for Signalling 4.2.3 System Calls for File Management 4.2.4 System Calls for Directory Management 4.2.5 System Calls for Protection 4.2.6 System Calls for Time Management 4.2.7 System Calls for Device Management 4.3 System Programs 4.4 System Design and Implementation 4.4.1 Design Goals 4.4.2 Mechanisms and Policies 4.5 Process Management Component 4.6 Memory management Component 4.7 I/O Management Component 4.8 Summary 4.9 Keywords 4.10 Learning Activity 4.11 Unit End Questions 4.12 References 64 CU IDOL SELF LEARNING MATERIAL (SLM)

4.0 LEARNING OBJECTIVES After studying this unit, you will be able to:  Exercise general system architecture  Define system call and system operation  Describe System Design and Implementation  Explain memory management component  Outline I/O management functions 4.1 INTRODUCTION The main difference between the operating system and system software is that the operating system runs in kernel or supervisor mode whereas the system software and applications run in user mode. This means that the hardware stops the user programs directly accessing the hardware. And, due to this restriction, you cannot, for example, write your own disc interrupt handler and replace the one in the operating system. However, you can write your own (say) command shell and replace the one supplied with the computer. Finally, at the top level we have the application programs that, at last, allow us to do something useful. 4.2 SYSTEM CALLS  System calls provide an interface between a running program and operating system. System calls are generally available as assembly language instructions. Several higher-level languages such as C also allow making system calls directly.  In UNIX operating system the system call interface layer contains entry point in kernel code. All system resources are managed by the kernel. Any request from user or application that involves access to any system resource must be handled by kernel code. The user process must not be given open access to kernel code for security reason. Many opening into kernel code called system calls are provided to user so that the user processes can invoke the execution of kernel code. System calls allow processes and users to manipulate system resources. 65 CU IDOL SELF LEARNING MATERIAL (SLM)

 There are three general methods that are used to pass information (parameters) between a running program and the operating system:  One method is to store parameters in registers.  Another is to store parameters in a table in memory and pass the address of table.  The third method is to push parameters on stack and allow operating system to pop the parameters off the stack. User level programs Normal programs System call interface Kernel Virtual filesystem Memory Process Abstract network management manager manager Services (sockets) Various filesystem TCP/IP protocol drivers drivers IDE harddisk Floppy disk Ethernet card driver driver driver IDE hard disk Floppy disk Kernel Hardware Ethernet card Figure 4.1: System Call 4.2.1 System Calls for Process Management  These types of system calls are used to control the processes. Some examples are end, abort, load, execute, create process, terminate process, etc. For example, the exit () system call ends a process and returns a value to its parent.  In Unix every process has an alarm clock stored in its system-data segment. When the alarm goes off, signal SIGALRM is sent to the calling process. A child inherits its parent's alarm clock value, but the actual clock isn't shared. The alarm clock remains set across an exec. 66 CU IDOL SELF LEARNING MATERIAL (SLM)

4.2.2 System Calls for Signalling  A signal is a limited form of inter-process communication used in Unix, Unix-like, and other POSIX-compliant operating systems. Essentially, it is an asynchronous notification sent to a process in order to notify it of an event that occurred. The number of signals available is system dependent. When a signal is sent to a process, the operating system interrupts the process' normal flow of execution. Execution can be interrupted during any non-atomic instruction. If the process has previously registered a signal handler, that routine is executed. Otherwise, the default signal handler is executed.  Programs can respond to signals three different ways. These are:  Ignore the Signal: This means that the program will never be informed of the signal no matter how many times it occurs.  A signal can be set to its default state, which means that the process will be ended when it receives that signal.  Catch the Signal: When the signal occurs, the system will transfer control to a previously defined subroutine where it can respond to the signal as is appropriate for the program. 4.2.3 System Calls for File Management  The file structure related system calls available in some operating system like Unix let you create, open, and close files, read and write files, randomly access files, alias and remove files, get information about files, check the accessibility of files, change protections, owner, and group of files, and control devices. These operations either use a character string that defines the absolute or relative path name of a file, or a small integer called a file descriptor that identifies the I/O channel. When doing I/O, a process specifies the file descriptor for an I/O channel, a buffer to be filled or emptied, and the maximum size of data to be transferred. An I/O channel may allow input, output, or both. Furthermore, each channel has a read/write pointer. Each I/O operation starts where the last operation finished and advances the pointer by the number of bytes transferred. A process can access a channel's data randomly by changing the read/write pointer. 67 CU IDOL SELF LEARNING MATERIAL (SLM)

 These types of system calls are used to manage files. Some examples are Create file, delete file, open, close, read, write, etc. 4.2.4 System Calls for Directory Management  We may need the same sets of operations as for file management for directories also. If we have a directory structure for organizing files in the file system. In addition, for either files or directories, we need to be able to determine the values of various attributes, and perhaps to reset them if necessary. File attributes include the file name, a file type, protection codes, accounting information, and so on. At least two system calls, get file attribute and set file attribute, are required for this function. Some operating systems provide many more calls. 4.2.5 System Calls for Protection  Improper use of the system can easily cause a system crash. Therefore some level of control is required; the design of the microprocessor architecture on basically all modern systems (except embedded systems) offers several levels of control – the (low privilege) level of which normal applications execute limits the address space of the program to not be able to access nor modify other running applications nor the operating system itself (called \"protected mode\" on x86), it also prevents the application from using any system devices (i.e. the frame buffer, network devices – any I/O mapped device). But obviously any normal application needs this ability, thus the operating system is introduced, it executes at the highest level of order and allows the applications to request for a service – a system call – which is implemented through hooking interrupt(s). If allowed the system enters a higher privileged state, executes a specific set of instructions which the interrupting program has no direct control over, then returns control to the former flow of execution. This concept also serves as a way to implement security.  With the development of separate operating modes with varying levels of privilege, a mechanism was needed for transferring control safely from lesser privileged modes to higher privileged modes. Less privileged code could not simply transfer control to more privileged code at any arbitrary point and with any arbitrary processor state. To allow it to do so could allow it to break security. For instance, the less privileged code 68 CU IDOL SELF LEARNING MATERIAL (SLM)

could cause the higher privileged code to execute in the wrong order, or provide it with a bad stack. 4.2.6 System Calls for Time Management  Many operating systems provide a time profile of a program. It indicates the amount of time that the program executes at a particular location or set of locations. A time profile requires either a tracing facility or regular timer interrupts. At every occurrence of the timer interrupt, the value of the program counter is recorded. With sufficiently frequent timer interrupts, a statistical picture of the time spent on various parts of the program can be obtained. 4.2.7 System Calls for Device Management  A program, as it is running, may need additional resources to proceed. Additional resources may be more memory, tape drives, access to files, and so on. If the resources are available, they can be granted, and control can be returned to the user program; otherwise, the program will have to wait until sufficient resources are available.  These types of system calls are used to manage devices. Some examples are Request device, release device, read, write, get device attributes, etc. 4.3 SYSTEM PROGRAMS Another aspect of a modern system is the collection of system programs. In the logical computer hierarchy, the lowest level is hardware. Next is the operating system, then the system programs, and finally the application programs. System programs provide a convenient environment for program development and execution. Some of them are simply user interfaces to system calls; others are considerably more complex. They can be divided into these categories: File Management: These programs create, delete, copy, rename, print, dump, list, and generally manipulate files and directories. Status Information: Some programs simply ask the system for the date, time, amount of available memory or disk space, number of users, or similar status information. That information is then formatted, and is printed to the terminal or other output device or file. 69 CU IDOL SELF LEARNING MATERIAL (SLM)

File Modification: Several text editors may be available to create and modify the content of files stored on disk or tape. Programming-language Support: Compilers, assemblers, and interpreters for common programming languages (such as C, C++, Java, Visual Basic, and PERL) are often provided to the user with the operating system. Some of these programs are now priced and provided separately. Program Loading and Execution: Once a program is assembled or compiled, it must be loaded into memory to be executed. The system may provide absolute loaders, relocatable loaders, linkage editors, and overlay loaders. Debugging systems for either higher-level languages or machine language are needed also. Communications: These programs provide the mechanism for creating virtual connections among processes, users, and different computer systems. They allow users to send messages to one another's screens, to browse web pages, to send electronic-mail messages, to log in remotely, or to transfer files from one machine to another. Most operating systems are supplied with programs that solve common problems, or perform common operations. Such programs include web browsers, word processors and text formatters, spreadsheets, database systems, compiler compilers, plotting and statistical- analysis packages, and games. These programs are known as system utilities or application programs. Perhaps the most important system program for an operating system is the command interpreter, the main function of which is to get and execute the next user-specified command. Many of the commands given at this level manipulate files: create, delete, list, print, copy, execute, and so on. These commands can be implemented in two general ways. In one approach, the command interpreter itself contains the code to execute the command. For example, a command to delete a file may cause the command interpreter to jump to a section of its code that sets up the parameters and makes the appropriate system call. In this case, the number of commands that can be given determines the size of the command interpreter, since each command requires its own implementing code. An alternative approach-used by UNIX, among other operating systems implements most commands by system programs. In this case, the command interpreter does not understand 70 CU IDOL SELF LEARNING MATERIAL (SLM)

the command in any way; it merely uses the command to identify a file to be loaded into memory and executed. Thus, the UNIX command to delete a file. Figure 4.2: System Programme 4.4 SYSTEM DESIGN AND IMPLEMENTATION The design of a new operating system is a major task. The goals of the system must be well defined before the design begins. They form the foundation for choices among various algorithms and strategies that will be necessary. Since an operating system is large, modularity is important. Designing a system as a sequence of layers or using a microkernel is considered a good technique. The virtual-machine concept takes the layered approach and treats both the kernel of the operating system and the hardware as though they were all hardware. Other operating systems may even be loaded on top of this virtual machine. Any operating system that has implemented the JVM is able to run all Java programs, because the JVM abstracts the underlying system to the Java program, providing an architecture-neutral interface. Throughout the entire operating-system design cycle, we must be careful to separate policy decisions from implementation details (or mechanisms). This separation allows maximum flexibility if policy decisions are to be changed later. 71 CU IDOL SELF LEARNING MATERIAL (SLM)

Operating systems are now almost always written in a systems implementation language or in a higher-level language. This feature improves their implementation, maintenance, and portability. To create an operating system for a particular machine configuration, we must perform system generation. 4.4.1 Design Goals The first problem in designing a system is to define the goals and specifications of the system. At the highest level, the design of the system will be affected by the choice of hardware and type of system: batch, time shared, single user, multi-user, distributed, real- time, or general purpose. Beyond this highest design level, the requirements may be much harder to specify. The requirements can be divided into two basic groups: user goals and system goals. Users desire certain obvious properties in a system: The system should be convenient and easy to use, easy to learn, reliable, safe and fast. Of course, these specifications are not particularly useful in the system design, since there is no general agreement on how to achieve these goals. A similar set of requirements can be defined by those people who must design, create, maintain, and operate the system: The operating system should be easy to design, implement, and maintain; it should be flexible, reliable, error free and efficient. Again, these requirements are vague and have no general solution. We have no unique solution to the problem of defining the requirements for an operating system. The wide range of systems shows that different requirements can result in a large variety of solutions for different environments. For example, the requirements for MS-DOS, a single-user system for microcomputers, must have been substantially different from those for MVS, the large multi-user, multi-access operating system for IBM mainframes. 4.4.2 Mechanisms and Policies The specification and design of an operating system is a highly creative task. Although no one can tell you how to do it, general software engineering principles do exist that are especially applicable to operating systems. 72 CU IDOL SELF LEARNING MATERIAL (SLM)

One important principle is the separation of policy from mechanism. Mechanisms determine how to do something; policies determine what will be done. For example, the timer construct is a mechanism for ensuring CPU protection, but deciding how long the timer is to be set for a particular user is a policy decision. The separation of policy and mechanism is important for flexibility. Policies are likely to change across places or over time. In the worst case, each change in policy would require a change in the underlying mechanism. A general mechanism would be more desirable. A change in policy would then require redefinition of only certain parameters of the system. For instance, if, in one computer system, a policy decision is made that I/O-intensive programs should have priority over CPU-intensive ones, then the opposite policy could be instituted easily on some other computer system if the mechanism were properly separated and were policy independent. Microkernel-based operating systems take the separation of mechanism and policy to one extreme, by implementing a basic set of primitive building blocks. These blocks are almost policy free, allowing more advanced mechanisms and policies to be added via user-created kernel modules, or via user programs themselves. At the other extreme is a system such as the Apple Macintosh operating system, in which both mechanism and policy are encoded in the system to enforce a global look and feel to the system. All applications have similar interfaces, because the interface itself is built into the kernel. Policy decisions must be made for all resource-allocation and scheduling problems. Whenever the question is how rather than what, it is a mechanism that must be determined. 4.5 PROCESS MANAGEMENT COMPONENT A program does nothing unless its instructions are executed by a CPU. A program in execution, as mentioned, is a process. A time-shared user program such as a compiler is a process. A word-processing program being run by an individual user on a PC is a process. A system task, such as sending output to a printer, can also be a process. For now, you can consider a process to be a job or a time-shared program, but later you will learn that the concept is more general. A process needs certain resources—including CPU time, memory, files, and I/O devices—to accomplish its task. These resources are either given to the process when it is created or allocated to it while it is running. In addition to the various physical and logical resources that 73 CU IDOL SELF LEARNING MATERIAL (SLM)

a process obtains when it is created, various initialization data (input) may be passed along. For example, consider a process whose function is to display the status of a file on the screen of a terminal. The process will be given the name of the file as an input and will execute the appropriate instructions and system calls to obtain and display the desired information on the terminal. When the process terminates, the operating system will reclaim any reusable resources. We emphasize that a program by itself is not a process. A program is a passive entity, like the contents of a file stored on disk, whereas a process is an active entity. A single-threaded process has one program counter specifying the next instruction to execute. The execution of such a process must be sequential. The CPU executes one instruction of the process after another, until the process completes. Further, at any time, one instruction at most is executed on behalf of the process. Thus, although two processes may be associated with the same program, they are nevertheless considered two separate execution sequences. A multithreaded process has multiple program counters, each pointing to the next instruction to execute for a given thread. A process is the unit of work in a system. A system consists of a collection of processes, some of which are operating-system processes (those that execute system code) and the rest of which are user processes (those that execute user code). All these processes can potentially execute concurrently—by multiplexing on a single CPU, for example. The operating system is responsible for the following activities in connection with process management: • Scheduling processes and threads on the CPUs • Creating and deleting both user and system processes • Suspending and resuming processes • Providing mechanisms for process synchronization • Providing mechanisms for process communication 4.6 MEMORY MANAGEMENT COMPONENT Memory management is the functionality of an operating system which handles or manages primary memory and moves processes back and forth between main memory and disk during 74 CU IDOL SELF LEARNING MATERIAL (SLM)

execution. Memory management keeps track of each and every memory location, regardless of either it is allocated to some process or it is free. It checks how much memory is to be allocated to processes. It decides which process will get memory at what time. It tracks whenever some memory gets freed or unallocated and correspondingly it updates the status. Process Address Space The process address space is the set of logical addresses that a process references in its code. For example, when 32-bit addressing is in use, addresses can range from 0 to 0x7fffffff; that is, 2^31 possible numbers, for a total theoretical size of 2 gigabytes. The operating system takes care of mapping the logical addresses to physical addresses at the time of memory allocation to the program. There are three types of addresses used in a program before and after memory is allocated − S.No. Memory Addresses & Description 1 Symbolic addresses The addresses used in a source code. The variable names, constants, and instruction labels are the basic elements of the symbolic address space. 2 Relative addresses At the time of compilation, a compiler converts symbolic addresses into relative addresses. 3 Physical addresses The loader generates these addresses at the time when a program is loaded into main memory. Virtual and physical addresses are the same in compile-time and load-time address-binding schemes. Virtual and physical addresses differ in execution-time address-binding scheme. 75 CU IDOL SELF LEARNING MATERIAL (SLM)

The set of all logical addresses generated by a program is referred to as a logical address space. The set of all physical addresses corresponding to these logical addresses is referred to as a physical address space. The runtime mapping from virtual to physical address is done by the memory management unit (MMU) which is a hardware device. MMU uses following mechanism to convert virtual address to physical address.  The value in the base register is added to every address generated by a user process, which is treated as offset at the time it is sent to memory. For example, if the base register value is 10000, then an attempt by the user to use address location 100 will be dynamically reallocated to location 10100.  The user program deals with virtual addresses; it never sees the real physical addresses. Static vs Dynamic Loading The choice between Static or Dynamic Loading is to be made at the time of computer program being developed. If you have to load your program statically, then at the time of compilation, the complete programs will be compiled and linked without leaving any external program or module dependency. The linker combines the object program with other necessary object modules into an absolute program, which also includes logical addresses. If you are writing a dynamically loaded program, then your compiler will compile the program and for all the modules which you want to include dynamically, only references will be provided and rest of the work will be done at the time of execution. At the time of loading, with static loading, the absolute program (and data) is loaded into memory in order for execution to start. If you are using dynamic loading, dynamic routines of the library are stored on a disk in relocatable form and are loaded into memory only when they are needed by the program. Static vs Dynamic Linking As explained above, when static linking is used, the linker combines all other modules needed by a program into a single executable program to avoid any runtime dependency. 76 CU IDOL SELF LEARNING MATERIAL (SLM)

When dynamic linking is used, it is not required to link the actual module or library with the program, rather a reference to the dynamic module is provided at the time of compilation and linking. Dynamic Link Libraries (DLL) in Windows and Shared Objects in UNIX are good examples of dynamic libraries. Swapping Swapping is a mechanism in which a process can be swapped temporarily out of main memory (or move) to secondary storage (disk) and make that memory available to other processes. At some later time, the system swaps back the process from the secondary storage to main memory. Though performance is usually affected by swapping process but it helps in running multiple and big processes in parallel and that's the reason Swapping is also known as a technique for memory compaction. Figure 4.3: Swapping Mechanism The total time taken by swapping process includes the time it takes to move the entire process to a secondary disk and then to copy the process back to memory, as well as the time the process takes to regain main memory. 77 CU IDOL SELF LEARNING MATERIAL (SLM)

Let us assume that the user process is of size 2048KB and on a standard hard disk where swapping will take place has a data transfer rate around 1 MB per second. The actual transfer of the 1000K process to or from memory will take 2048KB / 1024KB per second = 2 seconds = 2000 milliseconds Memory Allocation Main memory usually has two partitions −  Low Memory − Operating system resides in this memory.  High Memory − User processes are held in high memory. Operating system uses the following memory allocation mechanism. S.N. Memory Allocation & Description 1 Single-partition allocation In this type of allocation, relocation-register scheme is used to protect user processes from each other, and from changing operating-system code and data. Relocation register contains value of smallest physical address whereas limit register contains range of logical addresses. Each logical address must be less than the limit register. 2 Multiple-partition allocation In this type of allocation, main memory is divided into a number of fixed-sized partitions where each partition should contain only one process. When a partition is free, a process is selected from the input queue and is loaded into the free partition. When the process terminates, the partition becomes available for another process. Fragmentation As processes are loaded and removed from memory, the free memory space is broken into little pieces. It happens after sometimes that processes cannot be allocated to memory blocks 78 CU IDOL SELF LEARNING MATERIAL (SLM)

considering their small size and memory blocks remains unused. This problem is known as Fragmentation. Fragmentation is of two types − S.N. Fragmentation & Description 1 External fragmentation Total memory space is enough to satisfy a request or to reside a process in it, but it is not contiguous, so it cannot be used. 2 Internal fragmentation Memory block assigned to process is bigger. Some portion of memory is left unused, as it cannot be used by another process. 4.7 I/O MANAGEMENT COMPONENT Humans interact with machines by providing information through IO devices. Also, much of whatever a computer system provides as on-line services is essentially made available through specialized devices such as screen displays, printers, keyboards, mouse, etc. Clearly, management of all these devices can affect the throughput of a system. For this reason, input output management also becomes one of the primary responsibilities of an operating system. Issues in IO Management When we analyze device communication, we notice that communication is required at the following three levels:  The need for a human to input information and receive output from a computer.  The need for a device to input information and receive output from a computer.  The need for computers to communicate (receive/send information) over networks. The first kind of IO devices operate at rates good for humans to interact. These may be character-oriented devices like a keyboard or an event-generating device like a mouse. Usually, human input using a key board will be a few key depressions at a time. This means that the communication is rarely more than a few bytes. Also, the mouse events can be 79 CU IDOL SELF LEARNING MATERIAL (SLM)

encoded by a small amount of information (just a few bytes). Even though a human input is very small, it is stipulated that it is very important, and therefore requires an immediate response from the system. A communication which attempts to draw attention often requires the use of an interrupt mechanism or a programmed data mode of operation. The second kind of IO requirement arises from devices which have a very high character density such as tapes and disks. With these characteristics, it is not possible to regulate communication with devices on a character-by-character basis. The information transfer, therefore, is regulated in blocks of information. Additionally, sometimes this may require some kind of format control to structure the information to suit the device and/or data characteristics. For instance, a disk drive differs from a line printer or an image scanner. For each of these devices, the format and structure of information is different. It should be observed that the rate at which a device may provide data and the rates at which an end application may consume it may be considerably different. The third kind of IO requirements emanate from the need to negotiate system IO with the communications infrastructure. The system should be able to manage communications traffic across the network. This form of IO facilitates access to internet resources to support e-mail, file-transfer amongst machines or Web applications. Additionally, now we have a large variety of options available as access devices. These access devices may be in the form of Personal Digital Assistant (PDA), or mobile phones which have infrared or wireless enabled communications. This rapidly evolving technology makes these forms of communications very challenging. It is beyond the scope of this book to have a discussion on these technologies, devices or mechanisms. Even then it should be remarked that most network cards are direct memory access (DMA) enabled to facilitate DMA mode of IO with communication infrastructure. Managing Events Computer system may sometimes be embedded to interact with a real-life activity or process. It is quite possible that in some operational context a process may have to synchronize with some other process. In such a case this process may actually have to wait to achieve a rendezvous with another process. In fact, whichever of the two synchronizing processes arrives first at the point of rendezvous would have to wait. When the other process also reaches the point of synchronization, the first process may proceed after recognizing the 80 CU IDOL SELF LEARNING MATERIAL (SLM)

synchronizing event. Note that events may be communicated using signals which we shall learn about later. IO Organization The basic idea is to select a mode of communication taking device characteristics into account or a need to synchronize with some event, or to just have a simple strategy to ensure a reliable assured IO. Computers employ the following four basic modes of IO operation: 1. Programmed mode 2. Polling mode 3. Interrupt mode 4. Direct memory access mode. Programmed Data Mode In this mode of communication, execution of an IO instruction ensures that a program shall not advance till it is completed. To that extent one is assured that IO happens before anything else happens. An IO instruction is issued to an IO device and the program executes in “busy- waiting” (idling) mode till the IO is completed. During the busy-wait period the processor is continually interrogating to check if the device has completed IO. Invariably the data transfer is accomplished through an identified register and a flag in a processor. Figure 4.4: Programmed mode of IO 81 CU IDOL SELF LEARNING MATERIAL (SLM)

The figure depicts how an input can happen using the programmed data mode. First the processor issues an IO request (shown as 1), followed by device putting a data in a register (shown as 2) and finally the flag (which is being interrogated) is set (shown as 3). The device either puts a data in the register (as in case of input) or it picks up data from the register (in case of output). When the IO is accomplished, it signals the processor through the flag. During the busy-wait period the processor is busy checking the flag. However, the processor is idling from the point of view of doing anything useful. This situation is similar to a car engine which is running when the car is not in motion – essentially “idling”. Polling In this mode of data transfer, the system interrogates each device in turn to determine if it is ready to communicate. If it is ready, communication is initiated and subsequently the process continues again to interrogate in the same sequence. This is just like a round-robin strategy. Each IO device gets an opportunity to establish Communication in turn. No device has a particular advantage (like say a priority) over other devices. Polling is quite commonly used by systems to interrogate ports on a network. Polling may also be scheduled to interrogate at some pre-assigned time intervals. It should be remarked here that most daemon software operates in polling mode. In hardware, this may typically translate to the following protocol: 1. Assign a distinct address to each device connected to a bus. 2. The bus controller scans through the addresses in sequence to find which device wishes to establish a communication. 3. Allow the device that is ready to communicate to leave its data on the register. 4. The IO is accomplished. In case of an input the processor picks up the data. In case of an output the device picks up the data. 5. Move to interrogate the next device address in sequence to check if it is ready to communicate. 82 CU IDOL SELF LEARNING MATERIAL (SLM)

Figure 4.5: Polling mode of IO. Interrupt Mode Let us begin with a simple illustration to explain the basic rationale behind interrupt mode of data transfer. Suppose a program needs input from a device which communicates using interrupt. Even with the present-day technology the devices are one thousand or more times slower than the processor. So, if the program waits on the input device it would cycle through many processor cycles just waiting for the input device to be ready to communicate. This is where the interrupt mode of communication scores. To begin with, a program may initiate IO request and advance without suspending its operation. At the time when the device is actually ready to establish an IO, the device raises an interrupt to seek communication. Immediately the program execution is suspended temporarily and current state of the process is stored. The control is passed on to an interrupt service routine (which may be specific to the device) to perform the desired input. Subsequently, the suspended process context is restored to resume the program from the point of its suspension. Interrupt processing may happen in the following contexts:  Internal Interrupt  External Interrupt  Software Interrupt DMA Mode of Data Transfer 83 CU IDOL SELF LEARNING MATERIAL (SLM)

This is a mode of data transfer in which IO is performed in large data blocks. For instance, the disks communicate in data blocks of sizes like 512 bytes or 1024 bytes. The direct memory access, or DMA ensures access to main memory without processor intervention or support. Such independence from processor makes this mode of transfer extremely efficient. When a process initiates a direct memory access (DMA) transfer, its execution is briefly suspended (using an interrupt) to set up the DMA control. The DMA control requires the information on starting address in main memory and size of data for transfer. This information is stored in DMA controller. Figure 4.6: DMA: Hardware support The communication is regulated to first happen between the device and the controller, and later between the controller and main memory or CPU if so needed. Note that these devices communicate in blocks of bits or bytes as a data stream. Clearly, an un-buffered communication is infeasible via the data bus. The bus has its own timing control protocol. The bus cannot, and should not, be tied to device transfer bursts. The byte stream block needs to be stored in a buffer isolated from the communication to processor or main memory. This is precisely what the buffer in the disk controller accomplishes. Once the controller buffer has the required data, then one can envisage to put the controller in contention with CPU and main memory or CPU to obtain an access to the bus. This is the kind of information which initially needs to be set up in the controller address and count registers. Putting this information may be done under a program control as a part of DMA set up. The program that does it is usually the device controller. The device controller can then schedule the operations with much finer control. Data location information in disk 84 CU IDOL SELF LEARNING MATERIAL (SLM)

Figure 4.7: Direct memory access mode of data transfer. 4.8 SUMMARY  A process that creates a particular and uniquely specified operating system; it combines user-specified options and parameters with manufacturer-supplied general-purpose or non-specialized program subsections to produce an operating system (or other complex software) of the desired form and capacity is known as System Generation.  Memory management is the functionality of an operating system which handles or manages primary memory and moves processes back and forth between main memory and disk during execution.  Memory management keeps track of each and every memory location, regardless of either it is allocated to some process or it is free. It checks how much memory is to be allocated to processes.  Humans interact with machines by providing information through IO devices. Also, much of whatever a computer system provides as on-line services is essentially made available through specialized devices such as screen displays, printers, keyboards, mouse, etc. Clearly, management of all these devices can affect the throughput of a system. For this reason, input output management also becomes one of the primary responsibilities of an operating system. 4.9 KEYWORDS  Physical Memory: It is a broken into fixed-sized blocks called frames. Logical memory is also broken into blocks of the same size called pages.  System calls: System calls provide an interface between a running program and operating system.  System programs: System programs provide a convenient environment for program development and execution. 85 CU IDOL SELF LEARNING MATERIAL (SLM)

 Java Virtual Machine (JVM): It is an engine that provides runtime environment to drive the Java Code or applications. It converts Java bytecode into machines language. JVM is a part of Java Run Environment.  Process: a process is the instance of a computer program that is being executed by one or many threads. It contains the program code and its activity. Depending on the operating system, a process may be made up of multiple threads of execution that execute instructions concurrently.  DMA: Direct memory access is a feature of computer systems that allows certain hardware subsystems to access main system memory independent of the central processing unit. 4.10 LEARNING ACTIVITY 1. A password may become known to other users in a variety of ways. Is there a simple method for detecting that such an event has occurred? Explain your answer. ___________________________________________________________________________ ____________________________________________________________________ 4.11 UNIT END QUESTIONS A. Descriptive Questions Short Questions 1. What is the function of function of a command interpreter? 2. Discuss the functions of various layers included in layered systems. 3. What is Exokernel? How it is structured? 4. Explain different types of system components. 5. Explain the concept of system calls and system programs. Long Questions 1. What is system generation? Explain it. 2. Why is the separation of mechanism and policy a desirable principle? 3. Explain memory management component with necessary diagram. 86 CU IDOL SELF LEARNING MATERIAL (SLM)

4. What are the design goals of System Design and Implementation? 5. Outline I/O management component with its functionalities. B. Multiple Choice Questions 1. If one or more devices use a common set of wires to communicate with the computer system, the connection is called ______. a. CPU b. Monitor c. wirefull d. bus 2. A ____ set of wires and a rigidly defined protocol that specifies a set of messages that can be sent on the wires. a. port b. node c. bus d. None of these 3. When device A has a cable that plugs into device B, and device B has a cable that plugs into device C and device C plugs into a port on the computer, this arrangement is called a _________. a. port b. daisy chain c. bus d. cable 87 CU IDOL SELF LEARNING MATERIAL (SLM)

4. The _________ present a uniform device-access interface to the I/O subsystem, much as system calls provide a standard interface between the application and the operating system. a. devices b. buses c. device drivers d. I/O systems 5. A ________ is a collection of electronics that can operate a port, a bus, or a device. a. controller b. driver c. host d. bus 6. An I/O port typically consists of four registers status, control, ________ and ________ registers. a. system in, system out b. data in, data out c. flow in, flow out d. input, output 7. The ______ register is read by the host to get input. 88 a. flow in b. flow out c. data in CU IDOL SELF LEARNING MATERIAL (SLM)

d. data out 8. The ______ register is written by the host to send output. a. status b. control c. data in d. data out 9. The hardware mechanism that allows a device to notify the CPU is called _______. a. polling b. interrupt c. driver d. controlling 10. The CPU hardware has a wire called __________ that the CPU senses after executing every instruction. a. interrupt request line b. interrupt bus c. interrupt receive line d. interrupt sense line Answers 1 d, 2 c, 3 b, 4 c, 5 a, 6 b, 7 c, 8 d, 9 b, 10 a 4.12 REFERENCES  A. Silberschatz P.B. Galvin, Gange (2002). Operating System Concepts, 6th Ed., Addison Wesley Publishing Co., Boston. 89 CU IDOL SELF LEARNING MATERIAL (SLM)

 H.M. Deitel (1990). An Introduction to Operating Systems, Addison Wesley Publishing Co., Boston.  D.M. Dhamdhare (2002). Operating System. Tata McGraw Hill, New Delhi.  A.S. Tanenbaum (2000). Operating Systems: Design and Implementation, Prentice Hall of India, New Delhi.  Nutt (2005). Operating Systems, 3rd Edition, Pearson Education, Delhi. 90 CU IDOL SELF LEARNING MATERIAL (SLM)

UNIT - 5: OPERATING SYSTEM COMPONENTS 2 Structure 5.0 Learning Objectives 5.1 Introduction 5.2 File Management Component 5.2.1 File System 5.3 File Protection 5.3.1 Protection in Computer System 5.3.2 Access-Matrix Model of Protection 5.3.3 Access Hierarchies 5.3.4 Access Lists 5.4 Networking management component 5.5 Command interpreter 5.6 Summary 5.7 Keywords 5.8 Learning Activity 5.9 Unit End Questions 5.10 References 5.0 LEARNING OBJECTIVES After studying this unit, you will be able to:  Describe file management component  Perform file management task  Analyse file protection system  Exercise networking management functions  Discuss command interpreter 91 CU IDOL SELF LEARNING MATERIAL (SLM)

5.1 INTRODUCTION Another part of the operating system is the file manager. While the memory manager is responsible for the maintenance of primary memory, the file manager is responsible for the maintenance of secondary storage (e.g., hard disks). Each file is a named collection of data stored in a device. The file manager implements this abstraction and provides directories for organizing files. It also provides a spectrum of commands to read and write the contents of a file, to set the file read/write position, to set and use the protection mechanism, to change the ownership, to list files in a directory, and to remove a file. The file manager provides a protection mechanism to allow machine users to administer how processes executing on behalf of different users can access the information in files. File protection is a fundamental property of files because it allows different people to store their information on a shared computer, with the confidence that the information can be kept confidential. In addition to these functions, the file manager also provides a logical way for users to organize files in secondary storage. 5.2 FILE MANAGEMENT COMPONENT The most familiar file systems make use of an underlying data storage device that offers access to an array of fixed-size blocks, sometimes called sector, generally 512 bytes each. The file system software is responsible for organizing these sectors into files and directories, and keeping track of which sectors belong to which file and which are not being used. Most file systems address data in fixed-sized units called \"clusters\" or \"blocks\" which contain a certain number of disk sectors (usually 1–64). This is the smallest logical amount of disk space that can be allocated to hold a file. However, file systems need not make use of a storage device at all. A file system can be used to organize and represent access to any data, whether it be stored or dynamically generated (e.g., from a network connection). Whether the file system has an underlying storage device or not, file systems typically have directories which associate file names with files, usually by connecting the file name to an index into a file allocation table of some sort, such as the FAT in an MS-DOS file system, or an inode in a Unix-like file system. Directory structures may be flat, or allow hierarchies where directories may contain subdirectories. In some file systems, file names are structured, 92 CU IDOL SELF LEARNING MATERIAL (SLM)

with special syntax for filename extensions and version numbers. In others, file names are simple strings, and per-file metadata is stored elsewhere. Other bookkeeping information is typically associated with each file within a file system. The length of the data contained in a file may be stored as the number of blocks allocated for the file or as an exact byte count. The time that the file was last modified may be stored as the file's timestamp. Some file systems also store the file creation time, the time it was last accessed, and the time that the file's meta-data was changed. (Note that many early PC operating systems did not keep track of file times.) Other information can include the file's device type (e.g., block, character, socket, subdirectory, etc.), its owner user-ID and group- ID, and its access permission settings (e.g., whether the file is read-only, executable, etc.). The hierarchical file system was an early research interest of Dennis Ritchie of UNIX fame; previous implementations were restricted to only a few levels, notably the IBM implementations, even of their early databases like IMS. After the success of UNIX, Ritchie extended the file system concept to every object in his later operating system developments, such as Plan 9 and Inferno. Traditional file systems offer facilities to create, move and delete both files and directories. They lack facilities to create additional links to a directory (hard links in UNIX), rename parent links (Unix-like OS), and create bidirectional links to files. Traditional file systems also offer facilities to truncate, append to, create, move, delete and in-place modify files. They do not offer facilities to prepend to or truncate from the beginning of a file, let alone arbitrary insertion into or deletion from a file. The operations provided are highly asymmetric and lack the generality to be useful in unexpected contexts. For example, inter-process pipes in UNIX have to be implemented outside of the file system because the pipes concept does not offer truncation from the beginning of files. Secure access to basic file system operations can be based on a scheme of access control lists or capabilities. Research has shown access control lists to be difficult to secure properly, which is why research operating systems tend to use capabilities. Commercial file systems still use access control lists. 93 CU IDOL SELF LEARNING MATERIAL (SLM)

5.2.1 File System A file system is a method for storing and organizing computer files and the data they contain to make it easy to find and access them. File systems may use a data storage device such as a hard disk or CD-ROM and involve maintaining the physical location of the files, they might provide access to data on a file server by acting as clients for a network protocol (e.g., NFS, SMB, or 9P clients), or they may be virtual and exist only as an access method for virtual data. More formally, a file system is a set of abstract data types that are implemented for the storage, hierarchical organization, manipulation, navigation, access, and retrieval of data. File systems share much in common with database technology, but it is debatable whether a file system can be classified as a special-purpose database (DBMS). Types of File Systems File system types can be classified into disk file systems, network file systems and special purpose file systems. Disk file systems: A disk file system is a file system designed for the storage of files on a data storage device, most commonly a disk drive, which might be directly or indirectly connected to the computer. Examples of disk file systems include FAT, FAT32, NTFS, HFS and HFS+, ext2, ext3, ISO 9660, ODS-5, and UDF. Some disk file systems are journaling file systems or versioning file systems. Flash file systems: A flash file system is a file system designed for storing files on flash memory devices. These are becoming more prevalent as the number of mobile devices is increasing, and the capacity of flash memories catches up with hard drives. While a block device layer can emulate a disk drive so that a disk file system can be used on a flash device, this is sub-optimal for several reasons: Erasing blocks: Flash memory blocks have to be explicitly erased before they can be written to. The time taken to erase blocks can be significant, thus it is beneficial to erase unused blocks while the device is idle. Random access: Disk file systems are optimized to avoid disk seeks whenever possible, due to the high cost of seeking. Flash memory devices impose no seek latency. 94 CU IDOL SELF LEARNING MATERIAL (SLM)

Wear levelling: Flash memory devices tend to wear out when a single block is repeatedly overwritten; flash file systems are designed to spread out writes evenly. Log-structured file systems: These systems have all the desirable properties for a flash file system. Such file systems include JFFS2 and YAFFS. Database file systems: A new concept for file management is the concept of a database- based file system. Instead of, or in addition to, hierarchical structured management, files are identified by their characteristics, like type of file, topic, author, or similar metadata. Example: dbfs. Transactional file systems: Each disk operation may involve changes to a number of different files and disk structures. In many cases, these changes are related, meaning that it is important that they all be executed at the same time. Take for example a bank sending another bank some money electronically. The bank's computer will \"send\" the transfer instruction to the other bank and also update its own records to indicate the transfer has occurred. If for some reason the computer crashes before it has had a chance to update its own records, then on reset, there will be no record of the transfer but the bank will be missing some money. Transaction processing introduces the guarantee that at any point while it is running, a transaction can either be finished completely or reverted completely (though not necessarily both at any given point). This means that if there is a crash or power failure, after recovery, the stored state will be consistent. (Either the money will be transferred or it will not be transferred, but it won't ever go missing \"in transit\"). This type of file system is designed to be fault tolerant, but may incur additional overhead to do so. Journaling file systems are one technique used to introduce transaction-level consistency to file system structures. Network file systems: A network file system is a file system that acts as a client for a remote file access protocol, providing access to files on a server. Examples of network file systems include clients for the NFS, SMB protocols, and file-system-like clients for FTP and WebDAV. Special purpose file systems: A special purpose file system is basically any file system that is not a disk file system or network file system. This includes systems where the files are arranged dynamically by software, intended for such purposes as communication between computer processes or temporary file space. Special purpose file systems are most commonly 95 CU IDOL SELF LEARNING MATERIAL (SLM)

used by file-centric operating systems such as Unix. Examples include the procfs (/proc) file system used by some Unix variants, which grants access to information about processes and other operating system features. Deep space science exploration craft, like Voyager I & II used digital tape based special file systems. Most modern space exploration craft like Cassini- Huygens used Real-time operating system file systems or RTOS influenced file systems. The Mars Rovers are one such example of an RTOS file system, important in this case because they are implemented in flash memory. Flat file systems: In a flat file system, there are no subdirectories-everything is stored at the same (root) level on the media, be it a hard disk, floppy disk, etc. While simple, this system rapidly becomes inefficient as the number of files grows, and makes it difficult for users to organise data into related groups. Like many small systems before it, the original Apple Macintosh featured a flat file system, called Macintosh File System. Its version of Mac OS was unusual in that the file management software (Macintosh Finder) created the illusion of a partially hierarchical filing system on top of MFS. This structure meant that every file on a disk had to have a unique name, even if it appeared to be in a separate folder. MFS was quickly replaced with Hierarchical File System, which supported real directories. File Systems and Operating Systems Most operating systems provide a file system, as a file system is an integral part of any modern operating system. Early microcomputer operating systems' only real task was file management – a fact reflected in their names. Some early operating systems had a separate component for handling file systems which was called a disk operating system. On some microcomputers, the disk operating system was loaded separately from the rest of the operating system. On early operating systems, there was usually support for only one, native, unnamed file system; for example, CPM supports only its own file system, which might be called \"CPM file system\" if needed, but which didn't bear any official name at all. Because of this, there needs to be an interface provided by the operating system software between the user and the file system. This interface can be textual (such as provided by a command line interface, such as the UNIX shell, or OpenVMS DCL) or graphical (such as provided by a graphical user interface, such as file browsers). If graphical, the metaphor of the folder, containing documents, other files, and nested folders is often used. 96 CU IDOL SELF LEARNING MATERIAL (SLM)

File Attributes Disks provide the bulk of secondary storage on which a file system is maintained. To improve I/O efficiency, I/O transfer between memory and disk are performed in units of blocks. Each block is one or more sectors. Depending on the disk drive, sectors vary from 32 bytes to 4096 bytes; usually, they are 512 bytes. Disks have two important characteristics that make them a convenient medium for storing multiple files: They can be rewritten in place; it is possible to read a block from the disk, to modify the block, and to write it back into the same place. One can access directly any given block of information on the disk. Thus, it is simple to access any file either sequentially or randomly, and switching from one file to another requires only moving the read-write heads and waiting for the disk to rotate. To provide an efficient and convenient access to the disk, the operating system imposes a file system to allow the data to be stored, located, and retrieved easily. A file system poses two quite different design problems. The first problem is defining how the file system should look to the user. This task involves the definition of a file and its attributes, operations allowed on a file, and the directory structure for organizing the files. Next, algorithms and data structure must be created to map the logical file system onto the physical secondary storage devices. The file system itself is generally composed of many different levels. The structure shown in the figure is an example of a layered design. Each level in the design uses the features of lower levels to create new features for use by higher levels. The lowest level, the I/O control, consists of device drivers and interrupts handlers to transfer information between the memory and the disk system. A device driver can be thought of as a translator. Its input consists of high-level commands such as “retrieve block 123”. Its output consists of low-level hardware-specific instructions that are used by the hardware controller which interfaces the I/O device to the rest of the system. The device driver usually writes specific bit patterns to special locations in the I/O controller's memory to tell the controller on which device location to act and what actions to take. 97 CU IDOL SELF LEARNING MATERIAL (SLM)

The basic file system needs only to issue generic commands to the appropriate device driver to read and write physical blocks on the disk. Each physical block is identified by its numeric disk address (for example, drive 1, cylinder 3, track 2, and sector 10). The file-organization module knows about files and their logical blocks, as well as physical blocks. By knowing the type of file allocation used and the location of the file, the file- organization module can translate logical block addresses to physical block addresses for the basic file system to transfer. Each file's logical blocks are numbered from 0 (or 1) through N, whereas the physical blocks containing the data usually do not match the logical numbers, so a translation is needed to locate each block. The file-organization module also includes the free-space manager, which tracks unallocated blocks and provides these blocks to the file- organization module when requested. Finally, the logical file system uses the directory structure to provide the file organization module with the information the latter needs, given a symbolic file name. To create a new file, an application program calls the logical file system. The logical file system knows the format of the directory structures. To create a new file, it reads the appropriate directory into memory, updates it with the new entry, and writes it back to the disk. Some operating systems, including UNIX, treat a directory exactly as a file – one with a type field indicating that it is a directory. Other operating systems, including Windows/NT, implement separate system calls for files and directories and treat directories as entities separate from files. When a directory is treated as a special file, the logical file system can call the file-organization module to map the directory I/O into disk block numbers, which are passed on to the basic file system and I/O control system. 98 CU IDOL SELF LEARNING MATERIAL (SLM)

Figure 5.1: File System Attributes Now that a file has been created, it can be used for I/O. For each I/O operation, the directory structure could be searched to find the file, its parameters checked, its data blocks located, and finally the operation on those data blocks performed. Each operation would entail high over-heads. Rather, before the file can be used for I/O procedures, it must be opened. When a file is opened, the directory structure is searched for the desired file entry. Parts of the directory structure are usually cached in memory to speed directory operations. Once the file is found, the associated information such as size, owner, access permissions and data block locations are generally copied into a table in memory, referred to as the open-file table, consisting of information about all the currently opened files. The first reference to a file (normally an open) causes the directory structure to be searched and the directory entry for this file to be copied into the table as opened files. The index into this table is returned to the user program, and all further references are made through the index rather than with the symbolic name. The name given to the index varies. Unix systems refer to it as a file descriptor, Windows/NT as a file handle, and other systems as a file control block. Consequently, as long as the file is not closed, all file operations are done on 99 CU IDOL SELF LEARNING MATERIAL (SLM)

the open-file table. When the file is closed by all users who have opened it, the updated file information is copied back to the disk-based directory structure. Some systems complicate this scheme even further by using multiple levels of in-memory tables. For example, in the BSD UNIX file system, each process has an open-file table that holds a list of pointers, indexed by descriptor. The pointers lead to a system-wide open-file table. This table contains information about the underlying entity that is open. For files, it points to a table of active inodes. For other entities, such as network connections and devices, it points to similar access information. The active-inodes table is an in-memory cache of inodes currently in use, and includes the inode index fields that point to the on-disk data blocks. In this way, once a file is opened, all but the actual data blocks are in memory for rapid access by any process accessing the file. In reality, the open first searches the open-file table entry is created pointed to the system-wide open-file table. If not, the inode is copied into the active-inodes table, a new system-wide entry is created and a new per-process entry is created. File System Functions The file system provides the mechanism for online storage and access to both data and programs. The file system resides permanently on secondary storage, which has the main requirement that it must be able to hold a large amount of data, permanently. This lesson is primarily concerned with issues concerning file storage and access on the most common secondary-storage medium, the disk. We explore ways to allocate disk space, to recover freed space, to track the locations of data, and to interface other parts of the operating system to secondary storage. File Naming Each file is a distinct entity and therefore a naming convention is required to distinguish one from another. The operating systems generally employ a naming system for this purpose. In fact, there is a naming convention to identify each resource in the computer system not files alone. File Types The files under UNIX can be categorized as follows: 100 CU IDOL SELF LEARNING MATERIAL (SLM)


Like this book? You can publish your book online for free in a few minutes!
Create your own flipbook