Professional Documents
Culture Documents
Chapter 02 - System Structures
Chapter 02 - System Structures
Chapter 02 - System Structures
An operating system provides an environment for the execution of programs. One set of operating-system services provides functions that are helpful to the user. User interface. Almost all operating systems have user interface (UI). This interface take several forms.
One is command-line interface (CLI), which uses text commands and a method for entering them (say, a program to allow entering and editing of commands). Another is batch interface, in which commands and directives to control those commands are entered into files, and those files are executed. Most commonly, a graphical user interface (GUI) is used.
Program execution. The system must be able to load a program into memory and to run that program.
I/O operations. A running program may require I/O, which may involve a file or an I/O device. File-system manipulation. The file system is of particular interest. Communications. There are many circumstances in which one process needs to exchange information with another process. Error detection. The operating system needs to be constantly aware of possible errors. Resource allocation. When there are multiple users of multiple jobs running at the same time, resources must be allocated to each of them.
Accounting. We want to keep track of which users use how much and what kinds of computer resources. Protection and security. The owners of information stored in a multiuser networked computer system may want to control use of that information.
There are two fundamental approaches for users to interface with the operating system. On technique is to provide a command-line interface or command interpreter that allows users to directly enter commands that are to be performed by the operating system. The second approach allows the user to interface with the operating system via a graphical user interface or GUI.
2.2.1 Command Interpreter The main function of the command interpreter is to get and execute the next user-specified command. There are two general ways in which these commands can be implemented. In one approach, the command interpreter itself contains the code to execute the command. An alternative approach used by UNIX, among the other operating systems implements most commands through system programs. The INIX command to delete a file rm file.txt 2.2.2 Graphical User Interfaces A GUI provides a desktop metaphor where the mouse is moved to position its pointer on images, or icons, on the screen (the desktop) that represent programs, files, directories, and system functions. Depending on the mouse pointers location,
clicking a button on the mouse can invoke program, select a file or directory known as a folder or pull down a menu that contains commands.
source file
Example System Call Sequence Acquire input file name Write prompt to screen Accept input Acquire output file name Write prompt to screen Accept input Open the input file if file doesnt exist, abort Create output file if file exist, abort Loop Read from input file Write output file Until read fails Close output file Write completion message to screen Terminate normally
destination file
user application
open ( ) user mode kernel mode
Figure 2.2 The handling of a user application invoking the open() system call.
X register
Process control
o
end, abort o load, execute o create process, terminate process o get process attributes, set process attributes o wait for time o wait event, signal event o allocate and free memory
File Management
create file, delete file o open, close o read, write, reposition o get file attributes, set file attributes Device Management o request device, release device o read, write, reposition o get device attributes, set device attributes o logically attach or detach devices Information Maintenance
o
get time or date, set time or date o get system data, set system data o get process, file, or device attributes o set process, file, or device attributes
o
Communications
o o o o create, delete communication connection send, receive messages transfer status information attach or detach remote devices
2. 4.1 Process Control A running program needs to be able to halt its execution either normally (end) or abnormally (abort). * Debugger a system program designed to aid the programmer in finding and correcting bugs to determine the cause of the problem. * A control card is a batch system concept. It is a command to manage the execution of a process.
free memory
Free memory
process D
free memory
process C
interpreter
command interpreter
kernel
process B
kernel
(a)
(b)
Figure 2.5 MS-DOS execution. (a) At system startup. (b) Running a program.
A process may nee several resources to execute main memory, disk drives, access to files, and so on.
2.4.4 Information Maintenance Many system calls exist simply for the purpose of transferring information between the user program and the operating system.
2.4.5 Communication
There are two common models of interprocess communication: the message-passing model and the shared-memory model. Message-passing model the communicating process exchange message with one another to transfer information. Shared-memory model processes use shared memory create and shared memory attach system calls to create and gain access to regions of memory owned by other processes.
One important principle is the separation of policy from mechanism. Mechanism s determine how to d something; policies determine what will be done.
2.6.3 Implementation Once an operating system is designed, it must be implemented. Traditionally, operating systems have been written in assembly language. Now, however, they are most commonly written in
layer 1
layer 0 hardware
2.7.3 Microkernels
We have already seen that as UNIX expanded, the kernel became large and difficult to manage. In the mid-1980s, researchers at Carnegie Mellon University developed an operating system called March that modularized the kernel using the microkernel approach. 2.7.4 Modules
Perhaps the best current methodology for operating-system design involves using object-oriented programming techniques to create a modular kernel. The Solaris operating system structure is organized around a core kernel with seven types of loadable kernel with seven types of loadable kernel modules: 1. Scheduling classes 5. STREAMS modules 2. File systems 6. Miscellaneous 3. Loadable system calls 7. Device and bus drivers 4. Executable formats
scheduling classes
device and bus drivers core Solaris kernel
file systems
Miscellaneous modulas
STREAMS modules
executable formats
kernel environment
BSD
March
Figure 2.11 The Mac OS X structure.
executions environments, thereby creating the illusion that each separate execution environment is running its own private computer.
processes processes
processes kernel
VM 1
processes
kernel
VM 1
kernel
VM 1
kernel hardware
(a)
virtual-machine implementation
hardware
(b)
Figure 2.12 System models. (a) nonvirtual machine. (b) Virtual machine.
2.8.1 Implementation
Although the virtual-machine concept is useful, it is difficult to implement. Much work is required to provide an exact duplicate of the underlying machine. 2.8.1 Benefits The virtual-machine concept has several advantages. Each virtual machine is completely isolated from all other virtual machines, so there are no protection problems. 2.8.3 Examples
Despite the advantages of virtual machines, they received little attention for a number of years after they were first developed. Virtual machines are coming back into fashion as means of solving system compatibility problems.
2.8.3.1 Vmware
Vmware is a popular commercial application that abstracts Intel 80X86 hardware into isolated virtual machines.
application application
guest operating system (free BSD) virtual CPU virtual memory virtual devices
application
guest operating system (Windows NT) virtual CPU virtual memory virtual devices
application
guest operating system (Windows XP) virtual CPU virtual memory virtual devices
virtualization layer
host operating system (Linux)
hardware
CPU memory I/O devices
class loader
Java interpreter
*Read-Only Memory (ROM) it needs no initialization and cannot be infected by a computer virus.
*Erasable Programmable Read-Only Memory (EPROM) read only except when explicitly given a command to become writable. *All forms of ROM are also known as firmware.
*A disk that has a boot partition is called a boot disk or system disk.