Operating system (2)
Operating system (2)
____________________________________________________________________________________
COMPUTER SYSTEM AND OPERATING SYSTEM OVERVIEW
Operating System is a set of programs that acts as an interface between the user
of computer and the hardware of computer. An OS makes a computer more convenient to
use. An OS allows the computer system resources to be used in efficient manner. An OS
should be constructed in such a way as to permit the effective development, testing and
introduction of new system function without interfering new services.
1. OS FUNCTIONS
1. User interface: Users interact with application programs and computer hardware
through a user interface. Almost all operating systems today provide a windows-
like Graphical
Command line interface (CLI), which uses text command. E.g., DOS, UNIX.
Command: copy file1 file2 (DOS)
cp file1 file2 (UNIX)
Batch Interface (BI), in which commands and directives to control those
commands are entered into files, and those files are executed.
Graphical User Interface (GUI), in which graphic objects called icons are used
to represent commonly used features. E.g, Windows-95,Windows-98, Windows-
xp, GNOME and KDE on LINUX.
2. Program development
OS provides services such as editors and debuggers to assist the programmer in
1
Page
creating programs. These services are in the form of utility programs that are
supplied with the OS (not part of OS) and are referred to as application program
development tools.
Operating Systems Unit – 1
____________________________________________________________________________________
3. Program execution
Executable program (instructions and data) must be loaded into main memory and
allocates all the resources required for the program to execute. The OS handles
these scheduling duties for the user.
Main Problems:
A user might sign up for an hour and finish in 45 minutes; this would result in wasted
computer processing time. On the other hand, the user might run into problems, not finish
in allotted time.
Setup time:
A single program, called a job, could involve loading the compiler plus source program
into memory, saving the compiled program (object code) and then loading and linking
together the object program and common functions. Each of these steps could involve
mounting and dismounting tapes or setting up card decks. Thus, a considerable amount
of time was spent just in setting the program to run.
Earlier computers were very expensive, so the wasted time due to scheduling and setup
time in serial processing was unacceptable. In simple batch, user need not have direct
interaction with the processor. A piece software known as MONITOR will be used as
operating system. Each program is constructed to branch back to monitor when it
completes processing, at which point the monitor automatically begins loading next
program.
3
Page
Operating Systems Unit – 1
____________________________________________________________________________________
Interrupt
Processing
Device
Drivers
Job Monitor
Sequencing
Command
language
Interpreter
User
Program
Area
Memory Layout for Resident Monitor
The monitor performs a scheduling function: A batch of jobs is queued up, and
jobs are executed as rapidly as possible, without intervening time. With each job,
instructions are included in a primitive form of Job Control Language (JCL).
$JOB
$FTN
Fortran Instructions
$LOAD
$RUN
Data
$END
$JOB indicates the beginning of the job. The monitor reads $FTN line and loads the
appropriate language compiler from its mass storage (usually tape). The compiler
converts source code into object code and stores it on tape. When monitor reads
$LOAD, it loads the object code into memory (in the place of compiler) and transfers
control to it.
4
Page
Operating Systems Unit – 1
____________________________________________________________________________________
Advantage:
Problems:
1) The speed of I/O device is very slow compared to speed of CPU and whenever job
goes for I/O the CPU will be idle. CPU utilization is very less.
2) Only one JOB (program) will be loaded into memory.
The speed of I/O device is very slow compared to speed of CPU. In simple batch systems
whenever job goes for I/O the CPU will be idle since only one job is loaded into memory.
In multi programmed batch systems more than one JOB is loaded into memory. When
one JOB needs to wait for I/O, the processor switches to other JOB, which is not waiting
for I/O.
In multiprogramming, more than one program lies in the memory. For example, we open
word, excel, access and other applications together but while we type in word other
applications such as excel and access are just present in main memory but they are not
performing any task or work.
In multiprogramming with two programs, If JOB A goes for I/O, CPU will automatically
goes for JOB B. If we observe the above figure, CPU utilization in multiprogramming
(fig: 2b) with two processes has increased compared to uniprogramming (Fig: 2a).
In multiprogramming with three programs, If JOB A goes for I/O, CPU will
automatically goes for JOB B and JOB B goes for I/O CPU runs JOB C. The CPU
utilization in multiprogramming with three programs has increased compared to
multiprogramming with two programs. So, CPU utilization and resource utilization
increases with the number of programs in main memory. 5
Page
Operating Systems Unit – 1
____________________________________________________________________________________
Advantages:
1) CPU utilization and resource utilization increases with number of programs in
memory.
Dis advantage:
1) The response time of a job depends upon the previous jobs submitted. So, we can’t
predict response time of a JOB.
2) It can’t be used for multiple interactive JOBs.
Time-Sharing Systems:
User can’t predict the response time of a job in multiprogramming batch system. In a
time-sharing system OS interleaving execution of each user program in a short quantum
time. In time-sharing multiple users simultaneously access system through terminals. The
6
Page
response time of a program depends upon the number of programs submitted prior it.
Operating Systems Unit – 1
____________________________________________________________________________________
OS
JOB 1
JOB 2
JOB 3
JOB 4
Memory
Assume all jobs are submitted at the same time and time slice for each job is 4msec. The
response time of a JOB 4 will be utmost 12 sec (3*4). If any prior job of JOB 4 goes for
I/O, the response time of JOB 4 will reduced.
As soon as job assigned to the processor CPU starts timer. Once the timer expires system
clock generates interrupt. At each clock interrupt, the OS regains control and could assign
processor to another JOB. This technique is known as time slicing.
Table: Batch multiprogramming versus Time Sharing.
Batch Multi programming Time sharing
Objective Maximize processor use Minimize response time
Source of directives to Job control language Command entered at the
operating system terminal
Interactive jobs Not suitable Suitable
Online Transaction Not Suitable Suitable
Processing
performance, higher availability, and greater scalability and lower operating costs.
Cluster architectures are in place today for applications that must provide continuous,
uninterrupted service.
Operating Systems Unit – 1
____________________________________________________________________________________
With redundancy designed in to all subsystems — processing, storage, network, cooling,
power — cluster architectures can offer various levels of reliability.
In addition, cluster architectures can be scaled smoothly to provide for increasing system
performance. System architects can aggregate machines of different capacities in clusters
of different sizes to target small, mid-size and very large system needs. Costs are reduced
because clustering exploits low-cost, high-performance hardware.
Moreover, a cluster of UNIX systems provides the same standard UNIX system
environment that is used for existing applications.
If a computer system has multiple users and allows the concurrent execution of
multiple processes, then access to data must be regulated. For that purpose, mechanisms
ensure that files, memory segments, CPU, and other resources can be operated on by only
those processes that have gained proper authorization from the operating system.
3. DISTRIBUTED SYSTEMS
Peer-to-peer model:
It is another model of distributed system. A network of personal computers, all nodes in
the system are considered peers and thus may act as either clients or servers - or both. A
node may request a service from another peer, or the node may in fact provide such a
service to other peers in the system. Peer-to-peer networks are less expensive than
client/server networks but less efficient when large amounts of data need to be
exchanged.
Node must join P2P network Registers its service with central lookup service on network,
or Broadcast request for service and respond to requests for service via discovery
protocol.
Multimedia Systems:
Most operating systems are designed to handle conventional data such as text files,
programs, word processing documents, and spread sheets. Multimedia data consist of
audio and video files as well as conventional files. These data differ from conventional
data in that multimedia data- such as frames of video – must be delivered (streamed)
according to certain time restrictions( for example 30 frames per second). The
multimedia applications are audio files such as MP3, DVD movies, video conferencing,
and short video clips of movie previews. Multimedia applications may also include live
web casts of speeches or sporting events. Multimedia applications often include a
combination of both audio and video.
Handheld Systems:
11
Handheld systems include personal digital assistants (PDAs), such as Palm and packet
PCs, and cellular telephones, many of which use special-purpose embedded operating
Page
systems. A handheld computing device has an operating system (OS), and can run
various types of application software, known as apps. Most handheld devices can also be
equipped with Wi-Fi, Bluetooth, and GPS capabilities that can allow connections to the
Operating Systems Unit – 1
____________________________________________________________________________________
Internet and other Bluetooth-capable devices, such as an automobile or a microphone
headset. A camera or media player feature for video or music files can also be typically
found on these devices along with a stable battery power source such as a lithium battery.
Some handheld devices use wireless technology, such as Bluetooth, remote access to e-
mail and web browsing.
Limitations:
Handheld systems will have very less memory compared to desktops. As a result, the
operating system and applications must manage memory efficiently. Most handheld
devices use smaller, slower processors that consume less power to avoid frequent
recharging of batteries. Very small size keyboards and monitors are user due to lack of
space.
Modern operating systems are large and complex. They must be engineered properly if it
is to function properly and be modified easily. Common approach is to partition the task
into small components rather than have one monolithic system.
Simple Structure:
Many commercial systems do not have well-defined structure. MS-DOS was originally
designed and implemented by few people who had no idea that it would become so
popular. It was written to provide the most functionality in the least space. So it was not
divided into modules carefully.
Application Programming
MS-DOS Drivers
In MS-DOS, the interface and level of functionality are not well separated. For instance,
application programs able to access the basic I/O routines to write directly to the display
and disk drives. Such freedom levels MS-DOS vulnerable to errant programs, causing
entire system to crashes.
UNIX consists of two separate parts: the kernel and system programs. Everything below
the system call interface and above the physical hardware is kernel. The kernel provides
memory management, file management, CPU scheduling and other operating system
functions through system calls. The monolithic structure (kernel) was difficult to
12
Layered Approach:
Operating systems can be broken into pieces that are smaller and more appropriate than
those allowed by the original MS-DOS system. The OS can then retain much greater
control over the computer and over the application that make use of that computer.
Implementers have more freedom in changing the inner workings of the system and in
creating modular operating systems.
The operating system is divided into a number of layers (levels), each built on top of
lower layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user
interface.
With modularity, layers are selected such that each uses functions (operations) and
services of only lower-level layers. For example, Layer M consist of data structures and
set of routines can be invoked by the layers above M, in turn, layer M can invoke
services of lower layers.
Microkernel’s Structure:
Benefits:
Easier to extend a microkernel
Operating Systems Unit – 1
____________________________________________________________________________________
Easier to port the operating system to new architectures
More reliable (less code is running in kernel mode)
Maintenance is generally easier. Patches can be tested in a separate instance, then
swapped in to take over a production instance.
Rapid development time, new software can be tested without having to reboot the kernel.
More secure
Disadvantages: Performance overhead of user space to kernel space communication.
The first release of windows-NT 4.0 micro kernel version gave less performance than
windows 95 monolithic version. Windows-xp architecture is more monolithic than
microkernel.
Modules:
The kernel has a set of core components and dynamically links in additional services
either during booting time or during run time.
Most modern operating systems implement kernel modules:
Uses object-oriented approach
Each core component is separate
Each talks to the others over known interfaces
Each is loadable as needed within the kernel
Overall, similar to layers but with more flexible
For example, the Solaris operating system structure is organized around core kernel with
seven types of loadable kernel modules as shown in the above figure. Such a design
allows the kernel to provide core services yet also allows certain features to be
implemented dynamically. For example, device and bus drivers for specific hardware can
be added to kernel, and support for different file systems can be added as loadable
modules.
This approach is like the microkernel approach in that the primary module has only core
15
functions and knowledge of how to load and communicate with other modules; but it is
more efficient, because modules do not need to invoke message passing in order to
Page
communicate.
Operating Systems Unit – 1
____________________________________________________________________________________
Under what circumstances would a user be better of using a time-sharing system rather
than a PC or single-user workstation?
When there are few other users, the task is large, and the hardware is fast, timesharing
make sense. The full power of the system can be brought to bear on the pser’s problem.
The problem can be solved faster than on a personal computer. Another case occurs when
lots of other users need resources at the same time.
For example, an organization generates 1000 transactions per day. A user can enter 100
transactions per day. Then we recommend for time sharing system.
A personal computer is best when the job is small enough to be executed reasonably on it
and when performance is sufficient to execute the program to the user’s satisfaction.
6. SYSTEM CALLS
The interface between operating system and user programs is defined by the set of
system calls that operating system provides. The system calls available in the interface
vary from operating system to operating system. The system call is called by programmer
whenever services are required from OS.
The process starts running in user mode. As soon as system call is called it changes from
user mode to kernel mode. The mode bit specifies the process running in user
mode(mode bit=1) or kernel(mode bit=0) mode.
Open file1.c
Create file2.c
Loop
Read from file1.c
Write to file2.c
Until end of file1.c
Close file1.c
Close file2.c
16
Page
Example how system calls are used in copy contents from file1.c to file2.c
File Management
Create file, delete file( create)
Open, close (open, close)
Read, write, reposition (read, write, seek)
Get file attributes, set file attributes
Device management
Request device request device, release device
Read, write, reposition
Get device attributes, set device attributes
Logically attach or detach devices
Information maintenance
Get time or date(date), set time or date
Get system date, set system date
Get process, file, or device attributes
set process, file, or device attributes
Communication
create, delete communication connection
send, receive message
18
Each operating system has its own name for each system call. The portability of
application increases with the use of API rather than system call.
19
Page
Operating Systems Unit – 1
____________________________________________________________________________________
7. OPERATING-SYSTEM GENERATION
Operating systems are designed to run on any of a class of machines at a variety of
sites with a variety of peripheral configurations. The system must then be configured or
generated for each specific computer site, a process sometimes known as system
generation (SYSGEN).
The operating system is normally distributed on disk or CD-ROM. The SYSGEN
program reads from a given file, or asks the operator of the system for information
concerning the specific configuration of the hardware system, or probes the hardware
directly to determine what components are there. The following kinds of information
must be determined.
• What CPU is to be used? What options (extended instruction sets, floating point
arithmetic, and so on) are installed? For multiple CPU systems, each CPU must be
described.
• How much memory is available? Some systems will determine this value themselves by
referencing memory location after memory location until an "illegal address" fault is
generated. This procedure defines the final legal address and hence the amount of
available memory.
• What devices are available? The system will need to know how to address each device
(the device number), the device interrupt number, the device's type and model, and any
special device characteristics.
• What operating-system options are desired, or what parameter values are to be used?
These options or values might include how many buffers of which sizes should be used,
what type of CPU-scheduling algorithm is desired, what the maximum number of
processes to be supported is, and so on.
20
Page