Os Unit 1 Material
Os Unit 1 Material
Os Unit 1 Material
A computer consists of processor, memory, and I/O components, with one or more modules of each type.
These components are interconnected in some fashion to achieve the main function of the computer,
which is to execute programs.
There are four main structural elements:
• 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. In contrast, the contents of disk
memory are retained even when the computer system is shut down. Main memory is also referred
to as real memory or primary memory.
• I/O modules: Move data between the computer and its external environment. The external
environment consists of a variety of devices, including secondary memory devices (e.g., disks),
communications equipment, and terminals.
• System bus: Provides for communication among processors, main memory, and I/O modules.
SUB : OPERATING SYSTEM 4TH SEM CE/IT
I/C NAME : PROF. MEGHAL PRAJAPATI
▪ INSTRUCTION EXECUTION:
A program to be executed by a processor consists of a set of instructions stored
in memory. In its simplest form, instruction processing consists of two steps: The
processor reads ( fetches ) instructions from memory one at a time and executes each
instruction.
▪ INTERRUPTS
The occurrence of an event is usually signaled by an Interrupt from either the hardware or
the software. Hardware may trigger an interrupt at any time by sending a signal to the CPU,
usually by way of the system bus. Software may trigger an interrupt executing a special
operation called a System call (also called a monitor call)
Interrupt transfers control to the interrupt service routine generally, through the interrupt
vector, which contains the addresses of all the service routines
Interrupt Handling
The operating system preserves the state of the CPU by storing registers and the program counter.
Determines which type of interrupt has occurred:
Separate segments of code determine what action should be taken for each type of interrupt
▪ CACHE MEMORY
Cache memory, also called cache, supplementary memory system that temporarily stores
frequently used instructions and data for quicker processing by the central processing
unit (CPU) of a computer.
SUB : OPERATING SYSTEM 4TH SEM CE/IT
I/C NAME : PROF. MEGHAL PRAJAPATI
Both main memory and cache are internal random-access memories (RAMs) that use
semiconductor-based transistor circuits. Cache holds a copy of only the most frequently used
information or program codes stored in the main memory. The smaller capacity of the cache
reduces the time required to locate data within it and provide it to the CPU for processing.
When a computer’s CPU accesses its internal memory, it first checks to see if the information
it needs is stored in the cache. If it is, the cache returns the data to the CPU. If the information
is not in the cache, the CPU retrieves it from the main memory.
Structure of OS
A system as large and complex as a modern operating system 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, or modules, rather than have one monolithic system. Each of these modules should be
a well-defined portion of the system, with carefully defined inputs, outputs, and functions.
• Simple structure
• Layered approach
• Microkernels
• Modules
• Hybrid systems
▪ Simple structure:
The Simple structured operating systems do not have a well-defined structure. These systems
will be simple, small and limited systems.
SUB : OPERATING SYSTEM 4TH SEM CE/IT
I/C NAME : PROF. MEGHAL PRAJAPATI
Example: MS-DOS.
There are four layers that make up the MS-DOS operating system, and each has its own set of features.
These layers include ROM BIOS device drivers, MS-DOS device drivers, application programs, and
system programs.
The MS-DOS operating system benefits from layering because each level can be defined independently
and, when necessary, can interact with one another.
If the system is built in layers, it will be simpler to design, manage, and update. Because of this, simple
structures can be used to build constrained systems that are less complex.
Because MS-DOS systems have a low level of abstraction, programs and I/O procedures are visible to
end users, giving them the potential for unwanted access.
o Because there are only a few interfaces and levels, it is simple to develop.
o Because there are fewer layers between the hardware and the applications, it offers superior
performance.
o The entire operating system breaks if just one user program malfunctions.
SUB : OPERATING SYSTEM 4TH SEM CE/IT
I/C NAME : PROF. MEGHAL PRAJAPATI
o Since the layers are interconnected, and in communication with one another, there is no abstraction
or data hiding.
o The operating system's operations are accessible to layers, which can result in data tampering and
system failure.
▪ Monolithic Structure:
The monolithic operating system controls all aspects of the operating system's operation, including file
management, memory management, device management, and operational operations.
The core of an operating system for computers is called the kernel (OS). All other System components
are provided with fundamental services by the kernel. The operating system and the hardware use it as
their main interface. When an operating system is built into a single piece of hardware, such as a keyboard
or mouse, the kernel can directly access all of its resources.
The monolithic operating system is often referred to as the monolithic kernel. Multiple programming
techniques such as batch processing and time-sharing increase a processor's usability. Working on top of
the operating system and under complete command of all hardware, the monolithic kernel performs the
role of a virtual computer. This is an old operating system that was used in banks to carry out simple
tasks like batch processing and time-sharing, which allows numerous users at different terminals to access
the Operating System.
SUB : OPERATING SYSTEM 4TH SEM CE/IT
I/C NAME : PROF. MEGHAL PRAJAPATI
o Because layering is unnecessary and the kernel alone is responsible for managing all operations, it
is easy to design and execute.
o Due to the fact that functions like memory management, file management, process scheduling, etc.,
are implemented in the same address area, the monolithic kernel runs rather quickly when compared
to other systems. Utilizing the same address speeds up and reduces the time required for address
allocation for new processes.
o The monolithic kernel's services are interconnected in address space and have an impact on one
another, so if any of them malfunctions, the entire system does as well.
o It is not adaptable. Therefore, launching a new service is difficult.
▪ Layered Structure:
The OS is separated into layers or levels in this kind of arrangement. Layer 0 (the lowest layer)
contains the hardware, and layer 1 (the highest layer) contains the user interface (layer N). These
SUB : OPERATING SYSTEM 4TH SEM CE/IT
I/C NAME : PROF. MEGHAL PRAJAPATI
layers are organized hierarchically, with the top-level layers making use of the capabilities of the
lower-level ones.
The functionalities of each layer are separated in this method, and abstraction is also an option. Because
layered structures are hierarchical, debugging is simpler, therefore all lower-level layers are debugged
before the upper layer is examined. As a result, the present layer alone has to be reviewed since all the
lower layers have already been examined.
o Work duties are separated since each layer has its own functionality, and there is some amount of
abstraction.
o Debugging is simpler because the lower layers are examined first, followed by the top layers.
▪ Microkernels Structure:
The operating system is created using a micro-kernel framework that strips the kernel of any
unnecessary parts. Systems and user applications are used to implement these optional kernel
components. So, Micro-Kernels is the name given to these systems that have been developed.
SUB : OPERATING SYSTEM 4TH SEM CE/IT
I/C NAME : PROF. MEGHAL PRAJAPATI
Each Micro-Kernel is created separately and is kept apart from the others. As a result, the system is now
more trustworthy and secure. If one Micro-Kernel malfunctions, the remaining operating system is
unaffected and continues to function normally.
▪ Modules:
SUB : OPERATING SYSTEM 4TH SEM CE/IT
I/C NAME : PROF. MEGHAL PRAJAPATI
The best current methodology for operating-system design involves using loadable kernel modules
The kernel has a set of core components and links in additional services via modules, either at boot time
or during run time.
The kernel provides core services while other services are implemented dynamically, as the kernel is
running.
Linking services dynamically is more comfortable than adding new features directly to the kernel, which
would require recompiling the kernel every time a change was made.
Example: Solaris OS
The Solaris operating system structure is organized around a core kernel with seven types of loadable
kernel modules:
• Scheduling classes
• File systems
• Loadable system calls
• Executable formats
• STREAMS modules
• Miscellaneous
• Device and bus drivers
▪ Hybrid Systems:
The Operating System combines different structures, resulting in hybrid systems that address performance,
security, and usability issues.
They are monolithic, because having the operating system in a single address space provides very efficient
performance.
However, they are also modular, so that new functionality can be dynamically added to the kernel.
Example: Linux and Solaris are monolithic (simple) and also modular, IOS.
Basic Function of OS
The main operation performed by operating system is to carries out is the allocation of resources
and services, such as allocation of the following −
• Memory
SUB : OPERATING SYSTEM 4TH SEM CE/IT
I/C NAME : PROF. MEGHAL PRAJAPATI
• Devices
• Processors
• Information
The operating system includes programs that are helpful to manage these resources, such as a traffic
controller, a scheduler, memory management module, I/O programs, and a file system.
Job Accounting
Operating systems always keep track of time and resources that are used by various tasks and users, this
information can be used to track resource usage for a particular user or a group of users.
Memory Management
The operating system controls the primary memory or main memory. Primary memory is a large array
of bytes or words where each byte or word is assigned a certain address. It is a fast storage, and it can
be accessed directly by the CPU which is present inside the system. If a program wants to be executed,
it should be first loaded in the main memory.
The following activities are performed by operating system for memory management −
• It keeps track of primary memory.
• Memory addresses that have already been allocated and the memory addresses of the memory
that has not yet been used.
• In multiprogramming, the OS decides for how long the process must stay and the order in which
processes are granted access to memory.
• It allocates the memory to a process when the process requests it and deallocates the memory
when the process has terminated.
SUB : OPERATING SYSTEM 4TH SEM CE/IT
I/C NAME : PROF. MEGHAL PRAJAPATI
Processor Management
The OS manages the order in which processes have access to the processor, and how much processing
time that each process must stay in the multiprogramming environment. This is called process
scheduling.
The following activities are performed by operating system for processor management −
• Keeps track of the status of processes.
• The program to track the status is known as traffic controller.
• It allocates the CPU and deallocates the processor when it is not required.
Device Management
An OS manages device communication through respective drivers.
The following activities are performed by the operating system for device management.
• Keeping track of all devices connected to the system.
• The OS designates a program that is responsible for every device which is called the Input/output
controller.
• It decides which process gets access to which device and for how long. It then allocates the
devices in an effective and efficient way and de-allocates devices when they are not required.
File Management
A file system is arranged into directories for efficient navigation and usage. These directories contain
other directories and other files.
The following activities are performed by operating system for file management activities −
• It keeps track of where information is stored, user access settings and status of every file and
more.
• These facilities are called the file system.
System Calls
The interface between a process and an operating system is provided by system calls. In general,
system calls are available as assembly language instructions.
SUB : OPERATING SYSTEM 4TH SEM CE/IT
I/C NAME : PROF. MEGHAL PRAJAPATI
System calls are usually made when a process in user mode requires access to a resource. Then it
requests the kernel to provide the resource via a system call.
As can be seen from this diagram, the processes execute normally in the user mode until a system call
interrupts this. Then the system call is executed on a priority basis in the kernel mode. After the
execution of the system call, the control returns to the user mode and execution of user processes can
be resumed.
System calls are required in the following situations −
• If a file system requires the creation or deletion of files. Reading and writing from files also
require a system call.
• Creation and management of new processes.
• Network connections also require system calls. This includes sending and receiving packets.
• Access to a hardware devices such as a printer, scanner etc. requires a system call.
Process Control
These system calls deal with processes such as process creation, process termination etc.
File Management
These system calls are responsible for file manipulation such as creating a file, reading a file, writing
into a file etc.
Device Management
These system calls are responsible for device manipulation such as reading from device buffers,
writing into device buffers etc.
Information Maintenance
These system calls handle information and its transfer between the operating system and the user
program.
Communication
These system calls are useful for inter-process communication. They also deal with creating and
deleting a communication connection.
Types of OS
An operating system is a well-organized collection of programs that manages the computer hardware.
It is a type of system software that is responsible for the smooth functioning of the computer system.
In the 1970s, Batch processing was very popular. In this technique, similar types of jobs were batched
together and executed in time. People were used to having a single computer which was called a
mainframe.
In Batch operating system, access is given to more than one person; they submit their respective jobs to
the system for the execution.
The system put all of the jobs in a queue on the basis of first come first serve and then executes the jobs
one by one. The users collect their respective output when all the jobs get executed.
Disadvantages of Batch OS
1. Starvation
For Example:
2. Not Interactive
SUB : OPERATING SYSTEM 4TH SEM CE/IT
I/C NAME : PROF. MEGHAL PRAJAPATI
Batch Processing is not suitable for jobs that are dependent on the user's input. If a job requires the input
of two numbers from the console, then it will never get it in the batch processing scenario since the user
is not present at the time of execution.
In a multiprogramming environment, when a process does its I/O, The CPU can start the execution of
other processes. Therefore, multiprogramming improves the efficiency of the system.
Advantages of Multiprogramming OS
o Throughout the system, it increased as the CPU always had one program to execute.
o Response time can also be reduced.
Disadvantages of Multiprogramming OS
o Multiprogramming systems provide an environment in which various systems resources are used
efficiently, but they do not provide any user interaction with the computer system.
SUB : OPERATING SYSTEM 4TH SEM CE/IT
I/C NAME : PROF. MEGHAL PRAJAPATI
In Multiprocessing, Parallel computing is achieved. More than one processor present in the
system can execute more than one process simultaneously, which will increase the throughput
of the system.
o Increased reliability: Due to the multiprocessing system, processing tasks can be distributed
among several processors. This increases reliability as if one processor fails, the task can be
given to another processor for completion.
o Increased throughout: As several processors increase, more work can be done in less.
o Multiprocessing operating system is more complex and sophisticated as it takes care of multiple CPUs
simultaneously.
The Application of a Real-Time system exists in the case of military applications, if you want to
drop a missile, then the missile is supposed to be dropped with a certain precision.