Module 1 - SLP
INTRODUCTION TO OPERATING SYSTEMS, OPERATING SYSTEM SERVICES AND STRUCTURES
We can view an operating system from several vantage points. One view focuses on the services that the system provides; another, on the interface that it makes available to users and programmers; a third, on its components and their interconnections. In this SLP, we explore all three aspects of operating systems, showing the viewpoints of users, programmers, and operating system designers.
An operating system provides an environment for the execution of programs. It provides certain services to programs and to the users of those programs. The speciﬁc services provided, of course, differ from one operating system to another, but we can identify common classes. These operating system services are provided for the convenience of the programmer, to make the programming task easier. Figure 6 shows one view of the various operating system services and how they interrelate.
View of Operating System Services
Figure 6. A View of Operating System Services
One set of operating system services provides functions that are helpful to the user.
User interface. Almost all operating systems have a user interface (UI). This interface can take several forms. One is a command-line interface (CLI), which uses text commands and a method for entering them (say, a keyboard for typing in commands in a speciﬁc format with speciﬁc options). Another is a batch interface, in which commands and directives to control those commands are entered into ﬁles, and those ﬁles are executed. Most commonly, a graphical user interface (GUI) is used. Here, the interface is a window system with a pointing device to direct I/O, choose from menus, and make selections and a keyboard to enter text. Some systems provide two or all three of these variations.
Program execution. The system must be able to load a program into memory and to run that program. The program must be able to end its execution, either normally or abnormally (indicating error).
I/O operations. A running program may require I/O, which may involve a ﬁle or an I/O device. For speciﬁc devices, special functions may be desired (such as recording to a CD or DVD drive or blanking a display screen). For efﬁciency and protection, users usually cannot control I/O devices directly. Therefore, the operating system must provide a means to do I/O.
File-system manipulation. The ﬁle system is of particular interest. Obviously, programs need to read and write ﬁles and directories. They also need to create and delete them by name, search for a given ﬁle, and list ﬁle information. Finally, some operating systems include permissions management to allow or deny access to ﬁles or directories based on ﬁle ownership. Many operating systems provide a variety of ﬁle systems, sometimes to allow personal choice and sometimes to provide speciﬁc features or performance characteristics.
Communications. There are many circumstances in which one process needs to exchange information with another process. Such communication may occur between processes that are executing on the same computer or between processes that are executing on different computer systems tied together by a computer network. Communications may be implemented via shared memory, in which two or more processes read and write to a shared section of memory, or message passing, in which packets of information in predeﬁned formats are moved between processes by the operating system.
Error detection. The operating system needs to be detecting and correcting errors constantly. Errors may occur in the CPU and memory hardware (such as a memory error or a power failure), in I/O devices (such as a parity error on disk, a connection failure on a network, or lack of paper in the printer), and in the user program (such as an arithmetic overﬂow, an attempt to access an illegal memory location, or a too-great use of CPU time). For each type of error, the operating system should take the appropriate action to ensure correct and consistent computing. Sometimes, it has no choice but to halt the system. At other times, it might terminate an error-causing process or return an error code to a process for the process to detect andpossibly correct.
Another set of operating system functions exists not for helping the user but rather for ensuring the efﬁcient operation of the system itself. Systems with multiple users can gain efﬁciency by sharing the computer resources among the users.
Resource allocation. When there are multiple users or multiple jobs running at the same time, resources must be allocated to each of them. The operating system manages many different types of resources. Some (such as CPU cycles, main memory, and ﬁle storage) may have special allocation code, whereas others (such as I/O devices) may have much more general request and release code. For instance, in determining how best to use the CPU, operating systems have CPU-scheduling routines that take into account the speed of the CPU, the jobs that must be executed, the number of registers available, and other factors. There may also be routines to allocate printers, USB storage drives, and other peripheral devices.
Accounting. We want to keep track of which users use how much and what kinds of computer resources. This record keeping may be used for accounting (so that users can be billed) or simply for accumulating usage statistics. Usage statistics may be a valuable tool for researchers who wish to reconﬁgure the system to improve computing services.
Protection and security. The owners of information stored in a multiuser or networked computer system may want to control use of that information. When several separate processes execute concurrently, it should not be possible for one process to interfere with the others or with the operating system itself. Protection involves ensuring that all access to system resources is controlled. Security of the system from outsiders is also important. Such security starts with requiring each user to authenticate himself or herself to the system, usually by means of a password, to gain access to system resources. It extends to defending external I/O devices, including network adapters, from invalid access attempts and to recording all such connections for detection of break-ins. If a system is to be protected and secure, precautions must be instituted throughout it. A chain is only as strong as its weakest link.
User and Operating-System Interface
We mentioned earlier that there are several ways for users to interface with the operating system. Here, we discuss two fundamental approaches. One provides a command-line interface, or command interpreter, that allows users to directly enter commands to be performed by the operating system. The other allows users to interface with the operating system via a graphical user interface, or GUI.
1. Command Interpreters
Some operating systems include the command interpreter in the kernel. Others, such as Windows and UNIX, treat the command interpreter as a special program that is running when a job is initiated or when a user ﬁrst logs on (on interactive systems). On systems with multiple command interpreters to choose from, the interpreters are known as shells. For example, on UNIX and Linux systems, a user may choose among several different shells, including the Bourne shell, C shell, Bourne-Again shell, Korn shell, and others. Third-party shells and free user-written shells are also available. Most shells provide similar functionality, and a user’s choice of which shell to use is generally based on personal preference. Figure 7 shows the Bourne shell command interpreter being used on Solaris 10.
Bourne Shell Command Interpreter
Figure 7. Bourne Shell Command Interpreter
The main function of the command interpreter is to get and execute the next user-speciﬁed command. Many of the commands given at this level manipulate ﬁles: create, delete, list, print, copy, execute, and so on. The MS-DOS and UNIX shells operate in this way. 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 ﬁle 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 through system programs. In this case, the command interpreter does not understand the command in any way; it merely uses the command to identify a ﬁle to be loaded into memory and executed. Thus, the UNIX command to delete a ﬁle
would search for a ﬁle called rm, load the ﬁle into memory, and execute it with the parameter file.txt. The function associated with the rm comm. And would be deﬁned completely by the code in the ﬁle rm. In this way, programmers can add new commands to the system easily by creating new ﬁles with the proper names. The command-interpreter program, which can be small, does not have to be changed for new commands to be added.
2. Graphical User Interfaces
A second strategy for interfacing with the operating system is through a user-friendly graphical user interface, or GUI. Here, rather than entering commands directly via a command-line interface, users employ a mouse-based window-and-menu system characterized by a desktop metaphor. The user moves the mouse to position its pointer on images, or icons, on the screen (the desktop) that represent programs, ﬁles, directories, and system functions. Depending on the mouse pointer’s location, clicking a button on the mouse can invoke a program, select a ﬁle or directory—known as a folder—or pull down a menu that contains commands.
Graphical user interfaces ﬁrst appeared due in part to research taking place in the early 1970s at Xerox PARC research facility. The ﬁrst GUI appeared on the Xerox Alto computer in 1973. However, graphical interfaces became more widespread with the advent of Apple Macintosh computers in the 1980s. The user interface for the Macintosh operating system (Mac OS) has undergone various changes over the years, the most signiﬁcant being the adoption of the Aqua interface that appeared with Mac OS X. Microsoft’s ﬁrst version of Windows—Version 1.0—was based on the addition of a GUI interface to the MS-DOS operating system. Later versions of Windows have made cosmetic changes in the appearance of the GUI along with several enhancements in its functionality.
Because a mouse is impractical for most mobile systems, smartphones and handheld tablet computers typically use a touchscreen interface. Here, users interact by making gestures on the touchscreen—for example, pressing and swiping ﬁngers across the screen. Figure 8 illustrates the touchscreen of the Apple iPad. Whereas earlier smartphones included a physical keyboard, most smartphones now simulate a keyboard on the touchscreen.
Figure 8. Touchscreen Interfaces
Traditionally, UNIX systems have been dominated by command-line interfaces.Various GUI interfaces are available, however. These include the Common Desktop Environment (CDE) and X-Windows systems, which are common on commercial versions of UNIX, such as Solaris and IBM’s AIX system. In addition, there has been signiﬁcant development in GUI designs from various open-source projects, such as KDesktop Environment (or KDE) and the GNOME desktop by the GNU project. Both the KDE and GNOME desktops run on Linux and various UNIX systems and are available under open-source licenses, which means their source code is readily available for reading and for modiﬁcation under speciﬁc license terms.
3. Choice of Interface
The choice of whether to use a command-line or GUI interface is mostly one of personal preference. System administrators who manage computers and power users who have deep knowledge of a system frequently use the command-line interface. For them, it is more efﬁcient, giving them faster access to the activities they need to perform. Indeed, on some systems, only a subset of system functions is available via the GUI, leaving the less common tasks to those who are command-line knowledgeable. Further, command-line interfaces usually make repetitive tasks easier, in part because they have their own programmability. For example, if a frequent task requires a set of command-line steps, those steps can be recorded into a ﬁle, and that ﬁle can be run just like a program. The program is not compiled into executable code but rather is interpreted by the command-line interface. These shell scripts are very common on systems that are command-line oriented, such as UNIX and Linux. In contrast, most Windows users are happy to use the Windows GUI environment and almost never use the MS-DOS shell interface.
Another aspect of a modern system is its collection of system programs. Recall Figure1, which depicted the logical computer hierarchy. At the lowest level is hardware. Next is the operating system, then the system programs, and ﬁnally the application programs. System programs, also known as system utilities, provide a convenient environment for program development and execution. They can be divided into these categories:
File management. These programs create, delete, copy, rename, print, dump, list, and generally manipulate ﬁles 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. Others are more complex, providing detailed performance, logging, and debugging information. Typically, these programs format and print the output to the terminal or other output devices or ﬁles or display it in a window of the GUI. Some systems also support a registry, which is used to store and retrieve conﬁguration information.
File modiﬁcation. Several text editors may be available to create and modify the content of ﬁles stored on disk or other storage devices. There may also be special commands to search contents of ﬁles or perform transformations of the text.
Programming-language support. Compilers, assemblers, debuggers, and interpreters for common programming languages (such as C, C++, Java, and PERL) are often provided with the operating system or available as a separate download.
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 as well.
Communications. These programs provide the mechanism for creating virtual connections among processes, users, and computer systems. They allow users to send messages to one another’s screens, to browse Web pages, to send email messages, to log in remotely, or to transfer ﬁles from one machine to another.
Background services. All general-purpose systems have methods for launching certain system-program processes at boot time. Some of these processes terminate after completing their tasks, while others continue to run until the system is halted. Constantly running system-program processes are known as services, subsystems, or daemons.
Along with system programs, most operating systems are supplied with programs that are useful in solving common problems or performing common operations. Such application programs include Web browsers, word processors and text formatters, spreadsheets, database systems, compilers, plotting and statistical-analysis packages, and games.
The view of the operating system seen by most users is deﬁned by the application and system programs, rather than by the actual system calls. Consider a user’s PC. When a user’s computer is running the Mac OS X operating system, the user might see the GUI, featuring a mouse-and-windows interface. Alternatively, or even in one of the windows, the user might have a command-line UNIX shell. Both use the same set of system calls, but the system calls look different and act in different ways. Further confusing the user view, consider the user dual-booting from Mac OS X into Windows. Now the same user on the same hardware has two entirely different interfaces and two sets of applications using the same physical resources. On the same hardware, then, a user can be exposed to multiple user interfaces sequentially or concurrently.
An operating system provides the environment within which programs are executed. Internally, operating systems vary greatly in their makeup, since they are organized along many different lines. There are, however, many commonalities, which we consider in this section.
One of the most important aspects of operating systems is the ability to multiprogram. A single program cannot, in general, keep either the CPU or the I/O devices busy at all times. Single users frequently have multiple programs running. Multiprogramming increases CPU utilization by organizing jobs (code and data) so that the CPU always has one to execute.
The idea is as follows: The operating system keeps several jobs in memory simultaneously (Figure 9). Since, in general, main memory is too small to accommodate all jobs, the jobs are kept initially on the disk in the job pool. This pool consists of all processes residing on disk awaiting allocation of main memory.
The set of jobs in memory can be a subset of the jobs kept in the job pool. The operating system picks and begins to execute one of the jobs in memory. Eventually, the job may have to wait for some task, such as an I/O operation, to complete. In a non-multiprogrammed system, the CPU would sit idle. In a multiprogrammed system, the operating system simply switches to, and executes, another job. When that job needs to wait, the CPU switches to another job, and so on. Eventually, the ﬁrst job ﬁnishes waiting and gets the CPU back. As long as at least one job needs to execute, the CPU is never idle.
Memory Layout for a Multiprogrammed System
Figure 9. Memory Layout for a Multiprogrammed System
Multiprogrammed systems provide an environment in which the various system resources (for example, CPU, memory, and peripheral devices) are utilized effectively, but they do not provide for user interaction with the computer system. Time sharing (or multitasking) is a logical extension of multiprogramming. In time-sharing systems, the CPU executes multiple jobs by switching among them, but the switches occur so frequently that the users can interact with each program while it is running. Time sharing requires an interactive computer system, which provides direct communication between the user and the system. The user gives instructions to the operating system or to a program directly, using an input device such as a keyboard, mouse, touch pad, or touch screen, and waits for immediate results on an output device. Accordingly, the response time should be short—typically less than one second.
A time-shared operating system allows many users to share the computer simultaneously. Since each action or command in a time-shared system tends to be short, only a little CPU time is needed for each user. As the system switches rapidly from one user to the next, each user is given the impression that the entire computer system is dedicated to his use, even though it is being shared among many users.
A time-shared operating system uses CPU scheduling and multiprogramming to provide each user with a small portion of a time-shared computer. Each user has at least one separate program in memory. A program loaded into memory and executing is called a process. When a process executes, it typically executes for only a short time before it either ﬁnishes or needs to perform I/O. I/O may be interactive; that is, output goes to a display for the user, and input comes from a user keyboard, mouse, or other device. Since interactive I/O typically runs at “people speeds,” it may take a long time to complete. Input, for example, maybe bounded by the user’s typing speed; seven characters per second is fast for people but incredibly slow for computers. Rather than let the CPU sit idle as this interactive input takes place, the operating system will rapidly switch the CPU to the program of some other user.
Time sharing and multiprogramming require that several jobs be kept simultaneously in memory. If several jobs are ready to be brought into memory, and if there is not enough room for all of them, then the system must choose among them. Making this decision involves job scheduling. When the operating system selects a job from the job pool, it loads that job into memory for execution. Having several programs in memory at the same time requires some form of memory management. In addition, if several jobs are ready to run at the same time, the system must choose which job will run ﬁrst. Making this decision is CPU scheduling. Finally, running multiple jobs concurrently requires that their ability to affect one another be limited in all phases of the operating system, including process scheduling, disk storage, and memory management.
In a time-sharing system, the operating system must ensure reasonable response time. This goal is sometimes accomplished through swapping, whereby processes are swapped in and out of main memory to the disk. A more common method for ensuring reasonable response time is virtual memory, a technique that allows the execution of a process that is not completely in memory. The main advantage of the virtual-memory scheme is that it enables users to run programs that are larger than actual physical memory. Further, it abstracts main memory into a large, uniform array of storage, separating logical memory as viewed by the user from physical memory. This arrangement frees programmers from concern over memory-storage limitations.
To learn more about operating system services and structures, check the following sites:
Operating-Systems Structures at http://codex.cs.yale.edu/avi/os-book/OS8/os8c/slide-dir/PDF-dir/ch2.pdf
Operating-System Structures at http://www.just.edu.jo/~masadeh/mat/CS%20475/chapter3_Structure.pdf
OS Services at https://www.youtube.com/watch?v=Y8PiWge6Wkc
Operating Systems at https://www.youtube.com/watch?v=-dJEMhZ7z10
Operating System Structures at https://www.youtube.com/watch?v=kQ_Qb4TQ_6Y
Operating System Structures at https://www.youtube.com/watch?v=UxCiuctkKYo
Top 3 Worst and Best Operating System User Interfaces at https://www.youtube.com/watch?v=sYTOavWs6Aw
Operating Systems - Services at http://www.tutorialspoint.com/operating_system/os_services.htm
Operating-System Structure at http://faculty.salina.k-state.edu/tim/ossg/Introduction/struct.html
The services and functions provided by an operating system can be divided into two main categories. Describe the two categories, and discuss how they differ.
Describe in detail at least four types of system programs.
Describe in detail the advantages a time-shared operating system has over a non time-shared operating system.
SLP Assignment Expectations
Use information from the modular background readings as well as the given resources. Also, you could use any good quality resource you can find. Please cite all sources and provide a reference list at the end of your paper.
Length: 2–3 pages (excluding the title page and reference pages) and single-spaced.
The following items will be assessed in particular:
Your ability to consolidate ideas from reading materials and your understanding of the materials.
Your ability to write a report with strong argument.
Some in-text references to modular background readings.