Principles of Operating System
Principles of Operating System
operating system (OS) exploits the hardware resources of one or more processors to provide a set of
services to system users. The OS also manages secondary memory and I/O (input/output) devices on
behalf of its users.
a computer consists of processor, memory and I/O components with one or more modules of each type.
Processor: Controls the operation of the computer and performs its data processing functions. When
there is only one processor, it is often referred to as the central processing unit (CPU).
Main memory: Stores data and programs. This memory is typically volatile; that is, when the computer is
shut down, the contents of the memory are lost.
I/O modules: Move data between the computer and its external environment.
System bus: Provides for communication among processors, main memory, and I/O modules.
2. Control and status registers: Used by the processor to control the operation of the processor and by
privileged OS routines to control the execution of programs.
Data registers can be assigned to a variety of functions by the programmer. In some cases, they
are general purpose in nature and can be used with any machine instruction that performs operations on
data.
Address registers contain main memory addresses of data and instructions, or they contain a
portion of the address that is used in the calculation of the complete or effective address.
3. Index register: Indexed addressing is a common mode of addressing that involves adding an index to a
base value to get the effective address.
4. Segment pointer: With segmented addressing, memory is divided into segments, which are variable-
length blocks of words.
5. Stack pointer: If there is user-visible stack2 addressing, then there is a dedicated register that points
to the top of the stack. This allows the use of instructions that contain no address field, such as push and
pop.
6. Program counter (PC): Contains the address of the next instruction to be fetched
Condition codes (also referred to as flags) are bits typically set by the processor hardware as the
result of operations.
The processor contains a single data register, called the accumulator (AC).
OS is a program that controls the execution of application programs and acts as an interface between
applications and the computer hardware.
Three objectives:
1. Convenience: An OS makes a computer more convenient to use.
3. Ability to evolve: An OS should be constructed in such a way as to permit the effective development,
testing, and introduction of new system functions without interfering with service.
2. Program execution: A number of steps need to be performed to execute a program. Instructions and
data must be loaded into main memory, I/O devices and files must be initialized, and other resources
must be prepared.
3. Access to I/O devices: Each I/O device requires its own peculiar set of instructions or control signals
for operation. The OS provides a uniform interface that hides these details so that programmers can
access such devices using simple reads and writes.
4. Controlled access to files: For file access, the OS must reflect a detailed understanding of not only the
nature of the I/O device (disk drive, tape drive) but also the structure of the data contained in the files
on the storage medium.
5. System access: For shared or public systems, the OS controls access to the system as a whole and to
specific system resources.
6. Error detection and response: A variety of errors can occur while a computer system is running. These
include internal and external hardware errors, such as a memory error, or a device failure or
malfunction; and various software errors, such as division by zero, attempt to access forbidden memory
location.
Serial Processing
1. Scheduling: Most installations used a hardcopy sign-up sheet to reserve computer time.
Typically, a user could sign up for a block of time in multiples of a half hour or so.
2. Setup time: A single program, called a job, could involve loading the compiler plus the high-level
language program (source program) into memory, saving the compiled program (object
program) and then loading and linking together the object program and common functions.
The central idea behind the simple batch-processing scheme is the use of a piece of software known as
the monitor.
For this to be so, much of the monitor must always be in main memory and available for execution that
portion is referred to as the resident monitor.
Processor point of view: At a certain point, the processor is executing instructions from
the portion of main memory containing the monitor. These instructions cause the next
job to be read into another portion of main memory.
job control language (JCL)- This is a special type of programming language used to provide instructions
to the monitor.
Memory protection: While the user program is executing, it must not alter the memory
area containing the monitor. If such an attempt is made, the processor hardware should
detect an error and transfer control to the monitor.
Timer: A timer is used to prevent a single job from monopolizing the system. The timer is
set at the beginning of each job. If the timer expires, the user program is stopped, and
control returns to the monitor.
Privileged instructions: Certain machine level instructions are designated privileged and
can be executed only by the monitor.
Interrupts: Early computer models did not have this capability. This feature gives the OS
more flexibility in relinquishing control to and regaining control from user programs.
A user program executes in a user mode, in which certain areas of memory are protected from the user’s
use and in which certain instructions may not be executed.
The monitor executes in a system mode, or what has come to be called kernel mode, in which privileged
instructions may be executed and in which protected areas of memory may be accessed.
Time-Sharing Systems
Just as multiprogramming allows the processor to handle multiple batch jobs at a time,
multiprogramming can also be used to handle multiple interactive jobs. In this latter case, the technique
is referred to as time sharing, because processor time is shared among multiple users.
In a time-sharing system, multiple users simultaneously access the system through terminals, with the
OS interleaving the execution of each user program in a short burst or quantum of computation.
multiprogramming allows the processor to handle multiple batch jobs at a time, multiprogramming can
also be used to handle multiple interactive jobs.
worked. It was extremely simple, which minimized the size of the monitor.