Chapter 02 - System Structures

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 30

Operating System Principles

Abraham Silberschatz, Peter Baer Galvin and Greg Gagne

Submitted to: Bryan T. Urita Instructor

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.

2.3 System Calls


System calls provide an interface to the services made available by an operating system. The se calls are generally available as routines written in C and C++, although certain low-level tasks (for example, tasks where hardware must be accessed directly), may need to be written using assembly-language instructions.

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

Figure 2.1 Example of how system calls are used.

user application
open ( ) user mode kernel mode

system call interface


open ( ) Implementation of open ( ) system call return

Figure 2.2 The handling of a user application invoking the open() system call.

X register

X: parameters for call


load address X system call 13
use parameters from table X

code for system call 13

Figure 2.3 Passing of parameters as the table.

2.4 Types of System Calls


System calls can be grouped roughly into five major categories: process control, file manipulation, device manipulation, information maintenance, and communications. Figure 2.4 Types of system calls.

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 command interpreter


kernel

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.

Figure 2.6 FreeBSD running multiple programs.

2.4.2 File Management


We first need to be able to create and delete files. Either system call requires the name of the file and perhaps some of the files attributes. Once the file is created, we need to open it and to use it. We may also read, write, or reposition. 2.4.3 Device Management

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.

2.5 System Programs


Categories: File management Status information File modification

Programming-language support Program loading and execution Communications


System utilities or Application programs programs include web browsers, word processors and text formatters, spreadsheets, data base systems, compliers, plotting and statistical-analysis packages, and games.

2.6 Operating-System Design and Implementation


Problems we face in designing and implementing an operating system.

2.6.1 Design goals


The first problem in designing a system is to define goals and specifications. At the highest level, the design of the system will be affected by the choice of hardware and the type of system: batch, time shared, single user, multiuser, distributed, real time, or general purposes. 2.6.2 Mechanisms and Policies

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

higher level languages such as C or C++.

2.7 Operating-System Structure


A system as large and complex as a modern operating system must be engineered carefully if it is to function properly and be modified easily. 2.7.1 Simple Structure
Operating systems started as small, simple, and limited systems and then grew beyond their original scope. MS-DOS is an example of such system. It was originally designed and implemented b a few people who had no idea that it would become so popular. It was written to provide the most functionality in

Figure 2.7 MS-DOS layer structure

2.7.2 Layered Approach


With proper hardware support, operating systems can be broken into pieces that are smaller and more appropriate than those allowed by the original MS-DOS or UNIX systems.
(the users) shells and commands compilers and interpreters system libraries system-call interface to the kernel signals terminal handling character I/O system terminal drivers terminal controllers terminals file system swapping block I/O system disk and tape drivers device controllers disks and tapes CPU scheduling page replacement demand paging virtual memory memory controllers physical memory

kernel interface to the hardware

Figure 2.8 UNIX system structure.

layer N user interface


layer 1

layer 0 hardware

Figure 2.9 A layered operating system.

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

loadable system calls

STREAMS modules

executable formats

Figure 2.10 Solaris loadable modules.

application environments and common services

kernel environment

BSD

March
Figure 2.11 The Mac OS X structure.

2.8 Virtual Machines


The fundamental idea behind a virtual machine is to abstract the hardware of a single computer (the CPU, memory, disk drivers, network interface cards, and so forth) into several different

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

Figure 2.13 Vmware architecture.

2.8.3.2 The Java Virtual Machine


Java is a popular object-oriented programming language introduced be Sun Microsystems in 1995. In addition to a language specification for a Java virtual machine-or JVM.
Java program class files Java API class files

class loader

Java interpreter

host system (Windows, Linux, etc.)


Figure 2.14 The Java virtual machine.

2.9 Operating-System Generation


It is possible to design, code, and implement an operating system specifically for one machine at one site. The system must then be configured or generated for each specific computer site, a process sometimes known as system generation (SYSGEN).

2.10 System Boot


After an operating system is generated, it must be made available for use by the hardware. The procedure of starting a computer by loading the kernel in known as booting the system. On most computer systems, a small piece of code known as the bootstrap program or bootstrap loader locates the kernel, loads it into main memory, and starts its execution.

*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.

You might also like