58
Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Embed Size (px)

Citation preview

Page 1: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems Seventh Edition

Chapter 15Linux Operating Systems

Page 2: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 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 roles of the Memory, Device, File, Processor,

and Network Managers• The impact of open source software• Some strengths and weaknesses of Linux

Page 3: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 3

Introduction

• Linux– Originally based on a version of UNIX– Powerful– Inexpensive or free to use

• Portable– Versions for cell phones, supercomputers, and

computing systems in between• Source code: freely available

– Configurable: runs any device; meets any specification

Page 4: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 4

Introduction (cont'd.)

• Open source– Source code freely available to anyone for

improvement– Under constant development– Contributors around the world: not paid for their work

Page 5: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 5

Brief History

• Developed by Linus Torvalds (1991)• Original purpose

– Maximize Intel 80386 microprocessor’s limited capabilities

– Roots• MINIX: miniature UNIX with more functionality

• First version meant for small microcomputer– Expensive commercial computer features

• Flexibility and functionality– Brought UNIX features to small computer

Page 6: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 6

Brief History (cont'd.)

• User interface– First Linux operating systems: command-driven

interface • Sometimes cryptic commands

– Recent years• Graphical user interfaces (GUI)

• Written and distributed under the GNU General Public License

• Fedora Project responsible for the open-source development of the Linux kernel

Page 7: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 7

(table 15.1) Selected releases of Ubuntu Linux. New releases are scheduled every 6 months. Normal Ubuntu releases are supported for 18 months; LTS releases are supported longer. (adapted from https://wiki.ubuntu.com/Releases)© Cengage Learning 2014

Page 8: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 8

Design Goals

• Three goals– Modularity– Simplicity– Portability

• Numerous standard utilities– Eliminate need to write special code– Used in combination for specific tasks

• Numerous functions• IEEE POSIX (Portable Operating System Interface)

specifications conformity– Programs’ portability

Page 9: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 9

(table 15.2) Select system functions supported by Linux.© Cengage Learning 2014

Page 10: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 10

(table 15.2) (cont’d.)Select system functions supported by Linux.© Cengage Learning 2014

Page 11: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 11

Memory Management

• Space allocation– Kernel: 1 GB high order memory– Executing processes: 3 GB memory

• Process execution– Fixed-size segment– System calls change segment size

• Memory protection– Based on information type stored in address space

region for process

Page 12: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 12

Memory Management (cont'd.)

• Page loading– Least recently used algorithm (LRU)– Maintains a dynamically managed memory area and

page cache (new and old pages inserted and deleted)• System page tables

– Track free and busy pages – Added flexibility with swap devices

• Virtual memory– Managed using multiple-level table hierarchy

• 64- and 32-bit architectures

Page 13: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 13

Memory Management (cont'd.)

(table 15.3)The four fields that make up the virtual address for Line 214 in Figure 15.2.© Cengage Learning 2014

Page 14: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 14

(figure 15.2)Virtual memory management uses three levels of tables (Main, Middle, and Page Table Directories) to locate the page frame with the requested instruction or data within a job.© Cengage Learning 2014

Page 15: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 15

Memory Management (cont'd.)

• Buddy algorithm– Groups and splits into equal-sized page frames

• Gives more contiguous space to job

• Page replacement algorithm– Clock page replacement policy: expanded version– Uses eight-bit byte to track page’s activity: “age”– Page swap based on form of least frequently used

(LFU) replacement policy

Page 16: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 16

(figure 15.3)Main memory is divided to accommodate jobs of different sizes. In (a), the original group of 32 page frames is divided to satisfy the request of Job 1 for 16 page frames. In (b), another group of 16 page frames is divided to accommodate Job 2, which needs eight page frames. In (c), after Job 2 finishes, the two groups of eight page frames each are recombined into a group of 16, while Job 1 continues processing. © Cengage Learning 2014

Page 17: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Processor Management

• Uses same parent-child process management design found in UNIX

• Supports “personality” concept– Allows processes from other operating systems to be

executed

Understanding Operating Systems, 7e 17

Page 18: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Organization of Process Table

• Descriptor: referencing process– Contains approximately 70 fields: describe process

attributes– Includes information needed to manage process– Dynamically allocated by kernel

• Process execution time– Organized by doubly linked lists

• “Next run” field• “Previously run” field

– Scheduler manages and updates descriptors using macros

Understanding Operating Systems, 7e 18

Page 19: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Process Synchronization

• Wait queues and semaphores– Synchronize two processes with each other

• Wait queue– Linked circular list of process descriptors– Problems solved

• Mutual exclusion and producers and consumers

• Semaphore structure– Three fields (semaphore counter, number of waiting

processes, list of processes waiting for semaphore)• Counter contains only binary values: except if several

units of one resource available

Understanding Operating Systems, 7e 19

Page 20: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 20

Process Management

• Linux scheduler– Scans processes list in READY state – Chooses process to execute

• Using predefined criteria

• Three scheduling types– Real-time processes (two)– Normal processes (one)

• Process scheduling policy determination– Combination of type and priority

Page 21: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 21

Process Management (cont'd.)

(table 15.4)Linux has three process types, each signaling a different level of priority.© Cengage Learning 2014

Page 22: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 22

Process Management (cont'd.)

• First type– Highest priority (SCHED_FIFO)

• First in, first out algorithm– Cannot be preempted– Runs to completion unless:

• Process goes into WAIT state• Process relinquishes processor voluntarily

– All FIFO processes complete • Scheduler processes lower priority types

Page 23: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Process Management (cont'd.)

• Second type– Medium priority (SCHED_RR)

• Round robin algorithm with small time quantum– Time quantum expires

• Other higher priority processes (FIFO, RR ) selected and executed: before first process allowed to complete

• Third type– Low priority (SCHED_OTHER)– Executed if no higher priority processes in READY

queue

Understanding Operating Systems, 7e 23

Page 24: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 24

Device Management

• Device independent – Improves portability

• Device drivers– Supervise data transmission

• Between main memory and peripheral unit

• Devices assigned– Name – Descriptors

• Further identify each device• Stored in device directory

Page 25: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 25

Device Management (cont'd.)

(figure 15.4)Details about each device can be accessed via the Device Manager.© Cengage Learning 2014

Page 26: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 26

Device Classifications

• Device identification– Minor device number

• Passed to device driver as an argument• Accesses one of several identical physical devices

– Major device number• Index to array to access appropriate code

• Configuration Table for each class– Entry point into driver– Only connection between system code and driver– Importance

• Allows programmers quick creation of device drivers

Page 27: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 27

Device Drivers

• Support for standard classes introduced by UNIX• Allow new device classes supporting new

technology• Device classes not rigid

– Creating large, complex, and multiple function drivers is discouraged because:• Users share code: wider demand for simple drivers • Modular code supports system scalability and

extendibility goals– Encouraged: drivers maximizing system’s effective

device usage

Page 28: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 28

Device Drivers (cont'd.)

• Notable feature– Accept new device drivers on the fly

• System up and running• No reboot necessary

Page 29: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Device Drivers (cont'd.)

• Open and release: functions performed when opening a device– Verify that the device is available and in working order– Increase usage counter for the device by 1: alert the

subsystem that the module cannot be unloaded until its file is appropriately closed

– Initialize the device: 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, 7e 29

Page 30: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 30

Device Drivers (cont'd.)

• Open and release: functions (device_close or device_release) performed when releasing a device– Deallocate any resources allocated with the open

function– Shut down the device– Reduce usage counter by 1 so the device can be

released to another module

Page 31: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Device Classes

• Three standard classes– Character devices– Block devices– Network devices

Understanding Operating Systems, 7e 31

Page 32: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 32

(figure 15.5)This example of the three primary classes of device drivers shows how device drivers receive direction from different subsystems of Linux.© Cengage Learning 2014

Page 33: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 33

Device Classes (cont'd.)

• Character (char) devices– Accessed as a stream of bytes

• Communications port, monitor, or other byte-stream-fed device

– Implement open, release, read, and write system calls– Accessed by file system nodes

• Look like ordinary data area– Drivers treated as ordinary files

• Exception: drivers are data channels accessed sequentially

Page 34: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 34

Device Classes (cont'd.)

• Block devices– Host a file system (e.g., hard disk)– Accessed by file system nodes in /dev directory

• Transfer in blocks of data– Similarity to char driver

• Appear as ordinary files – Dissimilarity to char driver

• Access file system in connection with device (not possible with char device)

Page 35: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 35

Device Classes (cont'd.)

• Network interfaces – Function

• Send and receive information packets• Directed by network subsystem

– Network device functions• Relate to packet transmission

• System device handled by device driver– Under Linux subsystem’s direction

Page 36: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 36

File Management

• Very similar to UNIX– Easy transition for programmers and administrators

who are familiar with one operating system to move to the other

Page 37: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 37

Data Structures

• Files organized in directories– Connected in treelike structure

Page 38: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 38

(table 15.5)The file type indicates how each file is to be used.© Cengage Learning 2014

Page 39: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 39

Filename Conventions

• Case sensitive– Recognizes uppercase and lowercase letters

• Up to 255 characters long• Contain alphabetic characters, underscores, and

numbers• File suffixes: optional• Can include space

– Complications if running command-line programs• File hierarchy

– First slash indicates an absolute path name

Page 40: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 40

(figure 15.6)A sample file hierarchy. The forward slash (/ ) at the top represents the root directory.© Cengage Learning 2014

Page 41: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 41

Filename Conventions (cont'd.)

• Path name rules1. Path name starting with slash: begins at root

directory2. Path name

• One name or list of names separated by slashes• Last name on list: name of file requested

3. Two periods (..) in path name• Move upward in hierarchy: closer to root• Only way to go up the hierarchy

Page 42: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 42

Filename Conventions (cont'd.)

• Virtual File System (VFS)– Kernel

• Allows processes to access files in a consistent manner• Maintains interface between file related system calls

and file management code– Virtual file system layer

• Receives process-initiated system call to files • Performs file operations independent of file system

format• Redirects request to module managing the file

Page 43: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

New Versions

• Linux operating systems: patched between version releases– Downloaded on request or– System setup checks for available updates

• Patch management – Replaces or changes parts of the operating system

that need to be enhanced or replaced

Understanding Operating Systems, 7e 43

Page 44: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

New Versions (cont'd.)

• Reasons for operating system patches– Security precautions: constantly changing system

threats– System compliance: government regulations

regarding privacy and financial accountability– Peak efficiency

• System manager must:– Maintain vigilance: security vulnerabilities– Assess patch’s criticality

• If important, apply immediately

Understanding Operating Systems, 7e 44

Page 45: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 45

User Interface

• Early Linux versions – Required typed commands

• Thorough knowledge of valid commands required

• Current versions– Include powerful and intuitive menu-driven interfaces – Can still use Terminal mode

• Type commands similar to those used for UNIX– Several graphical user interfaces available

Page 46: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 46

User Interface (cont'd.)

• Many Linux versions – Equipped with Windows-compatible word processors,

spreadsheet, and presentation applications

Page 47: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 47

System Monitor

• System Monitor window – Moment-by-moment system status

• Immediate history: CPUs, memory, and network usage– Other information

• Supported file systems • Currently running processes information

Page 48: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 48

(figure 15.9)This Linux system monitor shows the recent history of both CPUs, shown in the top graph. © Cengage Learning 2014

Page 49: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 49

System Logs

• Provide detailed description of activity on system• Invaluable to administrators

– Tracking system malfunction– Firewall failure– Disabled device

• Found in /var/log directory• Seen using a log viewer

Page 50: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 50

(figure 15.10)The system log viewer shows details of all activity.© Cengage Learning 2014

Page 51: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 51

(table 15.6)A few of the many available Linux log files. See the documentation for your system for specifics.© Cengage Learning 2014

Page 52: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

File Listings

Understanding Operating Systems, 7e 52

(figure 15.11)Directories are shown in the left-most column, and the contents of the currently highlighted folder are displayed in the window on the right.© Cengage Learning 2014

Page 53: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 53

File Listings (cont'd.)

• Explore directory’s or file’s contents– Double click its icon

• Establish the directory’s or file’s access control settings– Right click on item’s icon

• Terminal window– Display directory details: type command ls-l

Page 54: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 54

(figure 15.12)Directory details shown in Terminal mode, which is another way to explore Linux.© Cengage Learning 2014

Page 55: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 55

Setting Permissions

• Network administrators– Full control: manage access to files and directories

• Three levels of access– Owner– Group– Others

• Access level settings: under properties option• Access types

– Create and delete files, list files only, access files, and none

Page 56: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Understanding Operating Systems, 7e 56

(figure 15.13)User activity can be restricted by using document properties options.© Cengage Learning 2014

Page 57: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Conclusion

• Originally designed to gain more power from a 1990s computer– Evolved into powerful, flexible operating system: runs

supercomputers, cell phones, and many other devices• Unparalleled popularity among programmers

– Contribute standard code set enhancements• Supports broad range of applications

– Available for minimal cost and easy to install– Growing acceptance among non-programmers

Understanding Operating Systems, 7e 57

Page 58: Understanding Operating Systems Seventh Edition Chapter 15 Linux Operating Systems

Conclusion (cont'd.)

• Large organizations– Commercial Linux products available

• Viable marketplace player– Popularity expected to grow for many years– Android operating system foundation

Understanding Operating Systems, 7e 58