You are on page 1of 49

Operating Systems [BCS303] Module - 1

MODULE – 1
INTRODUCTION TO OPERATING SYSTEM

What is an Operating System?


An operating system is system software that acts as an intermediary between a user of a computer and
the computer hardware. It is software that manages the computer hardware. Operating system allows
the user to execute programs in a convenient and efficient manner.

Operating system goals:


• Make the computer system convenient to use. It hides the difficulty in managing the hardware.
• Use the computer hardware in an efficient manner
• Provide and environment in which user can easily interface with computer.
• It is a resource allocator

Computer System Structure (Components of Computer System)


Computer system mainly consists of four components-
• Hardware – provides basic computing resources

Dept. of AIML, VCET Puttur 1


Operating Systems [BCS303] Module - 1

✓ CPU, memory, I/O devices


• Operating system
✓ Controls and coordinates use of hardware among various applications and users
• Application programs – define the ways in which the system resources are used to solve the
computing problems of the users
✓ Word processors, compilers, web browsers, database systems, video games
• Users
✓ People, machines, other computers

The basic hardware components comprises of CPU, memory, I/O devices. The application
program uses these components. The OS controls and co-ordinates the use of hardware, among
various application programs (like compiler, word processor etc.) for various users. The OS allocates
the resources among the programs such that the hardware is efficiently used. The operating system is
the program running at all the times on the computer. It is usually called as the kernel.

Kernel functions are used always in system, so always stored in memory. Non kernel functions are
stored in hard disk, and it is retrieved whenever required.

Dept. of AIML, VCET Puttur 2


Operating Systems [BCS303] Module - 1

Views of OS
Operating System can be viewed from two viewpoints–
1. User views 2. System views

1. User Views:-
The user’s view of the operating system depends on the type of user.
1. If the user is using standalone system, then OS is designed for ease of use and high
performances. Here resource utilization is not given importance.
2. If the users are at different terminals connected to a mainframe or minicomputers, by
sharing information and resources, then the OS is designed to maximize resource utilization.
OS is designed such that the CPU time, memory and i/o are used efficiently and no single user
takes more than the resource allotted to them.
3. If the users are in workstations, connected to networks and servers, then the user have a system
unit of their own and shares resources and files with other systems. Here the OS is designed for
both ease of use and resource availability (files).
4. Users of hand held systems, expects the OS to be designed for ease of use and performance per
amount of battery life
5. Other systems like embedded systems used in home devices (like washing m/c) & automobiles do
not have any user interaction. There are some LEDs to show the status of its work

2. System Views:-
Operating system can be viewed as a resource allocator and control program.
i. Resource allocator - The OS acts as a manager of hardware and software resources. CPU
time, memory space, file-storage space, I/O devices, shared files etc. are the different resources
required during execution of a program. There can be conflicting request for these resources by
different programs running in same system. The OS assigns the resources to the requesting
program depending on the priority
ii. Control Program – The OS is a control program and manage the execution of user program to
prevent errors and improper use of the computer.

Dept. of AIML, VCET Puttur 3


Operating Systems [BCS303] Module - 1

Computer System Organization

Computer-system operation
One or more CPUs, device controllers connect through common bus providing access to shared
memory. Each device controller is in-charge of a specific type of device. To ensure orderly access to
the shared memory, a memory controller is provided whose function is to synchronize access to the
memory. The CPU and other devices execute concurrently competing for memory cycles. Concurrent
execution of CPUs and devices competing for memory cycles.

When system is switched on,


1. ‘Bootstrap’ program is executed. It is the initial program to run in the system. This program is
stored in read-only memory (ROM) or in electrically erasable programmable read-only
memory(EEPROM).
2. It initializes the CPU registers, memory, device controllers and other initial setups.
3. The program also locates and loads, the OS kernel to the memory.
4. Then the OS starts with the first process to be executed (ie. ‘init’ process) and then wait for the
interrupt from the user.

Dept. of AIML, VCET Puttur 4


Operating Systems [BCS303] Module - 1

Interrupt handling
The occurrence of an event is usually signaled by an interrupt. The interrupt can either be from the
hardware or the software. Hardware may trigger an interrupt at any time by sending a signal to the
CPU. Software triggers an interrupt by executing a special operation called a system call (also called
a monitor call).
 When the CPU is interrupted, it stops what it is doing and immediately transfers execution
to a fixed location.
 The fixed location (Interrupt Vector Table) contains the starting address where the service routine
for the interrupt is located.
 After the execution of interrupt service routine, the CPU resumes the interrupted computation.

Interrupts are an important part of computer architecture. Each computer design has its own interrupt
mechanism, but several functions are common. The interrupt must transfer control to the appropriate
interrupt service routine

Dept. of AIML, VCET Puttur 5


Operating Systems [BCS303] Module - 1

Storage Structure

Computer programs must be in main memory (RAM) to be executed. Main memory is the large
memory that the processor can access directly. It commonly is implemented in a semiconductor
technology called dynamic random-access memory (DRAM). Computers provide Read Only
Memory(ROM), whose data cannot be changed.

All forms of memory provide an array of memory words. Each word has its own address. Interaction is
achieved through a sequence of load or store instructions to specific memory addresses.
A typical instruction-execution cycle, as executed on a system with a Von Neumann architecture,
 First fetches an instruction from memory and stores that instruction in the instruction
register.
 The instruction is then decoded and may cause operands to be fetched from memory and stored
in some internal register.

Dept. of AIML, VCET Puttur 6


Operating Systems [BCS303] Module - 1

 After the instruction on the operands has been executed, the result may be stored back in
memory.

Ideally, we want the programs and data to reside in main memory permanently. This arrangement
usually is not possible for the following two reasons:

1. Main memory is usually too small to store all needed programs and data permanently.
2. Main memory is a volatile storage device that loses its contents when power is turned off.

Thus, most computer systems provide secondary storage as an extension of main memory. The
main requirement for secondary storage is that it will be able to hold large quantities of data
permanently.

The most common secondary-storage device is a magnetic disk, which provides storage for both
programs and data. Most programs are stored on a disk until they are loaded into memory. Many
programs then use the disk as both a source and a destination of the information for their processing.

The wide variety of storage systems in a computer system can be organized in a hierarchy as shown in
the figure, according to speed, cost and capacity. The higher levels are expensive, but they are fast.
As we move down the hierarchy, the cost per bit generally decreases, whereas the access time and
the capacity of storage generally increases.

Dept. of AIML, VCET Puttur 7


Operating Systems [BCS303] Module - 1

In addition to differing in speed and cost, the various storage systems are either volatile or
nonvolatile. Volatile storage loses its contents when the power to the device is removed. In the
absence of expensive battery and generator backup systems, data must be written to nonvolatile
storage for safekeeping. In the hierarchy shown in figure, the storage systems above the electronic
disk are volatile, whereas those below are nonvolatile.

An electronic disk can be designed to be either volatile or nonvolatile. During normal operation, the
electronic disk stores data in a large DRAM array, which is volatile. But many electronic-disk devices
contain a hidden magnetic hard disk and a battery for backup power. If external power is interrupted,
the electronic-disk controller copies the data from RAM to the magnetic disk.

Another form of electronic disk is flash memory. Which is popular in cameras and personal digital
assistants (PDAS), in robots and increasingly as removable storage on general-purpose computers.
Flash memory is slower than DRAM but needs no power to retain its contents. Another form of
nonvolatile storage is NVRAM, which is DRAM with battery backup power. This memory can be as
fast as DRAM but has a limited duration in which it is nonvolatile.

I/O Structure
A large portion of operating system code is dedicated to managing I/O, both because of its importance
to the reliability and performance of a system and because of the varying nature of the devices.
Every device have a device controller, maintains some local buffer and a set of special- purpose
registers. The device controller is responsible for moving the data between the peripheral
devices. The operating systems have a device driver for each device controller.
To start an I/O operation,
 The device driver loads the registers within the device controller.
 The device controller, examines the contents of these registers to determine what action to take
(such as "read a character from the keyboard").
 The controller starts the transfer of data from the device to its local buffer.
 Once the transfer of data is complete, the device controller informs the device driver(OS) via an
interrupt that it has finished its operation.
 The device driver then returns control to the operating system, and also returns the data.

Dept. of AIML, VCET Puttur 8


Operating Systems [BCS303] Module - 1

 For other operations, the device driver returns status information.

This form of interrupt-driven I/O is fine for moving small amounts of data, but very difficult for bulk
data movement. To solve this problem, direct memory access (DMA) is used.

DMA is used for high-speed I/O devices, able to transmit information at close to memory speeds
• Device controller transfers blocks of data from buffer storage directly to main memory without
CPU intervention
• Only one interrupt is generated per block, rather than the one interrupt per byte

Computer System Architecture


Categorized roughly according to the number of general-purpose processors used

1. Single-Processor Systems
Most systems use a single processor. The variety of single-processor systems range from PDAs
through mainframes. On a single-processor system, there is one main CPU capable of executing
instructions from user processes. It contains special-purpose processors, in the form of device-
specific processors, for devices such as disk, keyboard, and graphics controllers.

Dept. of AIML, VCET Puttur 9


Operating Systems [BCS303] Module - 1

All special-purpose processors run limited instructions and do not run user processes. These are
managed by the operating system, the operating system sends them information about their next task
and monitors their status.
For example, a disk-controller processor, implements its own disk queue and scheduling algorithm,
thus reducing the task of main CPU. Special processors in the keyboard, converts the keystrokes into
codes to be sent to the CPU.
The use of special-purpose microprocessors is common and does not turn a single- processor system
into a multiprocessor. If there is only one general-purpose CPU, then the system is a single-
processor system.

2. Multiprocessor Systems (parallel systems or tightly coupled systems)


Systems that have two or more processors in close communication, sharing the computer bus, the
clock, memory, and peripheral devices are the multiprocessor systems.

Multiprocessor systems have three main advantages:


1. Increased throughput - In multiprocessor system, as there are multiple processors execution
of different programs take place simultaneously. Even if the number of processors is increased the
performance cannot be simultaneously increased. This is due to the overhead incurred in keeping all
the parts working correctly and also due to the competition for the shared resources. The speed-up
ratio with N processors is not N, rather, it is less than N. Thus the speed of the system is not has
expected.
2. Economy of scale - Multiprocessor systems can cost less than equivalent number of many single-
processor systems. As the multiprocessor systems share peripherals, mass storage, and power supplies,
the cost of implementing this system is economical. If several processes are working on the same data,
the data can also be shared among them.
3. Increased reliability- In multiprocessor systems functions are shared among several processors. If
one processor fails, the system is not halted, it only slows down. The job of the failed processor is
taken up, by other processors.
Two techniques to maintain ‘Increased Reliability’ - graceful degradation & fault tolerant
Graceful degradation – As there are multiple processors when one processor fails other process will
take up its work and the system goes down slowly.

Dept. of AIML, VCET Puttur 10


Operating Systems [BCS303] Module - 1

Fault tolerant – When one processor fails, its operations are stopped, the system failure is then
detected, diagnosed, and corrected.

There are two types of multiprocessor systems –


• Asymmetric multiprocessing
• Symmetric multiprocessing
1. Asymmetric multiprocessing – (Master/Slave architecture) Here each processor is assigned a
specific task, by the master processor. A master processor controls the other processors in the system.
It schedules and allocates work to the slave processors.

2) Symmetric multiprocessing (SMP) – All the processors are considered as peers. There is no
master-slave relationship. All the processors have its own registers and CPU, only memory is shared.

The benefit of this model is that many processes can run simultaneously. N processes can run if there
are N CPUs—without causing a significant deterioration of performance. Operating systems like
Windows, Windows XP, Mac OS X, and Linux—now provide support for SMP.

A Dual-Core Design
A recent trend in CPU design is to include multiple compute cores on a single chip. The
communication between processors within a chip is more faster than communication between two
single processors

Dept. of AIML, VCET Puttur 11


Operating Systems [BCS303] Module - 1

3. Clustered Systems
Clustered systems are two or more individual systems connected together via network and sharing
software resources. Clustering provides high-availability of resources and services. The service will
continue even if one or more systems in the cluster fail. High availability is generally obtained by
storing a copy of files (s/w resources) in the system.
There are two types of Clustered systems – asymmetric and symmetric
In asymmetric clustering – one system is in hot-stand by mode while the others are running the
applications. The hot-standby host machine does nothing but monitor the active server. If that server
fails, the hot-standby host becomes the active server.
In symmetric clustering – two or more systems are running applications, and are monitoring
each other. This mode is more efficient, as it uses all of the available hardware. If any system fails, its
job is taken up by the monitoring system.
Other forms of clusters include parallel clusters and clustering over a wide-area network (WAN).
Parallel clusters allow multiple hosts to access the same data on the shared storage. Cluster
technology is changing rapidly with the help of SAN(storage-area networks). Using SAN resources
can be shared with dozens of systems in a cluster, that are separated by miles.

Dept. of AIML, VCET Puttur 12


Operating Systems [BCS303] Module - 1

Operating-System Structure

Multiprogramming (Batch system) needed for efficiency

• Single user cannot keep CPU and I/O devices busy at all times, Multiprogramming organizes jobs
(code and data) so CPU always has one to execute.
• The jobs are kept initially on the disk in the job pool. A subset of total jobs in system is kept in
memory.
• Operating system picks and begins to execute one of the jobs in memory. When it has to wait (for
I/O for example), OS switches to another job.
• System resources are utilized efficiently. There is no user interaction with the computer system.

Memory Layout for Multiprogrammed System

Job 1 Job 2

Job 3 Job 4 Job 5

Job 6 Job 7

Job Pool Main Memory

Dept. of AIML, VCET Puttur 13


Operating Systems [BCS303] Module - 1

Timesharing (multitasking)

• Timesharing (multitasking) is logical extension in which CPU switches jobs so frequently that
users can interact with each job while it is running, creating interactive computing
• User gives instructions to the OS or to a program directly, using a i/p device and waits for immediate
results on the o/p device.
Response time should be < 1 second
• Each user is given the impression that the entire computer system is dedicated to his use.
• Each user has at least one program executing in memory which is called process.
• When a process executes, it executes for only a short time before it finishes or needs to perform I/O.
I/O may be interactive, rather than let the CPU sit idle during this I/O, OS switches the CPU to the
program of some other user.
• If several jobs are ready to be brought into memory and if there is no enough memory space, then
system must choose among them. Making this decision is job scheduling.
• If several jobs ready to run at the same time. System must choose among them Making this decision
is CPU scheduling.
• For reasonable response time, swapping moves processes in and out of memory.
• Virtual memory allows execution of processes not completely in memory. The main advantage of
virtual memory scheme is that it enables users to run programs that are larger than actual physical
memory.

Distributed Systems
 Individual systems that are connected and share the resource available in network is called
Distributed system. Access to a shared resource increases computation speed, functionality, data
availability, and reliability.
 A network is a communication path between two or more systems. Distributed systems depend on
networking for their functionality.
 Networks vary by the protocols used, the distances between nodes, and the transport media.
TCP/IP is the most common network protocol. Most operating systems support TCP/IP.

Dept. of AIML, VCET Puttur 14


Operating Systems [BCS303] Module - 1

Operating-System Operations

Modern operating systems are Interrupt driven.

• If there is nothing to be done, Operating system will sit quietly, waiting for something to occur.
• Events are signaled by the occurrence of an interrupt or a trap.
◦ Hardware interrupt by one of the devices
◦ Software interrupt (exception or trap):
▪ Software error (eg., division by zero)
▪ Request for operating system service
▪ Other process problems include infinite loop, processes modifying each other or the operating system
• For each type of interrupt, separate segments of code in the OS determine what action to take.
• Since operating system and the users share the hardware and software resources of the computer
system, we need to make sure that error in a user program could cause problem only for the program.

Dual-Mode Operation
Since the operating system and the user programs share the hardware and software resources of the
computer system, it has to be made sure that an error in a user program cannot cause problems to other
programs and the Operating System running in the system.
The approach taken is to use a hardware support that allows us to differentiate among various modes
of execution.
The system can be assumed to work in two separate modes of operation:
• user mode and
• kernel mode (supervisor mode, system mode, or privileged mode)
 A hardware bit of the computer, called the mode bit, is used to indicate the current mode:
kernel (0) or user (1).
 With the mode bit, we are able to distinguish between a task that is executed by the operating
system and one that is executed by the user.
 When the computer system is executing a user application, the system is in user mode.
 When a user application requests a service from the operating system (via a system call), the
transition from user to kernel mode takes place

Dept. of AIML, VCET Puttur 15


Operating Systems [BCS303] Module - 1

 At system boot time, the hardware starts in kernel mode. The operating system is then loaded
and starts user applications in user mode.
 Whenever a trap or interrupt occurs, the hardware switches from user mode to kernel
mode (that is, changes the mode bit from 1 to 0). Thus, whenever the operating system gains
control of the computer, it is in kernel mode.
 The dual mode of operation provides us with the means for protecting the operating system
from errant users—and errant users from one another.
 The hardware allows privileged instructions to be executed only in kernel mode. If an attempt
is made to execute a privileged instruction in user mode, the hardware does not execute the
instruction but rather treats it as illegal and traps it to the operating system. The instruction to
switch to user mode is an example of a privileged instruction.
 Initial control is within the operating system, where instructions are executed in kernel mode.
When control is given to a user application, the mode is set to user mode. Eventually, control is
switched back to the operating system via an interrupt, a trap, or a system call.

Timer
 Operating system uses timer to control the CPU. A user program cannot hold CPU for a long
time, this is prevented with the help of timer.
 A timer can be set to interrupt the computer after a specified period. The period may be fixed
(for example, 1/60 second) or variable (for example, from 1 millisecond to 1 second).
 Fixed timer – After a fixed time, the process under execution is interrupted.

Dept. of AIML, VCET Puttur 16


Operating Systems [BCS303] Module - 1

 Variable timer – Interrupt occurs after varying interval. This is implemented using a fixed-
rate clock and a counter. The operating system sets the counter. Every time the clock ticks, the
counter is decremented. When the counter reaches 0, an interrupt occurs.
 Before changing to the user mode, the operating system ensures that the timer is set tointerrupt.
If the timer interrupts, control transfers automatically to the operating system, which may treat
the interrupt as a fatal error or may give the program more time.

Process Management
A program under execution is a process. A process needs resources like CPU time, memory, files, and
I/O devices for its execution. These resources are given to the process when it is created or at run time.
When the process terminates, the operating system reclaims the resources.
The program stored on a disk is a passive entity and the program under execution is an active entity.
A single-threaded process has one program counter specifying the next instruction to execute.
The CPU executes one instruction of the process after another, until the process completes. A
multithreaded process has multiple program counters, each pointing to the next instruction to execute
for a given thread.
The operating system is responsible for the following activities in connection with process
management:
• Scheduling process and threads on the CPU
• Creating and deleting both user and system processes
• Suspending and resuming processes
• Providing mechanisms for process synchronization
• Providing mechanisms for process communication

Memory Management
Main memory is a large array of words or bytes. Each word or byte has its own address. Main memory
is the storage device which can be easily and directly accessed by the CPU. As the program executes,
the central processor reads instructions and also reads and writes data from main memory. To improve
both the utilization of the CPU and the speed of the computer's response to its users, general-purpose
computers must keep several programs in memory, creating a need for memory management.

Dept. of AIML, VCET Puttur 17


Operating Systems [BCS303] Module - 1

The operating system is responsible for the following activities in connection with memory
management:
• Keeping track of which parts of memory are currently being used by user.
• Deciding which processes and data to move into and out of memory.
• Allocating and de-allocating memory space as needed.

Storage Management
There are three types of storage management
i) File system management
ii) Mass-storage management
iii) Cache management.

File-System Management
File management is one of the most visible components of an operating system.A file is a collection of
related information defined by its creator. Commonly, files represent programs and data. Data files
may be numeric, alphabetic, alphanumeric, or binary. Files may be free-form (for example, text files),
or they may be formatted rigidly (for example, fixed fields).
The operating system is responsible for the following activities in connection with file
management:
• Creating and deleting files
• Creating and deleting directories to organize files
• Supporting primitives for manipulating files and directories
• Mapping files onto secondary storage
• Backing up files on stable (nonvolatile) storage media

Mass-Storage Management
As the main memory is too small to accommodate all data and programs, and as the data that it holds
are erased when power is lost, the computer system must provide secondary storage to back up main
memory.
The operating system is responsible for the following activities in connection with disk management:
Free-space management

Dept. of AIML, VCET Puttur 18


Operating Systems [BCS303] Module - 1

• Free-space management
• Storage allocation
• Disk scheduling

Caching
 Caching is an important principle of computer systems.
 Information is normally kept in some storage system (such as main memory). As it is used, it is
copied into a faster storage system— the cache—as temporary data.
 When a particular piece of information is required, first we check whether it is in the cache. If
it is, we use the information directly from the cache; if it is not in cache, we use the
information from the source, putting a copy in the cache under the assumption that we will
need it again soon.
 Because caches have limited size, cache management is an important design problem. Careful
selection of the cache size and page replacement policy can result in greatly increased
performance.

Migration of data “A” from Disk to Register

In a hierarchical storage structure, the same data may appear in different levels of the storage system.
For example, suppose to retrieve an integer A from magnetic disk to the processing program.
The operation proceeds by first issuing an I/O operation to copy the disk block on which A resides to
main memory. This operation is followed by copying A to the cache and to an internal register. Thus,
the copy of A appears in several places: on the magnetic disk, in main memory, in the cache, and in an
internal register.

In a multiprocessor environment, in addition to maintaining internal registers, each of the CPUs also
contains a local cache. In such an environment, a copy of A may exist simultaneously in several

Dept. of AIML, VCET Puttur 19


Operating Systems [BCS303] Module - 1

caches. Since the various CPUs can all execute concurrently, any update done to the value of A in one
cache is immediately reflected in all other caches where A resides. This situation is called cache
coherency, and it is usually a hardware problem (handled below the operating-system level).

I/O Systems
One of the purposes of an operating system is to hide the peculiarities of specific hardware devices
from the user. The I/O subsystem consists of several components:
• A memory-management component that includes buffering, caching, and spooling
• A general device-driver interface
• Drivers for specific hardware devices

I/O subsystem responsible for


◦ Memory management of I/O including buffering (storing data temporarily while it is being
transferred), caching (storing parts of data in faster storage for performance), spooling (the
overlapping of output of one job with input of other jobs)
◦ General device-driver interface
◦ Drivers for specific hardware devices
• Only device driver knows the peculiarities of the specific device to which it is assigned.

Protection and Security


If a computer system has multiple users and allows the concurrent execution of multiple processes,
then access to data must be regulated.
• Protection – any mechanism for controlling access of processes or users to resources defined by a
computer system. • A system can have adequate protection but still be prone to failure and allow
inappropriate access.(For eg., if authentication information of a user is stolen)
• Security – defense of the system against internal and external attacks .◦ attacks include denial-of-
service, viruses, identity theft, theft of service
• Protection and security require the system to be able to distinguish among all its users, to determine
who can do what.
• Most operating systems maintain a list of user names and associated User identifiers (user Ids).

Dept. of AIML, VCET Puttur 20


Operating Systems [BCS303] Module - 1

• User ID is associated with all files, processes of a user to determine access control.
• Group identifier (group ID) allows set of users to be defined.
• Then user's group IDs are also included in the every associated process.
• Privilege escalation allows user to change to effective ID with more rights.

Distributed Systems

• A Distributed Computer System consists of several computer systems, each with its own memory,
connected through networking hardware and software.
• Each computer system could be a PC, a multiprocessor system or a cluster.
• Many resources of a kind eg., many memories, CPUs and I/O devices exist in the distributed system.

Key Benefits:
◦ Resource sharing: Resources can be utilized across the boundaries of individual computer systems.
◦ Reliability: The OS continues to function even when computer systems or resources in it fail.
◦ Computation speedup Processes of an application can be executed in different computer systems to
speed up its completion.
◦ Communication Users can communicate among themselves irrespective of their location in the
system.

A distributed system must integrate the functioning of individual computer systems to achieve the
below benefits.
• Distributed Control: A control function is performed through participation of several nodes,
possibly all nodes in a distributed system.
• Transparency: A resource or service can be accessed without having to know its location in the
distributed system.

• Remote Procedure Call(RPC): A process calls a procedure located in a different computer system.
The OS passes parameters to the remote procedure over the network and returns its result over the
network.

Dept. of AIML, VCET Puttur 21


Operating Systems [BCS303] Module - 1

• Distributed control is opposite of the centralized control. Distributed control is essential for ensuring
that failure of a single computer does not halt the operation of the entire system.
• Transparency of a resource or service implies that a user should be able to access it without having to
know which node in the distributed system contains it.
• An Application may employ RPC feature to either perform a part of its computation in another
computer or to access the resource located in that computer.

Special-Purpose Systems
There are different classes of computer systems, whose functions are more limited and specific and it
deal with limited computation domains. The systems can be classified as Real-Time Embedded
Systems, Multimedia Systems and Handheld Systems.

Real-Time Embedded Systems


 Embedded systems vary considerably.
◦ Some are general purpose computers running standard operating systems with special purpose
application to implement the functionality.
◦ Some are hardware devices with a special-purpose embedded operating system providing just the
functionality desired.
◦ Others are hardware devices with application-specific integrated circuits (ASICS) that perform
their task without an OS.
 Embedded systems almost always run real-time operating systems.
 A real-time system is used when rigid time requirements have been placed on the operation of
a processor or the flow of data.
 Users need the computer to perform some action in a timely manner to control the activities in
an external system.
 A real-time system has well defined, fixed time constraints. Processing must be done within
the fixed time constraints, or the system will fail.

Dept. of AIML, VCET Puttur 22


Operating Systems [BCS303] Module - 1

◦ Examples of real time systems can be found in missile guidance, air traffic control, display systems
in automobiles, multimedia systems and applications like reservation and banking systems that employ
large databases.

Multimedia Systems
A recent trend in technology is the incorporation of multimedia data into computer systems.
• Multimedia data consists of audio and video files as well as conventional files.
• These data differ from conventional data in that -frames of video must be delivered according to
certain time restrictions.
• Multimedia applications need not be either audio or video, rather a multimedia application often
includes a combination of both. For eg., movie.
• Multimedia describes a wide range of applications
◦ Audio files such as MP3, movies, video conferencing.
◦ Live web-casts of speeches, sporting events and live web-cam.
• Increasingly multimedia applications are being directed toward smaller devices, including PDAs and
cellular telephones.

Handheld Systems

• Developers of handheld systems and applications face many challenges, most of which are due to the
limited size of such devices.
• Because of their size, most handheld devices have small amounts of memory, slow processors and
small display screens.
• The operating system and applications must manage memory efficiently. This includes returning all
allocated memory to the memory manager when the memory is not being used.
• Faster processors require more power. To include a faster processor in a handheld device would
require a large battery, which would take up more space.
• Most handheld devices use smaller, slower processors that consume less power. Therefore OS and
applications must be designed for slow processor.
• The small display screens limit input and output options. Tasks such as reading email and browsing
web pages must be condensed into smaller displays.

Dept. of AIML, VCET Puttur 23


Operating Systems [BCS303] Module - 1

• One approach for displaying the content in web pages is web clipping, where only a subset of web-
page is delivered and displayed on the handheld device.

Computing Environments

Traditional Computing
Just a few years ago typical office environment consisted of PCs connected to a network, with servers
providing file and print services.
• Portability was achieved by use of laptop computers.
• Terminals attached to mainframes were also common, with even fewer remote access and portability
options.
◦ Web technologies are stretching the boundaries of traditional computing. Companies establish
portals, which provide web accessibility to their internal servers.
◦ Handheld computers can synchronize with PCs to allow very portable use of the company
information.
• Batch systems processed jobs in bulk, with predetermined input.
• Interactive systems waited for input from users.
• Time sharing systems used a timer and scheduling algorithms to rapidly cycle processes through the
CPU giving each user a share of the resources.

Client-Server Computing

Terminals connected to centralized systems are now being replaced by Pcs.


• As a result, many of today's system act as server systems to satisfy the requests generated by client
systems.
• Compute-server system provides an interface to which a client can send a request to perform an
action, in response server executes the action and sends back results to the client. (eg., database)
• File-server system provides a file-system interface where clients can create, update, read and delete
files

Dept. of AIML, VCET Puttur 24


Operating Systems [BCS303] Module - 1

Peer-to-Peer Computing

In this model clients and servers are not distinguished from one another.
• All nodes within the system are considered peers, and each may act as either a client or a server,
depending on whether it is requesting or providing service.
• To participate in a peer-to-peer system, a node must first join the network of peers.
• Once a node has joined the network, it can begin providing services to and requesting services from
other nodes in the system.
• Determining what services are available is accomplished in one of two ways:
• When a node joins a network, it registers its service with a centralized lookup service on the network.
• Any node desiring specific service first contacts this centralized lookup service to determine which
node provides the service.
• The remainder of the communication takes place between the client and the service provider.
• A peer acting as a client must first discover what node provides a desired service by broadcasting a
request for the service to all other nodes in the network.
• The node providing that service responds to the peer making the request.

Dept. of AIML, VCET Puttur 25


Operating Systems [BCS303] Module - 1

Web-Based Computing

Web computing has increased the emphasis on networking.


• Devices that were not previously networked now include wired or wireless access.
• Devices that were networked now have faster network connectivity.
• The implementation of web based computing has given rise to new categories of devices, such as
load balancers, which distribute network connections among a pool of similar servers.

Dept. of AIML, VCET Puttur 26


Operating Systems [BCS303] Module - 1

System Structure

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.
OS provide services for the users of the system, including:
• User Interfaces - Means by which users can issue commands to the system. Depending on the
operating system these may be a command-line interface ( e.g. sh, csh, ksh, tcsh, etc.), a Graphical
User Interface (e.g. Windows, X-Windows, KDE, Gnome, etc.), or a batch command systems•
Program Execution - The OS must be able to load a program into RAM, run the program, and
terminate the program, either normally or abnormally.
• I/O Operations - The OS is responsible for transferring data to and from I/O devices, including
keyboards, terminals, printers, and files. For specific devices, special functions are provided(device
drivers) by OS.

Dept. of AIML, VCET Puttur 27


Operating Systems [BCS303] Module - 1

File-System Manipulation – Programs need to read and write files or directories. The services
required to create or delete files, search for a file, list the contents of a file and change the file
permissions are provided by OS.
• Communications - Inter-process communications, IPC, either between processes running on the
same processor, or between processes running on separate processors or separate machines. May be
implemented by using the service of OS- like shared memory or message passing.
• Error Detection - Both hardware and software errors must be detected and handled appropriately by
the OS. Errors may occur in the CPU and memory hardware (such as power failure and memory
error), in I/O devices (such as a parity error on tape, a connection failure on a network, or lack of
paper in the printer), and in the user program (such as an arithmetic overflow, an attempt to access an
illegal memory location).
OS provide services for the efficient operation of the system, including:
• Resource Allocation – Resources like CPU cycles, main memory, storage space, and I/O devices
must be allocated to multiple users and multiple jobs at the same time.
• Accounting – There are services in OS to keep track of system activity and resource usage, either
for billing purposes or for statistical record keeping that can be used to optimize future performance.
• Protection and Security – The owners of information(file) in multiuser or networked computer
system may want to control the use of that information. When several separate processes execute
concurrently, one process should not interfere with other or with OS. Protection involves ensuring that
all access to system resources is controlled. Security of the system from outsiders must also be done,
by means of a password.

User Operating-System Interface


There are several ways for users to interface with the operating system.
1) Command-line interface, or command interpreter, allows users to directly enter commands to be
performed by the operating system.
2) Graphical user interface(GUI), allows users to interface with the operating system using pointer
device and menu system.

Command Interpreter

Dept. of AIML, VCET Puttur 28


Operating Systems [BCS303] Module - 1

• Some operating systems include the command interpreter in the kernel. Others treat command
interpreter as a special system program.
• On systems with multiple command interpreters to choose from, the interpreters are known as shells.
• The main function of command interpreter is to get and execute the next user specified command.
• Commands can be implemented in two general ways.
◦ Command interpreter itself contains the code to execute the command. In this case number of
commands that can be given determines the size of the command interpreter.
◦ Operating systems implement most commands through system programs. Command Interpreter uses
the command to identify a file to be loaded into memory and executed.
▪ For eg., consider “rm file.txt”
▪ Command Interpreter would search for a file named rm, load the file into memory and execute it
with the parameter file.txt.

Graphical User Interface, GUI

A second approach for interfacing with the operating system is through a user friendly graphical user
interface or GUI.
• The user moves the mouse to position its pointer on images, or icons on the screen that represent
programs, files and directories.
• Clicking a button on the mouse can invoke a program, select a file or a directory or pull down a
menu that contains commands depending on pointer's location.
• Traditionally Unix systems have been dominated by command line interfaces.
• Common Desktop Environment (CDE) and X-windows system are common GUIs on commercial
versions of UNIX.
• Open source projects such as K Desktop Environment (KDE) and the GNOME desktop by the GNU
project. Both KDE and GNOME desktops run on Linux.
• Many UNIX users prefer command line interfaces and most windows users use the windows GUI
environment and almost never use MS-DOS shell.

Dept. of AIML, VCET Puttur 29


Operating Systems [BCS303] Module - 1

System Calls
System calls provide an interface to the services made available by an operating system.
• Illustrating how system calls are used: Writing a simple program to read data from one file and copy
them to another file.
• System call sequence to copy the contents of one file to another file
• Ask the user for the names of the two files. This requires a sequence of system calls, First to write a
prompting message on the screen and then read from the keyboard characters that define the two files.
• Once two file names are obtained the program must open the input file and create the output file. If
input file doesn't exist, then program prints a message on the console (system call) and then terminate
abnormally (another system call). Else the input file is opened (system call).
• If the input file exists, new output file must be created. If output file exists, then terminate the
program abnormally (system call). Else create the output file (system call).
• Now both files are set up, program enters a loop that reads from the input file (a system call) and
writes to the output file (another system call).
• Finally, after the entire file is copied, the program may close both files (another system call), write a
message to the console (one more system call), and finally terminate normally (the final system call).

Even simple programs make heavy use of the operating system.

• Application developers design programs according to an Application Programming Interface.

Dept. of AIML, VCET Puttur 30


Operating Systems [BCS303] Module - 1

• System calls are accessed by programs via a high-level Application Programming Interface (API)
rather than direct system call use.
• Three most common APIs are Win32 API for Windows, POSIX API for POSIX-based systems
(including all versions of UNIX, Linux and Mac OS X), and Java API for the Java virtual machine
(JVM).
• Functions that make up an API invoke the actual system calls on behalf of the application
programmer.
• One benefit of programming according to an API is program portability:
◦ A program designed according to an API can compile and run on any system that supports the same
API.
• Actual system calls are more detailed and difficult to work with than the API
• The run-time support system for most programming languages provides a system-call interface that
serves as a link to the system calls made available by the OS.

System Call Implementation

• Typically, a number associated with each system call


◦ System-call interface maintains a table indexed according to these numbers.
• The system call interface invokes the intended system call in OS kernel and returns status of the
system call and any return values.
• The caller need know nothing about how the system call is implemented
◦ Just needs to obey API and understand what OS will do as a result of execution of that system call.
◦ Most details of OS interface hidden from programmer by API, Managed by run-time support library.

API – System Call – OS Relationship

Dept. of AIML, VCET Puttur 31


Operating Systems [BCS303] Module - 1

Figure 2.6 The handling of a user application invoking the open() system call
System Call Parameter Passing
Three general methods used to pass parameters to OS are –
• To pass parameters in registers
• If parameters are large blocks, address of block (where parameters are stored in memory) is
sent to OS in the register. (Linux & Solaris).
• Parameters can be pushed onto the stack by program and popped off the stack by OS.

Types of System Calls


The system calls can be categorized into six major categories:
• Process Control
• File management

Dept. of AIML, VCET Puttur 32


Operating Systems [BCS303] Module - 1

• Device management
• Information management
• Communications
• Protection

Process control
• create process, terminate process
• end, abort – A running program needs to be able to halt its execution either normally(end) or
abnormally(abort).
• load, execute – A process executing one program may want to load and execute another program.
This feature allows the command interpreter to execute a program as directed by, user command.
• get process attributes, set process attributes – Execution of new processes should be controlled. This
control requires the ability to determine and reset the attributes of a process.
• wait for time – After creating new processes, we may need to wait for them to finish their execution.
We may want to wait for a certain amount of time to pass (wait for time).
• wait event, signal event – We want to wait for a specific event to occur (wait event). The processes
should signal when that event has occurred (signal event).
• allocate and free memory Locks for managing access to shared data between processes.

File management
• create file, delete file
• open, close file
• read, write, reposition
• get and set file attributes

We should be able to create and delete files. Once the file is created, we need to open it and use it. We
may also read, write or reposition. Finally we need to close the file.
File attributes include file name, file type, protection code and so on. Two system calls, get file
attribute and set file attribute are required to determine the values of various attributes and perhaps to
reset them.

Dept. of AIML, VCET Puttur 33


Operating Systems [BCS303] Module - 1

Device management
• request device, release device
• read, write, reposition
• get device attributes, set device attributes
• logically attach or detach devices
A process may need several resources to execute. A system with multiple users may require us to first
request the device, to ensure exclusive use of it. After we are finished with the device we release it.
These functions are similar to open and close system calls for files.
Similarity between I/O devices and files is so great that many operating systems don't differentiate
between them.

Information maintenance
• get time or date, set time or date
• get system data, set system data
• get and set process, file, or device attributes
System calls to return the current date and time, number of current users, the version number of the
operating system, amount of free memory or disk space and so on.

Communications
• In message passing model, communicating processes exchange messages with one another to
transfer information.
• Before communication can take place, a connection must be opened. The recipient process must give
its permission for communication to take place with an accept connection call.
• The source of the communication, known as the client and recipient known as a server, then
exchange messages by using read message and write message system calls.
• In Shared-memory model processes create and gain access to regions of memory owned by other
processes.
• Processes exchange the information by reading and writing to the shared area.
• Processes are responsible for ensuring that they are not writing to the same location simultaneously.

Dept. of AIML, VCET Puttur 34


Operating Systems [BCS303] Module - 1

Protection
• Control access to resources
• Get and set permissions
• Allow and deny user access
Protection provides mechanisms for controlling access to the resources provided by a computersystem.
Get and set permissions manipulate the permission settings of resources such as files and disks.
Allow user and deny user system calls specify whether particular user can or cannot be allowed to
access certain resources.

Standard C Library Example


C program invoking printf() library call, which calls write() system call

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:

◦ File management
◦ Status information

Dept. of AIML, VCET Puttur 35


Operating Systems [BCS303] Module - 1

◦ File modification
◦ Programming-language support
◦ Program loading and execution
◦ Communications
• Most users’ view of the operating system is defined by system programs, not the actual system calls.

• File management – These programs create, delete, copy, rename, print, dump, list, and generally
manipulate files and directories.
• Status information Some programs ask the system for info - date, time, amount of available
memory, disk space, number of users.
◦ Others provide detailed performance, logging, and debugging information. Typically, these programs
format and print the output to the terminal or other output devices
◦ Some systems implement a registry - used to store and retrieve configuration information
• File modification
◦ Text editors to create and modify the content of files
◦ 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.
• Program loading and execution- Once a program is assembled or compiled it must be loaded into
memory to be executed. Absolute loaders, relocatable loaders, linkage editors, and overlay-loaders,
debugging systems for higher-level and machine language.
• Communications - Provide the mechanism for creating virtual connections among processes, users,
and computer systems
◦ Allow users to send messages to one another’s screens, browse web pages, send electronic-mail
messages, log in remotely, transfer files from one machine to another

Operating System Design and Implementation


Design Goals
• Start the design by defining goals and specifications.
• Design of the system will be affected by the choice of hardware, type of system:batch, time shared,
single user, multiuser, distributed, real time etc.

Dept. of AIML, VCET Puttur 36


Operating Systems [BCS303] Module - 1

• User goals and System goals


◦ User goals – operating system should be convenient to use, easy to learn, reliable, safe, and fast.
◦ System goals – operating system should be easy to design, implement, and maintain, as well as
flexible, reliable, error-free, and efficient.
◦ All these requirements are vague and may be interpreted in multiple ways.
• Specifying and designing an operating system is a highly creative task. General principles have been
developed in the field of software engineering.

Mechanisms and Policies


• Important principle is the separation of policy from mechanism. Mechanism: Determines how to do
something Policy: Determines What will be done
• Policies are likely to change across places or over time. In the worst case each change in policy
would require a change in the mechanism.
• Mechanism insensitive to changes in policy would be more desirable.
• Consider the mechanism for giving priority to certain types of programs over others.
◦ If the mechanism is properly separated from policy, it can be used either to support a policy decision
that I/O intensive programs should have priority over CPU-intensive ones or to support the opposite
policy.

Implementation
• Traditionally operating systems have been written in assembly language.
• However now they are most commonly written in higher-level languages such as C or C++.
• Advantages of using a higher level language: code can be written faster, is more compact and is
easier to understand and debug.
• Operating system can be easily ported to some other hardware – if written in higher-level language.
• Disadvantages of using a higher level language: reduced speed and increased storage requirements.
• Although OS is large, only a small amount of code is critical to high performance. Memory manager
and CPU scheduler are probably the most critical routines.
• Bottleneck routines can be identified and can be replaced with assembly-language equivalents.

Dept. of AIML, VCET Puttur 37


Operating Systems [BCS303] Module - 1

Operating System Structure


• General-purpose OS is very large and complex program, it must be engineered carefully if it is to
function properly and be modified easily.
• A common approach is to partition the task into small components rather than have one monolithic
system.
• Each component should be well defined portion of the system, with carefully defined inputs, outputs
and functions.
• We discuss how these components are interconnected and melded into a kernel.

Simple Structure -- MS-DOS


• MS-DOS – written to provide the most functionality in the least space. It was not divided into
modules
• Although MS-DOS has some structure, its interfaces and levels of functionality are not well
separated.
◦ Application programs are able to access the basic I/O routines to write directly to display and disk
drives.
◦ Such freedom leaves MS-DOS vulnerable to errors in user programs, entire system may crash when
user program fails.

S-DOS Layer Structure

Dept. of AIML, VCET Puttur 38


Operating Systems [BCS303] Module - 1

Non Simple Structure -- UNIX

• UNIX –initially limited by hardware functionality, the original UNIX operating system had limited
structuring. The UNIX OS consists of two separable parts
◦ Systems programs
◦ The kernel
▪ Consists of everything below the system-call interface and above the physical hardware
▪ Provides the file system, CPU scheduling, memory management, and other operating-system
functions through system calls.
• A large number of functions to be combined into one level. This monolithic structure was difficult to
implement and maintain.
• Beyond simple but not fully layered

Traditional UNIX System Structure

Figure 2.13 UNIX System Structure

Layered Approach

 A system can be modular in many ways. One method is the layered approach.

Dept. of AIML, VCET Puttur 39


Operating Systems [BCS303] Module - 1

 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.
 The layers are selected such that each uses functions (operations) and services of only lower-
level layers.
 This approach simplifies debugging and system verification.

Figure 2.14 A layered Operating System

First layer can be debugged without any concern for the rest of the system, because it uses only the
basic hardware.
• Once first layer is debugged its correct functioning can be assumed while second layer is debugged.
• An error found during debugging of a layer must be on that layer, because the layers below it are
already debugged. Thus design and implementation of the system are simplified.
• Each layer is implemented with only those operations provided by lower level layers.
• The major difficulty with the layered approach involves appropriately defining the various layers.
• Layered implementations tend to be less efficient than other types.
◦ For instance, user request for an I/O operation needs to pass through many layers before reaching the
hardware.
◦ Each layer adds overhead to the system call, the net result is a system call than takes longer than than
the one on a non-layered system.

Dept. of AIML, VCET Puttur 40


Operating Systems [BCS303] Module - 1

Microkernel System Structure


• 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 smaller kernel.
• Microkernels provide minimal process and memory management, in addition to communication
facility.
• Microkernel provides communication facility between the client programs and various services that
are also in user space.
• Client and service communicate indirectly by exchanging messages with the microkernel.

• Benefits:
◦ Easier to extend a microkernel
◦ Easier to port the operating system to new architectures
◦ More reliable and secure(less code is running in kernel mode)
• Due to increased system function overhead, microkernel can suffer from performance decreases.

Fig: Microkernel structure

Dept. of AIML, VCET Puttur 41


Operating Systems [BCS303] Module - 1

Fig: Microkernel structure

Modules
 Kernel has a set of core components and links in additional services either during boot time or
during run time.
 This strategy uses dynamically loadable modules and is common in modern implementations of
UNIX including Linux and Mac OS X.

 Solaris OS organized around a core kernel with seven types of loadable kernel modules.
 This design allows kernel to provide core services yet allows certain features to be implemented
dynamically.

Figure 2.15 Solaris loadable modules

• The approach resembles a layered system in that each kernel section has defined, protected
interfaces; But more flexible than layered system because any module can call any other module.
• The approach resembles microkernel in that primary module has only core functions and knows how
to load other modules; But more efficient than microkernel because message passing is not required to
communicate.
• Most modern operating systems are actually not one pure model.
• Hybrid combines multiple approaches to address performance, security, usability needs.

Dept. of AIML, VCET Puttur 42


Operating Systems [BCS303] Module - 1

Virtual Machines

Figure 2.17 System modes. (A) Nonvirtual machine (b) Virtual machine

• Different classes of users need different kinds of user service. Hence running a single OS on a
computer system can disappoint many users.
• This problem is solved by using a virtual machine operating system(VM OS) to control the computer
system.
• The VM OS creates several virtual machines. Virtual machine abstracts the hardware of a single
computer into several different execution environments.
• User can use any OS of his choice on the virtual machine and run his programs under this OS.

• This way users of the computer system can use different operating systems at the same time. Single
physical machine can run multiple operating systems concurrently.
• Each of these operating systems a guest OS and call the virtual machine OS the host OS.

Dept. of AIML, VCET Puttur 43


Operating Systems [BCS303] Module - 1

Benefits
• Being able to share the same hardware yet run several different operating systems concurrently.
• Since each virtual machine is completely isolated from all other virtual machines, there are no
protection problems.
• A virus inside a guest OS might damage that OS but is unlikely to affect the host or the other guests.
• A virtual machine system is perfect vehicle for operating system research and development. All
changes to the operating system need to be tested carefully to avoid all possible errors.
• System programmers are given their own virtual machine, and system development is done on the
virtual machine instead of on a physical machine.
• So no need of stopping the current system while changes are made and tested.
• Virtual machines allow for rapid porting and testing of programs in varying environments.
• Quality assurance engineers can test their applications in multiple environments without maintaining
a computer for each environment.

Implementation
• The VM OS achieves concurrent operation of guest operating systems through an action that
resembles process scheduling.

Dept. of AIML, VCET Puttur 44


Operating Systems [BCS303] Module - 1

• VM OS selects a virtual machine and arranges to let the guest OS running on it execute its
instructions on the CPU.
• A guest OS remains in control of the host machine until the VM OS decides to switch to another
virtual machine.
• Dual mode of CPU causes some difficulties in the use of a VM OS. The VM OS must protect itself
from guest OSs, so it must run guest OSs with the CPU in the user mode.
• This makes guest OS vulnerable to corruption by a user process.
• With hardware support for several execution modes of the CPU. Host OS can run with the CPU in
the kernel mode, Guest OS processes are executed in user mode and guest OS runs with the CPU in
one of the intermediate modes.
• Full virtualization implies that the host machine and virtual machine have the same capabilities.
Hence OS can operate identically while running on a bare machine and on a virtual machine.

Para-virtualization
• Instead of making guest operating system to believe that it has a system to itself, Para-virtualization
presents the guest with a system that is similar but not identical to the guest's preferred system.
• Security issue in full virtualization could be resolved through paravirtualization.
• The privileged instructions would not be included in a virtual machine. Special instruction is
provided for use by a guest OS that wished to execute a privileged instruction.
• The Special instruction would cause a software interrupt and VM OS would execute the specialized
instruction on behalf of the guest OS.
• The host OS would know whether the special instruction in the virtual machine was used by a guest
OS or by a user process- latter is illegal.

VMware

• There are some methods which involve writing virtualization tool to run in user mode as an
application on top of the operating system.
• Virtual machines running within this tool believe they are running on bare hardware but in fact are
running inside a user level application.

Dept. of AIML, VCET Puttur 45


Operating Systems [BCS303] Module - 1

• VMware workstation runs as an application on a host operating system such as Windows or Linux
and allows host system to run several different guest OSs.
• Each virtual machine has its own virtual CPU, memory, disk drives, network interfaces and so on.
• The physical disk guest owns and manages is really just a file within the file system of the host
operating system.
• In the scenario below Linux is running as the host OS and FreeBSD, Windows NT and Windows XP
are running as the guest OSs.

Figure 2.19 VMware architecture

The Java Virtual Machine


• Java is a popular object-oriented programming language. A Java program consists of one or more
classes.
• For each Java class, the compiler produces an architecture-neutral byte code output that will run on
any implementation of JVM.
• The JVM is a specification for an abstract computer. It consists of a class loader and a Java
interpreter.
• The class loader loads the compiled .class files from both the Java program and the Java API for
execution by the Java Interpreter.

Dept. of AIML, VCET Puttur 46


Operating Systems [BCS303] Module - 1

• After the class is loaded, the verifier checks that the .class file is valid Java byte code, If the class
passes verification it is run by the Java interpreter.

Figure 2.20 The JVM


Operating-System Generation
• Operating system is designed for one machine at one site; the system must be configured or
generated for each specific computer site.
• SYSGEN program obtains information concerning the specific configuration of the hardware
system.
1. What CPU is to be used ? What options are installed
2. How much memory available
3. What devices are available
4. What operating system options are desired ?

System Boot
• The procedure of starting a computer by loading the kernel is known as booting the system.
• A small piece of code known as the bootstrap program or bootstrap loader locates the kernel, loads it
into memory, and starts its execution.
• Sometimes a two-step process in which a simple bootstrap loader fetches a more complex boot
program from the disk, which in turn loads the kernel.
• When system is powered up or rebooted – execution starts at a fixed memory location. ◦ At that
location initial bootstrap program resides. The program is in ROM.
• Bootstrap program initializes all aspects of the system from CPU registers to device controllers and
the contents of main memory.

Dept. of AIML, VCET Puttur 47


Operating Systems [BCS303] Module - 1

• Storing the OS in ROM is suitable for small operating systems. A problem with ROM is that
executing code there is slower than executing code in RAM.
• For large Operating systems, bootstrap loader is stored in ROM and operating system is on the disk.

Computer system Debugging


 Debugging is the activity of finding and fixing errors, or in a system. Debugging seeks to find and fix
errors, or bugs, in both hardware and software.
 Performance problems are considered bugs, so debugging can also include Performance tuning,
which seeks to improve performance by removing bottlenecks in the processing taking place within a
system.
Here, we explore debugging kernel and process errors and performance problems.
(1) Failure Analysis
 If a process fails, most operating systems write the error information to a log file to alert system
administrators or users that the problem occurred.
 The operating system can also take a core dump—a capture of the memory of the process—and store
it in a file for later analysis. (Memory was referred to as the “core” in the early days of computing.)
 Running programs and core dumps can be probed by a debugger, which allows a programmer to
explore the code and memory of a process at the time of failure
 Debugging user-level process code is a challenge. Operating-system kernel debugging is even more
complex because of the size and complexity of the kernel, its control of the hardware, and the lack of
user-level debugging tools.
 A failure in the kernel is called a crash. When a crash occurs, error information is saved to a log file,
and the memory state is saved to a crash dump.
 Operating-system debugging and process debugging frequently use different tools and techniques due
to the very different nature of these two tasks. Consider that a kernel failure in the file-system code
would make it risky for the kernel to try to save its state to a file on the file system before rebooting.
 A common technique is to save the kernel’s memory state to a section of disk set aside for this
purpose that contains no file system. If the kernel detects an unrecoverable error, it writes the entire
contents of memory, or at least the kernel-owned parts of the system memory, to the disk area.
 When the system reboots, a process runs to gather the data from that area and write it to a crash dump
file within a file system for analysis. Obviously, such strategies would be unnecessary for debugging
ordinary user-level processes.

Dept. of AIML, VCET Puttur 48


Operating Systems [BCS303] Module - 1

(2) Performance Tuning


 To identify bottlenecks, we must be able to monitor system performance. Code must be added to
compute and display measures of system behavior.
 In a number of systems, the operating system does this task by producing trace listings of system
behavior. All interesting events are logged with their time and important parameters and are written
to a file.
 Later, an analysis program can process the log file to determine system performance and to identify
bottlenecks and inefficiencies.
 These same traces can be run as input for a simulation of a suggested improved system. Traces also
can help people to find errors in operating-system behavior.

(3) DTrace
 DTrace is a facility that dynamically adds probes to a running system, both in user processes and in
the kernel.
 These probes can be queried via the D programming language to determine an astonishing amount
about the kernel, the system state, and process activities.
 Debugging the interactions between user-level and kernel code is nearly impossible without a toolset
that understands both sets of code and can instrument the interactions.
 For that toolset to be truly useful, it must be able to debug any area of a system, including areas that
were not written with debugging in mind, and do so without affecting system reliability.
 This tool must also have a minimum performance impact-ideally it should have no impact when not
in use and a proportional impact during use.
 The DTrace tool meets these requirements and provides a dynamic, safe, low-impact debugging
environment.

Dept. of AIML, VCET Puttur 49

You might also like