Unit1 Operatingsystem
Unit1 Operatingsystem
Introduction to
i programs that control the
An operating system (OS) is a set of
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
Page 1
Unit 1
figure 1.
1. Hardware: such as CPU, memory and I/O devices.
2. Operating system: provides the means of proper use of the
hardware in theoperations of the computer system, it is similar to
government.
3. Application programs: solve the computing problems of the user,
such as :compilers, database systems and web browsers.
4. Users: peoples, machine, or other computer.
Page 2
Unit 1
Computer System
O i ti
1. Computer-System Operation
A modern general-purpose computer system consists of one or more
CPUs and a number of device controllers connected through a common
bus that provides access to shared memory (Figure 1.2). Each device
controller is in charge of a specific type of device (for example, disk
drives, audio devices, and video displays). The CPU and the device
controllers can execute concurrently, competing for memory cycles. To
ensure orderly access to the shared memory, a memory controller is
synchronizing access to the memory.
For a computer to start running-for instance, when it is powered up or
rebooted- it needs to have an initial program to run. This initial program,
or bootstrap program, tends to be simple. Typically, it is stored in read-
only memory (ROM) or electrically erasable programmable read-only
memory (EEPROM),known by the general term firmware, within the
computer hardware. It initializes all aspects of the system, from CPU
registers to device controllers to memory contents. The bootstrap
Page 3
Unit 1
Page 4
Unit 1
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
theinstruction register. And increment the PC register.
2) Decode the instruction and may cause operands to be fetched from
memoryand stored in some internal register.
3) Execute the instruction and store the result in memory.
Page 5
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 poweris turned off or otherwise lost.
Thus, most computer systems provide secondary storage as an
extension of mainmemory 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 systemslie in speed, cost, size, and volatility. The higher
levels are expensive, but they are fast.
3. I/O Structure
3. I/O
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
Page 6
Unit 1
Page 7
Unit 1
buffer storage. Typically, operating systems have a device driver for each
devicecontroller.
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 8
Unit 1
Operating system
F ti
OS performs many functions such as:
1. Implementing user interface.
access.11.Handling network
communications.
Page 9
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
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
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
Page
Unit 1
Page
Unit 1
4. Multiprogramming
Advantages
Disadvantages
5. Parallel system
Page
Unit 1
6. Distributed system
7. Personal computer
Page
Unit 1
system operations:
1. Resource allocation: For simultaneously executing job.
Page
Unit 1
Page
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 bywhom
Page
Unit 1
2) Deciding which processes (or parts thereof) and data to move into
and out ofmemory
Page
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
Page
Unit 1
Page
Unit 1
Acquire input
filename Write
prompt to screen
Accept input
Acquire output
filenameWrite prompt
Example
to screensystem
Accept call
input
Open the input file
If file does not exist,
abortCreate output file
If file exist,
abortLoop
Read from input
fileWrite to output
file
Until read fail
Close output
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
View publication