BCS303
BCS303
OPERATING SYSYTEMS
Prepared By:
Saritha N
Assistant Professor
Department of CS&E
AIT Chikkamagaluru
Module 1
Chapter 1
System structures
Introduction
1. User view:
Case-1
• Most computer users sit in front of a PC, consisting of a
monitor/keyboard/ mouse, and system unit.
• Such a system is designed for one user to monopolize its
resources. The goal is to maximize the work (or play) that the
user is performing.
• In this case OS is designed for ease of use,no attention paid to
resource utilization
Case-2
• a user sits at a terminal connected to a mainframe or a mini
computer. Other users are accessing the same computer through
other terminals.
• These users share resources and may exchange information.
• The operating system in such cases is designed to maximize resource
utilization.
• To assure that all available CPU time, memory, and I/0 are used
efficiently and that no individual user takes more than her fair share.
Case 3
• In still other cases, users sit at connected to networks of other
workstations and These users have dedicated resources at their
disposal, but they also share resources such as networking and
servers-file, compute, and print servers.
• Therefore, their operating system is designed to compromise between
individual usability and resource utilization.
Systems View
• From the computer's point of view, the operating system is the program most
intimately involved with the hardware.
• In this context, we can view an operating system as a resource allocator.
• A computer system has many resources that may be required to solve a problem:
CPU time, memory space, file-storage space, I/0 devices, and so on.
• The operating system acts as the manager of these resources.
• Facing numerous and possibly conflicting requests for resources, the operating
system must decide how to allocate them to specific programs and users so that it
can operate the computer system efficiently and fairly.
• A bit is the basic unit of computer storage- it can contain 0 0r 1
• All other storage in a computer is based on collections of bits.
• numbers, letters, images, movies, sounds, documents, and programs,
• 1 byte-8bits
Computer System Organization
• Computer System Operation
• Storage Structure
• I/O structure
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
• Each device controller is in charge of a specific type of device
• 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 provided whose function is to synchronize access to the shared
memory.
Some important Terms:
1. Bootstrap Program
• the initial program that runs when a computer is powered up or
rebooted
• It is stored in the ROM
• It must know how to load the OS and start executing that system.
• It must locate and load into memory the OS kernal
2. Interrupt
• The occurrence of an event is usually signalled by an interrupt from
hardware or software
• Hardware may Trigger an interrupt at any time by sending a signal to the
CPU, usually by the way of the system bus
3. System Call
• Software may trigger an interrupt by executing a special operating
system call
• When the CPU is interrupted, it stops what it is doing and immediately
transfers execution to a fixed location
• Fixed location: Usually contains the starting address where the service
routine of the interrupt is located.
• The interrupt Service Routine executes
• On completion, the CPU resumes the interrupted computation.
Storage Structure
I/O Stucture
Computer System Architecture
1. Single Processor Systems
2. Multi Processor system
3. Clustered Systems
1.Single Processor System
● One single CPU capable of executing a general purpose instruction
set including instructions from user processes
● Other Special purpose processors are also present which perform
device specific task ( for devices such as disk, keyboard, and graphics
controllers.)
● 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.
Multi -Processor 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:
○ Increased throughput
○ Economy of scale
○ Increased reliability
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’:
1. Graceful degradation
As there are multiple processors when one processor fails other
processor will take up its work and the system go down slowly.
2. Fault tolerant
When one processor fails, its operations are stopped, the system
failure is then detected, diagnosed, and corrected.
Different types of multiprocessor systems:
• A single user cannot , in general, keep either the CPU or the I/O
devices busy all the time
• Multiprogramming increases CPU utilization by organizing jobs (code
and data) so that the CPU always has one to execute.
job
job 11 2job 2
job 4
job 3
• Multi programming systems provide an environment in which the
various system resources (eg: CPU, memory, peripheral devices etc.)
are utilized effectively, but they do not provide for user interaction
with the computer system.
Multi Tasking (Time Shraing)
• CPU executes multiple jobs by switching among them
• Switches occur so frequently that the users can interact with each
program while it is running
• Time Sharing requires a interactive (or hand on) computer system,
which provides direct communication between the user and the
system
• A time shared operating system allows many users to share the
computer simultaneously
• Uses CPU scheduling and multiprogramming to provide each user
with a small portion of a time shared computer.
• Each user has at least one separate program in memory
• Program
Operating-System Operations
• Modern operating systems are interrupt driven.
• If there are no processes to execute, no I/O devices to service, and
no users to whom to respond, an operating system will sit quietly,
waiting for something to happen.
• Events are signaled by the occurrence of an interrupt or a trap. A
trap (or an exception) is a software-generated interrupt.
• For each type of interrupt, separate segments of code in the
operating system determine what action should be taken.
• An interrupt service routine is provided that is responsible for
dealing with the interrupt.
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:
1. User mode
2. 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:
1. Kernel (0)
2. 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.
• 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.
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:
1. Keeping track of which parts of memory are currently being used by user.
2. Deciding which processes and data to move into and out of memory.
3. Allocating and deallocating memory space as needed.
Storage Management
• If a computer system has multiple users and allows the concurrent execution of
multiple processes, then access to data must be regulated.
• For that purpose, mechanisms ensure that files, memory segments, CPU, and
other resources can be operated on by only those processes that have gained
proper authorization from the operating system.
• For example, memory-addressing hardware ensures that a process can execute
only within its own address space.
• The timer ensures that no process can gain control of the CPU for a long time.
• Device-control registers are not accessible to users, so the integrity of the
various peripheral devices is protected.
• Protection is a mechanism for controlling the access of processes or users
to the resources defined by a computer system.
• This mechanism must provide means for specification of the controls to be
imposed and means for enforcement.
• Protection improves reliability.
• A protection-oriented system provides a means to distinguish between
authorized and unauthorized usage.
• A system can have adequate protection but still be prone to failure and
allow inappropriate access.
• Consider a user whose authentication information is stolen. Her data could be copied
or deleted, even though file and memory protection are working. It is the job of
security to defend a system from external and internal attacks. Such attacks spread
across a huge range and include viruses and worms, denial-of service attacks etc.
• Protection and security require the system to be able to distinguish among all its users.
Most operating systems maintain a list of user names and associated user identifiers
(user IDs). When a user logs in to the system, the authentication stage determines the