Operating Systems - Operating-System Structures (Night Class)
Compiled
By: Aurelie A. Peralta
Operating-System Structures
An operating
system provides the environment within which programs are executed. Internally,
operating systems vary greatly in their makeup, being organized, along many different
lines. An operating system may be viewed from several vantage points. One is by
examining the services that it provides. Another is by looking at the interface
that it makes available to users and programmers. A third is by disassembling the
system into its components and their interconnections.
System Components
We can
create a system as large and complex as an operating system only by partitioning
it into smaller pieces. Each piece should be a well-delineated portion of the system,
with carefully defined inputs, outputs, and functions.
Process Management
A program
does nothing unless its instructions are executed by a CPU. A process
can be thought of as a program in execution, but its definition will broaden as we explore it further.
A time-shared user program such as a compiler is a process. A word-processing program
being run by an individual user on a PC is a process. A system task, such as sending
output to a printer, is also a process.
A process
needs certain resources - including CPU time, memory, files, and I/O devices - to accomplish its task. When the process terminates, the operating system will reclaim
any reusable resources.
We emphasize
that a program by itself is not a process; a program is a passive entity, such as
the contents of a file stored on disk, whereas a process is an active entity, with
a program counter specifying the next instruction to execute. The execution of a
process must be sequential. The CPU executes one instruction of the process after
another, until the process completes.
A process
is the unit of work in a system. Such a system consists of a
collection of processes,
some of which are operating-system processes and the rest of which are user processes.
All these processes can potentially execute concurrently.
The operating
system is responsible for the following activities in connection with process management:
1. Creating
and deleting both user and system processes
2. Suspending
and resuming processes
3. Providing
mechanisms for process synchronization
4. Providing
mechanisms for process communication
5. Providing
mechanisms for deadlock handling
Main-Memory Management
The main
memory is central to the operation of a modern computer system. Main memory is a
large array of words or bytes, ranging in size from hundreds of thousands to billions.
Each word or byte has its own address. Main memory is a repository of quickly accessible
data shared by the CPU and I/O devices.
For a program
to be executed, it must be mapped to absolute addresses and loaded into memory.
As the program
executes, it accesses program instructions and data from memory by
generating these absolute addresses. Eventually, the program terminates, its memory
space is declared available, and the next program can be loaded and executed.
The operating
system is responsible for the following activities in connection with memory management:
1. Keeping
track of which parts of memory are currently being used and by whom
2. Deciding
which processes are to be loaded into memory when memory space becomes available
3.
Allocating and deallocating memory space as needed
File Management
File management
is one of the most visible components of an operating system. Computers can store
information on several different types of physical media. Magnetic tape, magnetic
disk, and optical disk are the most common media.
For convenient
use of the computer system, the operating system provides a uniform logical view
of information storage. The operating system abstracts from the physical properties
of its storage devices to define a logical storage unit, the file. The operating
system maps files onto physical media, and accesses these files via the storage
devices.
A file
is a collection of related information defined by its creator.
The operating
system is responsible for the following activities in connection with file management:
1. Creating
and deleting files
2. Creating
and deleting directories
3. Supporting
primitives for manipulating files and directories
4. Mapping
files onto secondary storage
5. Backing
up files on stable storage media
I/O-System Management
One of
the purpose of an operating system is to hide the peculiarities of specific hardware
devices from the user. This is usually done through the use of an I/O subsystem
which is consists of the following:
1. A memory-management
component that includes buffering, caching, and spooling
2. A general
device-driver interface
3. Drivers
for specific hardware devices
Only the
device driver knows the peculiarities of the specific device to which it is assigned.
Secondary-Storage Management
Because
main memory is too small to accommodate all the data and programs, and because data
that it holds are lost when power is lost, the computer system must provide secondary
storage to back up main memory.
The operating
system is reponsible for the following activities in connection with disk management:
1. Free-space
management
2. Storage
allocation
3. Disk
Scheduling
Because
secondary storage is used frequently, it must be used efficiently. The entire speed
of operation of a computer may hinge on the speeds of the disk subsystem and of
the algorithms that manipulate that subsystem.
Networking
A distributed
system is a collection of processors that do not share memory, peripheral devices,
or a clock. The processors in the system are connected through a communication network,
which can be configured in a number of different ways. The communication-network
design must consider message routing and connection strategies, and the problems
of contention and security.
A distributed
system collects physically separate, possibly heterogeneous systems into a single
coherent system, providing the user with access to the various resources that the
system maintains. Access to shared resource allows computation speed up, increased
functionality, increased data availability, and enhanced reliability.
Protection System
If a computer
system has multiple users and allows the concurrent execution of multiple processes,
then the various processes must be protected from one another’s activities. For
that purpose, mechanisms ensure that the files, memory segments, CPU, and other
resources can be operated on by only those processes that have gained proper authorization
from the operating system.
Protection
is any mechanism for controlling the access of programs, processes, or users to
the resources defined by a computer system. This mechanism must provide means for
specification of the controls to be imposed and means for enforcement.
Protection
can improve reliability by detecting latent errors at the interfaces between component
subsystems.
Command-Interpreter System
One of
the most important systems programs for an operating system is the command interpreter,
which is the interface between the user and the operating system. Some operating
systems include the command interpreter in the kernel.
Many commands
are given to the operating system by control statements. A program sometimes called
control-card interpreter or command-line interpreter reads and interprets control
statements. It is often known as the shell.
The command
statements themselves deal with process creation and management, I/O handling, secondary-storage
management, main-memory management, file-system access, protection, and networking.
Operating-System Services
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 specific 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 programming task easier:
1. 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).
2. I/O
Operations: The operating system must provide a means to do I/O.
3. File-System
Manipulation: Programs need to read, write, create, and delete files by name.
4. Communications:
In many circumstances, one process needs to exchange information with another process.
Communications may be implemented via shared memory, or by the technique of message
passing, in which packets of information are moved between processes by the operating
system.
5. Error
Detection: The operating system constantly needs to be aware of possible errors.
For each type of error, the operating system should take the appropriate action
to ensure correct and consistent computing.
Another
set of operating-system functions exists not for helping the user, but for ensuring
the efficient operation of the system itself. Systems with multiple users can gain
efficiency by sharing the computer resources among the users.
1. Resource
Allocation: When multiple users are logged on the system or multiple jobs are running
at the same time, resources must be allocated to each of them.
2. Accounting:
We want to keep track of which users uses how many and which kinds of computer resources.
This record keeping may be used for accounting or simply or accumulating usage statistics.
3. Protection:
Protection involves ensuring that all access to system resources is controlled.
Security of the system from outsiders is also important.
System Calls
System
calls provide the interface between a process and the operating system. These calls
are generally available as assembly-language instructions, and they are usually
listed in the various manuals used by the assembly-language programmers.
Certain
system allow system calls to be made
directly from a higher-level language program,
in which case the calls normally resemble predefined function or subroutine calls.
As an example
of how system calls are used, consider writing a simple program to read data from
one file and to copy them to another file. The first input that the program will
need is the names of the two files: the input file and the output file. These names
can be specified in many ways, depending on the operating-system design. One approach
is for the program to ask the user for the names of the two files. In an interactive system, this approach will require a sequence of system calls, first to write a
prompting message on the screen, and then to read from the keyboard the characters
that define the two files. On mouse-based window-and-menu systems, a menu bar of
file names is usually displayed in a window. The user can then use the mouse to
select the source name, and a similar window can be opened for the destination name to be specified.
Most users
never see this level of detail, however. The run-time support system (the set of
functions built into libraries
included with a compiler) for most programming languages
provides a much simpler interface. Thus, most of the details of the operating system
interface are hidden from the programmer by the compiler and by the run-time support
package.
System
calls occur in different ways, depending on the computer in use. Often, more information
is required than simply the identity of the desired system call. The exact type
and amount of information vary according to the particular operating system and
call.
System
calls can be grouped roughly into five major categories: process control, file management,
device management, information maintenance, and communications.
Process Control
1. end,
abort
2. load,
execute
3. create
process, terminate process
4. get
process attributes, set process attributes
5. wait
for time
6. wait
event, signal event
7. allocate
and free memory
File Management
1. create
file, delete file
2. open,
close
3. read,
write, reposition
4. get
file attributes, set file attributes
Device
Management
1. request
device, release device
2. read,
write, reposition
3. get
device attributes, set device attributes
4. logically attach or detach devices
Information
Maintenance
1. get
time or date, set time or date
2. get
system data, set system data
3. get
process, file, or device attributes
4. set
process, file, or device attributes
Communications
1. create,
delete communication connection
2. send,
receive messages
3. transfer
status information
4. attach
or detach remote devices
System Programs
Another
aspect of a modern system is the collection of system programs. System programs
provide a convenient environment for program development and execution. Some of
them are simply user interfaces to system calls; others are considerably more complex.
They can be divided into these categories:
1. File
Management
2. Status
Information
3. File
Modification
4. Programming-language
support
5. Program
loading and execution
6. Communication
System Structure
System
structure refers to
the way the different components of an operating system are
interconnected and melded into a kernel.
1. Simple
structure - many commercial systems do not have a well-defined structures. Frequently,
such operating systems started as small, simple, and limited systems, and then grew
beyond their original scope. MS-DOS is an example of such a system.
2. Layered
approach - the modularization of a system can be done in many ways. One method is
the layered approach, in which operating system is broken up into a number of layers
or levels, each built on top of lower layers. The bottom layer is the hardware,
the highest layer is the user interface. The main advantage of the layered approach
is modularity.
3. Microkernels
- modularization of the kernel, this method structures the operating system by removing
all nonessential components from the kernel, and implementing them as system- and
user-level programs. The result is a smaller kernel. The main function of the microkernel
is to provide a communication facility between the client program and the various
services that are also running in user space.
Virtual Machines
Conceptually,
a computer system is made up of layers. The hardware is the lowest level in all
such systems. The kernel running at the next level uses the hardware instructions
to create a set of system calls for use by outer layers. The system programs above the kernel are therefore able to use either system calls or hardware instructions,
and in some ways these programs do not differentiate between these two. Thus, although
they are accessed differently, they both provide functionality that the program
can use to create
even more advanced functions. System programs, in turn, treat
the hardware and the system calls as though they were both at the same
level.
Some systems
carry this scheme a step further by allowing the system programs to be called easily
by the application programs. As before, although the system programs are at a level
higher than that of the other routines, the application programs may view everything
under them in the hierarchy as though the latter were part of the machine itself.
This layered approach is taken to its logical conclusion in the concept of a virtual
machine. The VM operating system of IBM systems is the best example of the virtual-machine
concept, because IBM pioneered the work in this area.
Java is
a very popular object-oriented language introduced by Sun Microsystems in late 1995.
In addition to a language specification and a large API Library, Java also provides
a specification for a Java virtual machine (JVM). The JVM is a specification for
an abstract computer. The JVM consists of a class loader, a class verifier, and
a Java interpreter that executes the architectural-neutral bytecodes.
System Design and Implementation
No complete
solutions to the design problems exist, but some approaches have been successful.
Design Goals
At the
highest level, the design of the system will be affected by the choice of hardware
and type of system: batch, time shared, single user, multiuser, distributed, real time, or general purpose.
Mechanisms and Policies
One important
principle is the separation of policy from mechanism. Mechanisms determine how to
do something while policies determine what will be done.
Implementation
Once an
operating system is designed, it must be implemented. Traditional operating systems
have been written in assembly language. Now, however, they are often written in
higher level languages such as C or C++.
Assignment:
Explain System Generation in Operating Systems.
Reference: Operating System Concepts by Silberschatz, Galvin, and Gagne, 2003