OS Part 3
OS Part 3
An operating system provides services to programs and to the users of those programs. It
provided by one environment for the execution of programs. Operating system makes the
programming task easier.
The common service provided by the operating system is listed below.
1. User Interface
2. Program execution
3. I/O operation
4. File system manipulation
5. Communications
6. Error detection
7. Resource allocation
8. Accounting
9. Protection and Security
1. 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 specific format
with specific options). Another is a 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. 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.
2. Program execution:
The purpose of computer system is to allow the users to execute programs in an
efficient manner. The operating system provides an environment where the user can
conveniently run these programs. To run a program, the program is required to be
loaded into the RAM first and then to assign CPU time for its execution. Operating
system performs this function for the convenience of the user.
3. I/O operation:
Each program requires an input and after processing the input submitted by user it
produces output. This involves the use of I/O devices. The operating system hides the
user from all these details of underlying hardware for the I/O. So the operating system
makes the users convenient to run programs by providing I/O functions. The I/O service
cannot be provided by user-level programs and it must be provided by the operating
system.
1. Simple Structure:
There are many operating systems that have a rather simple structure. These started as small
systems and rapidly expanded much further than their scope. A common example of this is
MS-DOS. It was designed simply for a niche amount for people. There was no indication that
it would become so popular.
When DOS was originally written, its developers had no idea how big and important it would
eventually become. It was written by a few programmers in a relative short amount of time
without the benefits of modern software engineering techniques and then gradually grew over
time to exceed its original expectations.
2. Monolithic Approach:
Functionality of the OS is invoked with simple function calls within the kernel,
which is one large program.
Device drivers are loaded into the running kernel and become part of the kernel.
Figure: A Monolithic Kernel, such as Linux or other Unix systems
3. Layered Structure:
This approach breaks up the operating system into different layers.
This allows implementers to change the inner workings, and increases modularity.
As long as the external interface of the routines doesn’t change, developers have more
freedom to change the inner workings of the routines.
With the layered approach, the bottom layer is the hardware, while the highest layer is
the user interface.
o The main advantage is simplicity of construction and debugging.
o The main difficulty is defining the various layers.
o The main disadvantage is that the OS tends to be less efficient than other
implementations.
4. Microkernel:
This structures the operating system by removing all nonessential portions of the kernel and
implementing them as system and user level programs.
Generally they provide minimal process and memory management, and a
communications facility.
Communication between components of the OS is provided by message passing.
The benefits of the microkernel are as follows:
Extending the operating system becomes much easier.
Any changes to the kernel tend to be fewer, since the kernel is smaller.
The microkernel also provides more security and reliability.
Main disadvantage is poor performance due to increased system overhead from message
passing.
System Calls:
System calls provide an interface to the services made available by an operating system.
Program passes relevant information to OS.
System calls are typically written in C and C++.
The mechanism used by an application program to request service from the operating
system.
System calls often use a special machine code instruction which causes the processor
to change mode (e.g. to "supervisor mode" or "protected mode").
This allows the OS to perform restricted actions such as accessing hardware devices or
the memory management unit.
Types of System Calls:
System calls can be grouped roughly into five major categories: process control, file
manipulation, device manipulation, information maintenance, and communications.
Process control:
A running program needs to be able to halt its execution either normally (end) or
abnormally (abort). If a system call is made to terminate the currently running
program abnormally, or if the program runs into a problem and causes an error trap,
a dump of memory is sometimes taken and an error message generated. The dump
is written to disk and may be examined by a debugger—a system program designed
to aid the programmer in finding and correcting bugs-—to determine the cause of
the problem. Under either normal or abnormal circumstances, the operating system
must transfer control to the invoking command interpreter. The command
interpreter then reads the next command. In an interactive system, the command
interpreter simply continues with the next command; it is assumed that the user will
issue an appropriate command to respond to any error. In a GUI system, a pop-up
window might alert the user to the error and ask for guidance. In a batch system,
the command interpreter usually terminates the entire job and continues with the
next job.
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 manipulation:
o create file, delete file
o open, close
o read, write, reposition
o get file attributes, set file attributes
Device manipulation:
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
Communication:
o create, delete communication connection
o send, receive messages
o transfer status information
o attach or detach remote devices
System Programs:
Another aspect of a modern system is the collection of system programs. At the lowest level is
hardware. Next is the operating system, then the system programs, and finally the application
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:
File management
These programs create, delete, copy, rename, print, dump, list, and generally
manipulate files 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
pro- grams format and print the output to the terminal or other output devices or files
or display it in a window of the GUI. Some systems also support a registry, which is
used to store and retrieve configuration information.
File modification
Several text editors may be available to create and modify the content of files stored
on disk or other storage devices. There may also be special commands to search
contents of files or perform transformations of the text.
Programming-language support
Compilers, assemblers, debuggers and interpreters for common programming
languages (such as C, C++, Java, Visual Basic, and PERL) are often provided to the
user with the operating system.
Program loading and execution
Once a program is assembled or com- piled, 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 electronic-mail messages, to log in
remotely, or to transfer files from one machine to another.
Virtual Machine:
The fundamental idea behind a virtual machine is to abstract the hardware of a single
computer (the CPU, memory, disk drives, network interface cards, and so forth) into several
different execution environments, thereby creating the illusion that each separate execution
environment is running its own private computer.
There are several reasons for creating a virtual machine, all of which are fundamentally
related to being able to share the same hardware yet run several different execution
environments (that is, different operating systems) concurrently.
A major difficulty with the virtual-machine approach involves disk systems. Suppose that
the physical machine has three disk drives but wants to support seven virtual machines. Clearly,
it cannot allocate a disk drive to each virtual machine, because the virtual-machine software
itself will need substantial disk space to provide virtual memory and spooling. The solution is
to provide virtual disks—termed minidisks in IBM's VM operating system —that are identical
in all respects except size. The system implements each minidisk by allocating as many tracks
on the physical disks as the minidisk needs. Obviously, the sum of the sizes of all minidisks
must be smaller than the size of the physical disk space available.