1 / 69

Understanding Operating Systems Sixth Edition

Understanding Operating Systems Sixth Edition. Chapter 16 Linux Operating System. Learning Objectives. After completing this chapter, you should be able to describe: The design goals for the Linux operating system The flexibility offered by using files to manipulate devices

dulcinea
Télécharger la présentation

Understanding Operating Systems Sixth Edition

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Understanding Operating Systems Sixth Edition Chapter 16Linux Operating System

  2. Learning Objectives After completing this chapter, you should be able to describe: • The design goals for the Linux operating system • The flexibility offered by using files to manipulate devices • The differences between command-driven and menu-driven interfaces • The roles of the Memory, Device, File, Processor, and Network Managers • Some strengths and weaknesses of Linux Understanding Operating Systems, Sixth Edition

  3. Overview • Linux is POSIX-compliant and portable with versions available to run: • cell phones, supercomputers, and most computing systems in between. • Its source code is freely available, allowing programmers to configure it to run any device and meet any specification. • The frequent inclusion of several powerful desktop GUIs continues to attract users. • It is also highly modular, allowing multiple modules to be loaded and unloaded on demand, making it a technically robust operating system. Understanding Operating Systems, Sixth Edition

  4. Overview • Linux is an open source program. • Its source code is freely available to anyone for improvement. • If someone sends a better program or coding sequence to Linus Torvalds, the author of Linux, and if it’s accepted as a universal improvement to the OS, then the new code is added to the next version made available to the computing world. • Updates are scheduled every six months. • In this way, Linux is under constant development by uncounted contributors around the world, most of whom have never met. • The name Linux remains a registered trademark of Linus Torvalds. Understanding Operating Systems, Sixth Edition

  5. History • Linus Torvalds wanted to create an OS that would greatly enhance the limited capabilities of the Intel 80386 microprocessor. • He started with MINIX (a miniature UNIX system developed primarily by Andrew Tanenbaum) and rewrote certain parts to add more funcxtionality. • When he had a working OS, he announced his achievement on an Internet usegroup. • It was August, 1991. • This new OS, originally created to run a small microcomputer, was built with substantial flexibility and it features many of the same functions found on expensive commercial OS. Understanding Operating Systems, Sixth Edition

  6. History (cont’d) • Linux brought much of the speed, efficiency, and flexibility of UNIX to small desktop computers. • The first Linux OS required typed and sometimes cryptic commands. • Now users can enter commands using either a command-driven interface (terminal mode) or a menu-driven interface or graphical user interface (GUI), greatly expanding the usability of the OS. • The first primary corporate supporter of Linux was Red Hat Linux, the world’s leading Linux distributor until 2003. Understanding Operating Systems, Sixth Edition

  7. History (cont’d) • In September of that year, the company split its efforts in two directions: • The Fedora Project to encourage continuation of open-source development of the Linux Kernel; • Red Hat Enterprise Linux (RHEL) to meet the growing needs of organizations willing to pay for and enterprise-wide OS and dedicated technical support. • As shown in Table 16.1, the Fedora Project issues updates free to the public about every six months. • Because Linux is written and distributed under the GNU General Public License, its source-code is freely distributed and available to the general public. Understanding Operating Systems, Sixth Edition

  8. History (cont'd.) Understanding Operating Systems, Sixth Edition

  9. History (cont'd.) Understanding Operating Systems, Sixth Edition

  10. Design Goals • Linux has three design goals: • Modularity • Simplicity • Portability • To achieve these goals, Linux administrators have access to numerous standard utilities, eliminating the need to write special code. • Many of these utilities can be used in combination with each other so that users can select and combine appropriate utilities to carry out specific tasks. • As shown in Table 16.2, Linux accommodates numerous functions. Understanding Operating Systems, Sixth Edition

  11. Design Goals (cont'd.) Understanding Operating Systems, Sixth Edition

  12. Design Goals (cont’d) • Linux conforms to the specifications for Portable Operating System Interface (POSIX). • A registered trademark of the IEEE. • POSIX is an IEEE standard that defines OS interfaces to enhance the portability of programs from one OS to another. Understanding Operating Systems, Sixth Edition

  13. Memory Management • When Linux allocates space, it allocates: • 1GB of high-order memory to the kernel • 3GB of memory to executing processes. • This 3GB address space is divided among: • Process data; • Shared library data used by the process; • The stack used by the process. • When a process begins execution, its segments have a fixed size. • There are cases when a process has to handle variables with an unknown number and size. Understanding Operating Systems, Sixth Edition

  14. Memory Management (cont’d) • When a process begins execution, its segments have a fixed size (cont’d). • Therefore, Linux has system calls that change the size of the process data segment, either by expanding it to accommodate extra data values or reducing it when certain values positioned at the end of the data segment are no longer needed. • Linux offers memory protection based on the type of information stored in each region belonging to the address space of a process. • If a process modifies access authorization assigned to a memory region, the kernel changes the protection information assigned to the corresponding memory pages. Understanding Operating Systems, Sixth Edition

  15. Memory Management (cont'd.) • When a process requests pages, Linuz loads them into memory. • When the kernel needs the memory space, the pages are released using a least recently used algorithm (LRU). • Linux maintains a dynamically managed area in memory, a page cache, where new and old pages requested by processes are inserted, and from which pages are deleted when they’re no longer needed. • If any pages marked for deletion have been modified, they’re rewritten to the disk. • The swap device could be a partition on the disk or it could be a normal file. Understanding Operating Systems, Sixth Edition

  16. Memory Management (cont'd.) • Linux shows added flexibility with swap devices because, if necessary, Linux can deactivate them without having to reboot the system. • When this takes place, all pages saved on that device are reloaded into memory. • To keep track of free and busy pages, Linux uses a system of page tables. • Virtual memory in Linux is managed using a multiple-level table hierarchy, which accommodates both 64- and 32-bit architectures. • Table 16.3 shows how each virtual address is made up of four fields, which are used by the Memory Manager to locate the instruction or data requested. Understanding Operating Systems, Sixth Edition

  17. Memory Management (cont'd.) • Virtual memory managed using multiple-level table hierarchy • Four fields in virtual address Understanding Operating Systems, Sixth Edition

  18. Memory Management (cont'd.) • Each page has its own entry in the main directory, which has pointers to each page’s middle directory. • A page’s middle directory contains pointers to its corresponding page table directories. • In turn, each page table directory has pointers to the actual page frame, as shown in Figure 16.2. • Finally, the page offset field is used to locate the instruction or data within the requested page (Line 214). Understanding Operating Systems, Sixth Edition

  19. Memory Management (cont'd.) Understanding Operating Systems, Sixth Edition

  20. Memory Management (cont'd.) • Virtual memory is implemented in Linux through demand paging. • Up to a total of 256MB of usable memory can be configured into equal-sized page frames, which can be grouped to give more contiguous space to a job. • These groups can also be split to accommodate smaller jobs. Understanding Operating Systems, Sixth Edition

  21. Memory Management (cont'd.) • This process of grouping and splitting is known as the buddy algorithm. • Let’s consider the case where main memory consists of 64 page frames and Job 1 requests 15 page frames. • The buddy algorithm first rounds up the request to the next power of 2 (15 is rounded up to 16). • Then the group of 64 page frames is divided into two groups of 32, and the lower section is then divided in half. • Now there is a group of 16 page frames that can satisfy the request, so the job’s 16 pages are copied into the page frames as shown in Figure 16.3 (a). Understanding Operating Systems, Sixth Edition

  22. Memory Management (cont'd.) • The buddy algorithm (cont’d). • When the next job, Job 2, requests 8 page frames, the second group of 16 page frames is divided into two and the lower half with 8 page frames is given to Job 2 (Figure 16.3 (b)). • Later, when Job 2 releases its page frames, they are combined with the upper 8 page frames to make a group of 16 page frames (Figure 16.3 (c)). Understanding Operating Systems, Sixth Edition

  23. Memory Management (cont'd.) Understanding Operating Systems, Sixth Edition

  24. Memory Management (cont'd.) • The page replacement algorithm is an expanded version of the clock page replacement policy (Chapter 3). • Instead of using a single reference bit, Linux uses an eight-bit byte to keep track of a page’s activity. • Referred to as “age”. • Each time a page is referenced, this age variable is incremented. • Behind the scenes, at specific intervals, the Memory Manager checks each of these age variables and decreases their value by 1. Understanding Operating Systems, Sixth Edition

  25. Memory Management (cont'd.) • As a result, if a page is not reference frequently, then its age variable will drop to 0 and the page will become a candidate for replacement if a page swap is necessary. • On the other hand, a page that is frequently used will have a high age value and will not be a good choice for swapping. • Therefore, we can see that Linux uses a form of the least frequently used (LFU) replacement policy. Understanding Operating Systems, Sixth Edition

  26. Processor Management • Linux uses the same parent-child process management design found in UNIX (Chapter 13). • Linux also supports the concept of “Personality” to allow processes coming from other OS to be executed. • Each process is assigned to an execution domain specifying the way in which system calls are carried out and the way in which messages are sent to processes. Understanding Operating Systems, Sixth Edition

  27. Organization of Process Table • Each process is referenced by a descriptor which contains approximately 70 fields describing the process attributes together with the information needed to manage the process. • The kernel dynamically allocates these descriptors when processes begin execution. • All process descriptors are organized by a doubly linked list, and the descriptors of processes that are ready or in execution are put in another doubly linked list with fields indicating: • “Next run” • “Previously run” • There are several macro instructions used by the Scheduler to manage and update these process descriptor lists as needed. Understanding Operating Systems, Sixth Edition

  28. Process Synchronization • Linux provides wait queues and semaphores to allow two processes to synchronize with each other. • A Wait queue is a linked circular list of process descriptors. • Semaphores (Chapter 6) are used to solve the problems of mutual exclusion and the problems of producers and consumers. • In Linux, the semaphore structure contains three fields: • The semaphore counter; • The number of waiting processes; • The list of processes waiting for the semaphore. Understanding Operating Systems, Sixth Edition

  29. Process Synchronization (cont’d) • In Linux, the semaphore structure contains three fields (cont’d). • The semaphore counter may contain only binary values, except when several units of one resource are available, and the semaphore counter then assumes the value of the number of units that are accessible concurrently. Understanding Operating Systems, Sixth Edition

  30. Process Management • The Linux scheduler: • Scans the list of processes in the READY state; • Using predefined criteria, chooses which process to execute. • The scheduler has three different scheduling types: • Two for real-time processes; • One for normal processes. • The combination of type (Table 16.4) and priority is used by the scheduler to determine the scheduling policy used on processes in the READY queue. Understanding Operating Systems, Sixth Edition

  31. Process Management (cont'd.) Understanding Operating Systems, Sixth Edition

  32. Process Management (cont'd.) • From among the processes with the highest priority (SCHED_FIFO), the scheduler selects the process with the highest priority and executes it using the First in, first out algorithm. • This process is normally not preemptible and runs to completion unless one of the following situations occur: • The process goes into the WAIT state (waiting for I/O, or another event, to finish). • The process relinquishes the processor voluntarily, in which case the process is moved to a WAIT state and other proceses are executed. • Only when all FIFO processes are completed does the scheduler proceed to execute processes of lower priority. Understanding Operating Systems, Sixth Edition

  33. Process Management (cont'd.) • When executing a process of the second type (SCHED_RR), the scheduler chooses those from this group with the highest priority and uses a round robin algorithm with a small time quantum. • When the time expires, other higher priority processes (FIFO, RR ) may be selected and executed before the first process is allowed to complete. Understanding Operating Systems, Sixth Edition

  34. Process Management (cont'd.) • The third type of process (SCHED_OTHER) has the lowest priority and is executed only when there are no processes with higher priority in the READY queue. • From among these processes, the scheduler selects processes on order after considering their dynamic priorities. • Set by the user using system calls and by a factor computed by the system. • From among the SCHED-OTHER processes, the priorities of all processes that are CPU-bound are lowered during execution. • They may earn a lower priority than processes that are not executing or those with a priority that has not been lowered. Understanding Operating Systems, Sixth Edition

  35. Device Management • Linux is device independent, which improves portability from one system to another. • Device drivers supervise the transmission of data between main memory and the peripheral unit. • Devices are assigned not only a name but also descriptors that further identify each device and are stored in the device directory (Figure 16.4) Understanding Operating Systems, Sixth Edition

  36. Device Management (cont'd.) Understanding Operating Systems, Sixth Edition

  37. Device Classifications • Linux identifies each device by a: • Minor device number: • Passed to the device driver as an argument • Is used to access one of several identical physical devices. • Major device number: • Used as an index to the array to access the appropriate code for a specific device driver. • Each class has a Configuration Table that contains an array of entry points into the device drivers. • This table is the only connection between the system code and device driver. • It allows the system programmers to create new device drivers quickly to accommodate differently configured systems. Understanding Operating Systems, Sixth Edition

  38. Device Drivers • Linux supports the standard classes of devices introduced by UNIX. • Linux allows new device classes to support new technology. • Device classes are not rigid in nature. • Programmers may choose to create large, complex device drivers to perform multiple functions. • Such programming is discouraged because: • Code can be shared among Linux users and there is a wider demand for several simple drivers than for a single complex one. • Modular code is better able to support Linux’s goals of system scalability and extendibility. Understanding Operating Systems, Sixth Edition

  39. Device Drivers (cont'd.) • Programmers are urged to write device drivers that maximize the system’s ability to use the device effectively. • A notable feature of Linux is its ability to accept new device drivers on the fly, while the system is up and running. • Administrators can give the kernel additional functionality by loading and testing new drivers without having to reboot each time to reconfigure the kernel. • Devices are treated in Linux in the same way all files are treated. Understanding Operating Systems, Sixth Edition

  40. Device Drivers (cont'd.) • Two common features of Linux device drivers are open and release, which essentially allocate and deallocate the appropriate device. • The operation to open a device should perform the following functions: • Verify that the device is available and in working order. • Increase the usage counter for the device by 1, so the subsystem knows that the module cannot be unloaded until its file is appropriately closed. • Initialize the device so that old data is removed and the device is ready to accept new data. • Identify the minor number and update the appropriate pointer if necessary. • Allocate any appropriate data structure. Understanding Operating Systems, Sixth Edition

  41. Device Drivers (cont'd.) • The release function (called device_close or device_release) performs these tasks: • Deallocate any resources that were allocated with the open function; • Shut down the device; • Reduce the usage counter by 1 so the device can be released to another module. Understanding Operating Systems, Sixth Edition

  42. Device Classes • Three standard classes Understanding Operating Systems, Sixth Edition

  43. Device Classes (cont'd.) • The three standard classes of devices supported b y Linux are character devices, block devices and network devices (Figure 16.5). • Character (char) devices • Can be accessed as a stream of bytes • Communications port, monitor, other byte-stream-fed device. • At a minimum, drivers for these devices usually implement the open, close, read, and write system calls. • Accessed by file system nodes, and, from a functional standpoint, these devices look like an ordinary data area. Understanding Operating Systems, Sixth Edition

  44. Device Classes (cont'd.) • Character (Char) Devices (contid). • Their drivers are treated the same way as ordinary files with the exception that char device drivers are data channels that must be accessed sequentially. • Block devices • Can host a file system (hard disk). • Accessed by file system nodes in /dev directory • These devices are transferred in blocks of data of any size from a few bytes to many. • Appear as ordinary files with the exception that the block drivers can access a file system in connection with the device (not possible with char device). Understanding Operating Systems, Sixth Edition

  45. Device Classes (cont'd.) • Network interfaces • Are dissimilar from both char and block devices because their function is to send and receive packets of information as directed by the network subsystem of the kernel. • Each system device is handled by a device driver that is, in turn, under the direction of a subsystem of Linux. Understanding Operating Systems, Sixth Edition

  46. File Management • All Linux files are organized in directories that are connected to each other in a tree-like structure. • Linux specifies five file types (Table 16.5). Understanding Operating Systems, Sixth Edition

  47. Data Structures • Files organized in directories • Connected in treelike structure • Five file types Understanding Operating Systems, Sixth Edition

  48. Filename Conventions • Filenames are case sensitive so Linux recognizes both uppercase and lowercase letters in filenames. • Filenames can be up to 255 characters long. • Can contain alphabetic characters, underscores, and numbers. • File suffixes (similar to file extensions) are optional. • Filenames can include a space; however, this can cause complications if you’re running programs from the command-line • A program named interview notes would be viewed as a command to run two files: interview and notes. • To avoid confusion, the two words can be enclosed in quotes: “interview notes” Understanding Operating Systems, Sixth Edition

  49. Filename Conventions (cont'd.) Understanding Operating Systems, Sixth Edition

  50. Filename Conventions (cont’d) • To copy the file called checks for october (Figure 16.6), the user can type from any other folder:cp/memo/job_expenses/checks for october • The first slash indicates that this is an absolute path name that starts at the root directory. • If the file you are seeking is in a local directory, you can use a relative path name – one that doesn’t start at the root directory. • Two examples of relative path names from Figure 16.6 are: Job_expense/checks for october memo/music 10a Understanding Operating Systems, Sixth Edition

More Related