You are on page 1of 27

AN

INTRODUCTION
TO OPERATING
SYSTEMS

Lecture 1
Dr. Subhi A.Rahim
Bahudaila OS
Operating System Objectives
2 Lecture 1

CONVENIENCE:
An operating system makes a computer more convenient to
use.

EFFICIENCY:
It allows the computer system resources to be used in an
efficient manner.

ABILITY TO EVOLVE: It should have the capability to


permit the effective development, testing & introduction of
new system functions.
The Operating System as a User /
Computer Interface
3 Lecture 1
Operating System Functions
4 Lecture 1

 PROGRAM CREATION:
Operating system provides a number of facilities & services to
assist the programmer during development of a program like
“editor & debugger”. These programs normally exist in the form
of a utility program. Such programs are not part of the o/s rather
they are accessible through the o/s.

 PROGRAM EXECUTION:
When a program is to be executed, a number of tasks like
instructions & data loading into memory, I/O operation & file
initialization are to be executed. The o/s performs all these jobs
for the user.
 OS Functions
5 Lecture 1

 ACCESS TO I/O DEVICES: Each I/O devices requires its own set of
instructions or control signals for operations. The o/s takes care of all
these requirements and the user only thinks in terms of reading/writing, all
those details are hidden from the user.
 CONTROLLED ACCESS TO FILES: In the case of files, control must
include to understand the nature of the I/O devices like FD, HD & CD and
also the format on the storage medium. Again o/s provides all such
controls but these are transparent to the user. Furthermore in a multi-user
system o/s provides a protection mechanisms to access any file.
 OS Functions
6 Lecture 1

 SYSTEM ACCESS / PROTECTION: In the case of a shared or public system


the o/s takes control of the whole system as well as the system resources. The
reason being o/s has to provide protection to the data & resources from any
unauthorized user and also to resolve conflicts when more than one user is
competing for a resource.
 ERROR DETECTION: During the execution of a program different errors can
be encountered e.g., insufficient memory, device failure, arithmetic overflow & a
program accessing a protected area etc. Typical o/s takes care of all these
problems and respond to clear these errors without disturbing normal functioning
of the system. But in some cases it may have to terminate the application.
 ACCOUNTING: A good OS will collect usage statistics for various resources
and monitor performance parameters such as response time. On any system, this
information is useful in anticipating the need for future enhancements and in
tuning the system to improve performance. On a multiuser system, the
information can be used for billing purposes.
OS Characteristics
7 Lecture 1

CONCURRENCY: Concurrency means the existence of several


simultaneous or parallel activities. For example overlapping of I/O
operations with computation or coexistence of several programs in the
memory. Concurrency raises problems of switching from one activity to
another, of protecting one activity against the effect of another &
synchronization of activities which are mutually dependent.
SHARING: Concurrent activities required to share resources or
information. The motivation of sharing is four fold as follows:
• COST: It is probably expensive to provide each user for example in a
multi-user system to provide all the resources separately.
• SHARING DATA: It may be a necessity requirement to use the same
database for several different programs, possibly working for several
different users. • BUILDING ON OTHERS WORK: It is useful to
utilize previously developed work/routines/programs as an advantage of
being proven & tested piece of work.
 OS Characteristics
8 Lecture 1

• REMOVING REDUNDENCY: It is economical to share a single copy


of programs e.g., compiler between several users, rather than providing a
separate copy for each user. The associated problems with sharing are
resource allocation, simultaneous access to data & execution of program
& protection against corruption.
NON-DETERMINACY: An operating system must be deterministic in the
sense that same program run today or tomorrow with the same data
should produce the same result. On the other hand it must not be
deterministic in the sense that it must be able to respond to events which
occurs in the unpredictable order. These events could be resource
request, run time error in the program or interrupts.
LONG TERM USE: Long term storage allows a user the convenience of
keeping his programs or data in the computer rather than on some
external medium, which of course is also possible.
Desirable Features of an OS
9 Lecture 1

EFFICIENCY: The need of efficiency in any system is a must, it is


perhaps difficult to have a single word of judgment to indicate the
efficiency of a system. In fact there are various factors which
determines the efficiency of an operating system.
- Mean time between jobs/processes. - Unused CPU time. - Turn
round time for batch jobs (Time between job submission &
completion). - Response time - Resource utilization
-Throughput (jobs/time)
It must be noted that a system satisfying all the above listed factors will
represent an ideal system, but in reality there are compromises among
these factors.
RELIABILITY: Ideally an operating system must be completely error
free & should be able to handle all contingencies, but we know in
practice this is not always true.
 Desirable Features of an OS
10 Lecture 1

MAINTAINABILITY: A good operating system should be able to


enhance its capabilities & rectify its errors if required without
employing an army of system programmers. The operating system
must be modular in construction, with clearly defined interface
between modules and should be well documented.

SMALL SIZE: Space used to hold the operating system whether in


main memory or hard disk must be of reasonable size. Further more a
larger system is liable to be more error prone and requires obviously
more time to write etc.
OS as a Resource Manager
11 Lecture 1

 Computer System is a collection of resources.


 O/S manage these resources.
 Function wise any ordinary software program and an o/s are
similar in nature.
 The distinctive feature is the intent:
 o/s commands the processor in using computer system
resources and timing of its execution.
 In doing so it stops its own execution.

 Meaning it relinquishes control of the processor to do some


productive thing and subsequently resume control of the
processor for another task.
 OS as a Resource Manager
12 Lecture 1

 Memory is the resource of an operating system.


 Memory contains the operating system, as a nucleus
containing the most frequently used functions.
 Rest of the memory contains program and data.
 Utilization (allocation) of the memory resource is
controlled by o/s and the memory management hardware in
the processor.
 Processor is also a resource of o/s.
 Processor utilization is controlled by the o/s for different
programs.
 I/O devices are also resources and o/s decides which and
when to use these devices.
 OS as a Resource Manager
13 Lecture 1
Uni-Programming Vs Multi-Programming
14 Lecture 1
 Resource Utilization Example
15 Lecture 1
 The Results
16 Lecture 1
System Structure
17 Lecture 1

Operating system complexity has grown with its advancement.


Any operating system can suffer from the following 3 components:
 O/S chronically late in delivery.
 Bugs show up after its operation in the field.
 Performance is not that great which is expected.
So, focus has been on the structure of the operating system as:
 Modular .
 Hierarchical Layer; which is a function of o/s complexity, time
scale and level of abstraction. All of the above can be viewed as
different levels: 1) Each level performs a related subset of
functions. 2) Each levels relies on the adjacent lower level to
perform. 3) Ideally changes in one level may not effect the next
level. 4) Problem is partitioned into more manageable
components.
 Hierarchy Design
18 Lecture 1
Required Characteristics of a Modern O/S
19 Lecture 1

Modification or enhancement to the existing architecture has not been enough to


cope with the rate of change of o/s structure. Following are the main categories
typically, required for a modern day o/s:

1. Micro-kernel structure

It assigns only a few essential functions to the kernel, including address


spaces, interprocess communication (IPC), and basic scheduling. Other
OS services are provided by processes, sometimes called servers, that
run in user mode.
This approach simplifies implementation, provides flexibility, and is
well suited to a distributed environment. In essence, a microkernel
interacts with local and remote server processes in the same way,
facilitating construction of distributed systems.
 Required Characteristics of a Modern O/S
20 Lecture 1

2. Multi-threading:
• In this case a process is created out of an existing process called thread and
both can run simutaneously.
• Thread is a dispatchable unit of work, it execute sequentially and
interruptable.
• Process could be collection of threads.
3. Symmetric Multi-processing:
• More then one processor may be present in the system.
• This means incremental growth is possible by adding more processors.
• It improves performance.
• It brings fault tolerence to the system.
• Scaling: vendors can provide different degrees of selection based on the
number of processors capability present in the system.
4. Distributed operating system
• This type of setup gives the illusion of a single memory space, clusters are
becoming increasingly popular.
• But still cannot match uni-processor and SMP operating systems.
Modern Unix Systems
21 Lecture 1

Typical of the
modern UNIX kernel
is the architecture
depicted in the
Figure. There is a
small core of
facilities, that
provide functions
and services needed
by a number of OS
processes. Each of
the outer circles
represents functions
and an interface that
may be implemented
in a variety of ways
 Examples of modern UNIX systems
22 Lecture 1

•System V Release 4 (SVR4): New features in the release include real-


time processing support, process scheduling classes, dynamically
allocated data structures, virtual memory management, virtual file
system, and a preemptive kernel.
•Solaris 10: Solaris provides all of the features of SVR4 plus a number of
more advanced features, such as a fully preemptable, multithreaded
kernel, full support for SMP, and an object oriented interface to file
systems. Solaris is the most widely used and most successful commercial
UNIX implementation. SVR4 runs on processors ranging from 32-bit
microprocessors up to supercomputers.
•Linux: Linux is free and the source code is available, it became an early
alternative to other UNIX workstations, such as those offered by Sun
Microsystems and IBM. Today, Linux is a full-featured UNIX system
that runs on all of these platforms and more, including Intel Pentium and
Itanium, and the Motorola/IBM PowerPC.
Linux Kernel Components
23 Lecture 1

the principal kernel components are the following:


• Signals: The kernel uses signals to call into a process. For example, signals are used to
notify a process of certain faults, such as division by zero. • System calls: The system call
is the means by which a process requests a specific kernel service. There are several hundred
system calls, which can be roughly grouped into six categories: filesystem, process,
scheduling, interprocess communication, socket (networking), and miscellaneous.
• Processes and scheduler: Creates, manages, and schedules processes. • Virtual memory:
Allocates and manages virtual memory for processes. • File systems: Provides a global,
hierarchical namespace for files, directories, and provides file system functions.
• Network protocols: Supports the Sockets interface to users for the TCP/IP protocol suite.
• Character device drivers: Manages devices that require the kernel to send or receive data
one byte at a time, such as terminals, modems, and printers. • Block device drivers:
Manages devices that read and write data in blocks, such as various forms of secondary
memory (magnetic disks, CD-ROMs, etc.). • Network device drivers: Manages network
interface cards and communications ports that connect to network devices, such as bridges
and routers. • Traps and faults: Handles traps and faults generated by the processor, such
as a memory fault. • Physical memory: Manages the pool of page frames in real memory
and allocates pages for virtual memory. • Interrupts: Handles interrupts from peripheral
devices.
24 Lecture 1
 Examples of Read System Call
Count = read( fd, buffer, nbytes );
25 Lecture 1

System calls are performed in a series of steps:


Step 1-3 The calling program 1st pushes the parameters onto the stack.
Step 4 The actual library procedure call is occurring.
26 Step 5 The library procedure, possibly written in assembly language,
typically puts the system call number in a place where the OS
expects it, such as a register.
Step 6 a TRAP instruction is executed to switch from user mode to
kernel mode & start execution at a fixed address with in the
kernel.
Step 7 The kernel code examines the system call number & then
dispatches to the correct system call handler.
Step 8 At that point the system call handler runs.
Step 9 Once the system call handler has completed its work, control
may be return to the user-space library procedure at the
instruction following the TRAP instruction.
Step 10 This procedure then returns to the user program in the usual
way procedure calls return.
Step 11 To finish the Job, the user program has to clean up the stack.
References
27 Lecture 1

William Stallings, "Operating Systems:


Internals and design Principles 7th Edition",
(c) Pearson Prentice Hall 2012.
 Chapter 2. Operating System Overview

© Dr. Subhi Bahudaila

You might also like