Unit1 Operatingsystem
Unit1 Operatingsystem
Introduction to operating
An operating system (OS) is a set of programs that control the
execution of application programs and act as an intermediary between
a user of a computer and the computer hardware. OS is software that
manages the computer hardware as well as providing an environment
for application programs to run.
Examples of OS are: Windows, Windows/NT, OS/2 and MacOS.
Computer System
A computer system can be divided into four components: the
hardware, the operating system, the application programs and the
users. The abstract view of system components is shown in figure 1.
Page 1
Unit 1
Page 2
Unit 1
Page 3
Unit 1
and to start executing that system. To accomplish this goal, the bootstrap
program must locate and load into memory the operating system kernel. The
operating system then starts executing the first process, such as "init," and waits
for some event to occur.
Figure 2
2. Storage Structure
Computer programs must be in main memory (also called RAM) to be executed.
Main memory is the only large storage area that the processor can access
directly. It forms 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. The load instruction moves a word from main
memory to an internal register within the CPU, whereas the store instruction
moves the content of a register to main memory.
The instruction-execution cycle includes:
1) Fetches an instruction from memory and stores that instruction in the
instruction register. And increment the PC register.
2) Decode the instruction and may cause operands to be fetched from memory
and stored in some internal register.
3) Execute the instruction and store the result in memory.
Page 4
Unit 1
The programs and data are not resided in main memory permanently 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 or otherwise lost.
Thus, most computer systems provide secondary storage as an extension of main
memory to hold large quantities of data permanently.
The wide variety of storage systems in a computer system can be organized in a
hierarchy (figure 2). The main differences among the various storage systems
lie in speed, cost, size, and volatility. The higher levels are expensive, but they
are fast.
3. I/O Structure
3. I/O Structure
A computer system consists of CPUs and multiple device controllers that are
connected through a common bus. The device controller is responsible for
moving the data between the peripheral devices that it controls and its local
Page 5
Unit 1
buffer storage. Typically, operating systems have a device driver for each device
controller.
To start an I/O operation, the device driver loads the appropriate registers within
the device controller. The device controller examines the contents of these
registers to determine what action to take. 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 via an interrupt that it has finished
its operation. The device driver then returns control to the operating system . For
other operations, the device driver returns status information.
For moving bulk data, direct memory access (DMA) is used. After setting up
buffers, pointers, and counters for the I/O device, the device controller transfers
an entire block of data directly to or from its own buffer storage to memory, with
no intervention by the CPU. Only one interrupt is generated per block, to tell the
device driver that the operation has completed, rather than the one interrupt per
byte generated for low-speed devices.
Page 6
Unit 1
Page 7
Unit 1
In this type of OS, users submit jobs on regular schedule (e.g. daily, weekly,
monthly) to a central place where the user of such system did not interact
directly with computer system. To speed up the processing, jobs with similar
needs were batched together and were run through the computer as a group.
Thus, the programmer would leave the programs with the operator. The output
from each job would send to the appropriate programmer. The major task of this
type was to transfer control automatically from one job to the next.
Disadvantages of Batch System
1. Turnaround time can be large from user standpoint.
2. Difficult to debug program.
2. Time-Sharing System
This type of OS provides on-line communication between the user and the
system, the user gives his instructions directly and receives intermediate
response, and therefore it called interactive system.
The time sharing system allows many user simultaneously share the
computer system. The CPU is multiplexed rapidly among several programs,
which are kept in memory and on disk. A program swapped in and out of
memory to the disk.
Time sharing system reduces the CPU ideal time. The disadvantage is more
complex.
Page 8
Unit 1
Performance development of OS
1. On-line and off-line operation
A special subroutine was written for each I/O device called a device
controller. Some I/O devices has been equipped for either on-line
operation (they are connected to the processor), or off-line operations
(they are run by control unit).
2. Buffering
A buffer is an area of primary storage for holding data during I/O transfer.
On input, the data are placed in the buffer by an I/O channel, when the
transfer is complete the data may be accessed the processor. The buffing
may be single or double.
Spooling uses the disk as a very large buffer. Spooling is useful because
device access data that different rates. The buffer provides a waiting
station where data can rest while the slower device catches up.
Spooling allows overlapping between the computation of one job and I/O
of another job.
Page 9
Unit 1
4. Multiprogramming
Advantages
Disadvantages
5. Parallel system
There are more than on processor in the system. These processors share
the computer bus, clock, memory and I/O devices.
Page 10
Unit 1
6. Distributed system
c) Reliability – If one processor failed the rest still can function with no
problem.
7. Personal computer
Page 11
Unit 1
Page 12
Unit 1
Page 13
Unit 1
System calls provide the means for a user program to ask the operating system to
perform tasks reserved for the operating system on the user program's behalf.
B) Protection CPU
To ensure that the operating system maintains must control over the CPU. We
must prevent a user program from getting stuck in an infinite loop or not
calling system services and never returning control to the operating system. To
accomplish this goal, we can use a timer. A timer can be set to interrupt the
computer after a specified fixed or variable period.
1.Process Management
Memory Management
Management
Main memory is a large array of words or bytes where each word or byte has its
own address. The operating system is responsible for the following activities in
regard to memory management:
1) Keeping track of which parts of memory are currently being used and by
whom
2) Deciding which processes (or parts thereof) and data to move into and out of
memory
Page 14
Unit 1
1. Free-space management.
2. Storage allocation
3. Disk scheduling.
Example about how system calls are used from the OS to read data from one
files and copy them to another file, shown in figure . the programmer never see
this level of details
Page 15
Unit 1
System program provide basic function to users, so that they don’t need to write
their own environment for program development (editors, compilers) and
program execution (shells).
Page 16