Unit5FIT (1) (1)
Unit5FIT (1) (1)
Unit5FIT (1) (1)
Operating System:
Functions, Measuring System Performance, Assemblers, Compilers and Interpreters.Batch
Processing, Multiprogramming, Multi Tasking, Multiprocessing, Time Sharing, DOS, Windows,
Unix/Linux.
Functions of OS are:
• Memory Management.
• Process Management/CPU Scheduling.
• Device Management.
• File Management.
• Security.
• Accounting.
• Error detection etc.
Operating System is used as a communication channel between the Computer
hardware and the user.
responsibilities:
• It controls all the computer resources.
• It provides valuable services to user programs.
• It coordinates the execution of user programs.
• t hides the complexity of software.
• It supports multiple execution modes.
• It monitors the execution of user programs to prevent errors.
Processor Management
o First Come First Serve (FCFS) Algorithm: In this algorithm, which comes first is
served first by the CPU until it is completed. It is a non-preemptive algorithm which
means it cannot be terminated without completing it.
o Shortest Job First (SJF) Algorithm: The process which has the shortest burst time
(execution time) that will be served first by the CPU.
o Longest Job First (LJF) Algorithm: This algorithm is based on the phenomenon
that the process that has the longest execution time will be served first by the
processor.
o Round Robin Algorithm: In this algorithm, there is a specific time quanta
assigned for each process. If the process is not executed in time quanta, it is sent
to the waiting queue for its next turn.
o Priority Scheduling Algorithm: Processes are given the priority based on
different criteria and scheduled according to the highest priority. Criteria can be
burst time or arrival time etc.
Device Management
An OS manages device communication via its respective drivers.
Allocates devices effectively and efficiently. Deallocates devices when they are
no longer required.
There are various input and output devices. an OS controls the working of these
input-output devices .
It receives the requests from these devices, performs a specific task, and
communicates back to the requesting process.
File Management.
A file system is organized into directories for efficient or easy navigation and
usage. These directories may contain other directories and other files
An OS keeps track of information regarding the creation, deletion, transfer, copy,
and storage of files in an organized way.
It also maintains the integrity of the data stored in these files, including the file
directory structure, by protecting against unauthorized access.
Security.
The operating system uses password protection to protect user data and similar
other techniques. it also prevents unauthorized access to programs and user data
Accounting
Error detection
The operating system constantly monitors the system to detect errors and avoid
malfunctioning computer systems.
From time to time, the operating system checks the system for any external
threat or malicious software activity.
It also checks the hardware for any type of damage.
• vmstat: Reports statistics about virtual memory, disks, traps, and CPU activity. It is used
to dcover system load activity.
• iostat: Reports CPU and input/output statistics for disks, and CD-ROMS.
• monitor (AIX® platform): Starts and stops profiling.
• sar: Records and reports a broad variety of system statistics.
• netstat: Records and reports network activity by displaying the contents of various
network-related data structures.
Here are some common methods and metrics used to measure system performance in an
operating system:
CPU Utilization:
CPU utilization measures how much of the CPU's processing power is being used. It is usually
expressed as a percentage. High CPU utilization can indicate that the CPU is a bottleneck.
Memory Usage:
Monitoring memory usage is essential to ensure that there is enough RAM available for running
processes. Metrics like free memory, used memory, and swap usage are important in this context.
Disk I/O:
Disk input/output (I/O) performance measures how fast data can be read from and written to the
storage devices. Key metrics include read and write throughput, IOPS (Input/Output Operations
Per Second), and disk latency.
Network Throughput:
Network performance metrics measure the rate at which data is transmitted over the network.
This includes metrics like bandwidth utilization, latency, and packet loss.
Response Time:
Response time measures how long it takes for a system to respond to a request or an action. It
can be specific to various components, such as application response time, database query
response time, or web server response time.
System Load:
System load average indicates the number of processes in the run queue, waiting to be executed.
High load averages may suggest system resource contention.
Page Faults:
Page faults occur when a program tries to access a part of memory that is not currently in RAM.
High page fault rates may indicate memory pressure.
Interrupts and Context Switches:
Interrupts and context switches measure the frequency at which the CPU switches between
different tasks
Assemblers, Compilers and Interpreters
Assemblers, compilers, and interpreters are three different types of language translators used in
the field of computer programming and software development.
Assemblers
Purpose:
Assemblers are used to translate assembly language code into machine code.
Assembly language is a low-level programming language that is specific to a particular computer
architecture.
Translation Process: Assemblers perform a one-to-one translation of assembly language
instructions into machine code instructions.
Each assembly language instruction corresponds to a specific machine code instruction.(opcode-
operation code)
Output:
The output of an assembler is typically an object file or binary executable that can be run directly
on the target computer's CPU.
Efficiency:
Assemblers produce highly efficient code because they generate machine code specific to the
hardware architecture.
Debugging: Debugging can be more challenging with assembly language because it is closer to
machine code, making it less human-readable than high-level languages.
Examples: NASM (Netwide Assembler), GAS (GNU Assembler)
ADD
SUB
MUL
Types of assembler
One-Pass Assemblers:
Usage: One-pass assemblers scan the assembly code only once, generating machine code in a
single pass. They are suitable for small or simple assembly programs.
Advantages:
Efficient use of memory and processing power since they perform a single pass.
Faster assembly for small programs.
Disadvantages:
Limited support for forward references (labels that are defined later in the code).
Two-Pass Assemblers:
Usage: Two-pass assemblers read the assembly code twice. In the first pass, they gather symbol
information and calculate memory addresses. In the second pass, they generate machine code.
Working of Pass-2:
Pass-2 of assembler generates machine code by converting symbolic machine-opcodes into their
respective bit configuration(machine understandable form).
Advantages:
Support for forward references, making them suitable for complex programs.
Improved error checking and reporting.
Disadvantages:
Slower than one-pass assemblers due to two passes over the code.
May require more memory and storage for intermediate data.
Example1
#include<stdio.h>
void main() {
int a = 10, b = 20, c;
asm {
mov ax,a
mov bx,b
add ax,bx
mov c,ax
}
printf("c= %d",c);
}
Output:
c= 30
example2
Assembly Program:
Label Op-code operand LC value(Location counter)
JOHN START 200
MOVER R1, ='3' 200
MOVEM R1, X 201
L1 MOVER R2, ='2' 202
LTORG 203
X DS 1 204
END 205
Compiler:
Purpose:
Compilers are used to translate high-level programming languages (e.g., C, C++, Java) into
machine code or an intermediate code (e.g., bytecode).
High-level languages are more human-readable and portable than assembly language.
Translation Process:
Compilers perform a two-step process:
a. Compilation:
They translate the entire source code into an intermediate representation or machine code.
b. Linking (if necessary):
They link various object files and libraries together to create an executable program.
Output: The output of a compiler is typically an executable file that can be run on the target
platform.
Efficiency: Compiled code is usually more efficient than interpreted code because it is optimized
during the compilation process.
Debugging: Debugging can be easier in high-level languages since they offer better abstractions
and debugging tools. However, debugging compiled code may be more challenging than
debugging interpreted code due to optimization and code transformations.
Examples: GCC (GNU Compiler Collection), Clang (C/C++ Compiler), Java Compiler.
Advantages of Compiler
Disadvantages of Compiler
• The compiler can catch only syntax errors and some semantic errors.
• Compilation can take more time in the case of bulky code.
Steps of Programming:
• Program Creation.
• Analysis of language by the compiler and throws errors in case of any incorrect
statement.
• In case of no error, the Compiler converts the source code to Machine Code.
• Linking of various code files into a runnable program.
• Finally runs a Program.
void main()
{
int a=5;
int b=6;
int c= a+b;
printf ( “ the sum is %d”, c);
getch();
}
Output
The sum is 11
Example 2
void main()
{
Printf(“hello world”);
}
Output
Hello world
Complier Interpreter
It does not require source code for It requires source code for later
later execution. execution.
CPU utilization is more in the case of CPU utilization is less in the case of a
a Compiler. Interpreter.
C, C++, C#, etc are programming Python, Ruby, etc are programming
languages that are compiler-based. languages that are interpreter-based.
Interpreter
Purpose:
Interpreters are used to execute high-level programming languages directly without the need for
a separate compilation step. They read and execute the source code line by line.
Translation Process:
Interpreters translate and execute code line by line at runtime, without generating a separate
machine code file.
Output: Interpreters do not produce a separate executable file; they execute the code directly
from the source.
Efficiency: Interpreted code tends to be slower than compiled code because it is translated and
executed line by line, without the optimizations that compilers perform.
Debugging:
Debugging is often easier with interpreters because they can provide immediate feedback,
allowing developers to identify and fix issues as they occur.
Advantage
The advantage of the interpreter is that it is executed line by line which helps users to find errors
easily.
Disadvantage
it takes more time to execute successfully than the compiler.
num1 = 15
num2 = 12
# printing values
print( sum)
output
27
Example 2
Example
print("Hello World!")
Output
Hello World!
Batch processing
Batch processing is a type of processing in which a computer system processes multiple tasks or
jobs in a sequence without the need for user interaction.
Usage
Batch processing is commonly used in operating systems for various purposes, such as running
large-scale data processing jobs, executing repetitive tasks, and managing system resources
efficiently.
Diagram
Job Execution:
The jobs are processed one by one without user intervention. The operating system loads each
job into memory, executes it, and manages its resources. Once a job completes, the results are
typically stored or sent to output devices.
Spooling:
Input and output data may be spooled (simultaneously read/written to disk) to prevent data loss
and to facilitate job execution. This allows one job to read its input data while another job writes
its output data, improving overall system efficiency.
Error Handling: Batch processing systems need robust error handling mechanisms. If a job
encounters an error, the system may log the issue, skip the problematic job, and continue
processing other jobs.
Resource Management: The operating system ensures that each job gets the necessary
resources (CPU time, memory, I/O devices) without causing resource conflicts with other jobs.
Job Prioritization: Jobs are typically assigned priorities, which determine their order of
execution. Higher priority jobs are processed before lower priority jobs.
Batch Monitoring: Operators or administrators can monitor the progress of batch jobs and
intervene when necessary. They may also be responsible for maintaining the hardware and
resolving issues.
Advantages
It isn't easy to forecast how long it will take to complete a job; only batch system processors
This system can easily manage large jobs again and again.
The batch process can be divided into several stages to increase processing speed.
When a process is finished, the next job from the job spool is run without any user interaction.
CPU utilization gets improved.
Disadvantages
:
When a job fails once, it must be scheduled to be completed, and it may take a long time to
complete the task.
Computer operators must have full knowledge of batch systems.
The batch system is quite difficult to debug.
The computer system and the user have no direct interaction.
Multiprogramming
Usage
The primary goal of multiprogramming is to maximize CPU utilization and overall system
throughput by overlapping CPU and I/O operations
Diagram
Advantages
✓ It provides less response time.
✓ It may help to run various jobs in a single application simultaneously.
✓ It helps to optimize the total job throughput of the computer.
✓ Various users may use the multiprogramming system at once.
✓ Short-time jobs are done quickly in comparison to long-time jobs
Disadvantages
Multi Tasking
Multitasking in an operating system (OS) refers to the ability of the OS to manage and switch
usage
CPU Scheduling: The OS employs a CPU scheduling algorithm to determine which task should
execute next. It allocates CPU time to different tasks based on priority, time slices, or other
criteria.
Context Switching: When the OS switches from one task to another, it performs a context
switch. This involves saving the current task's context (register values, program counter, etc.)
and loading the context of the next task. Context switching is a crucial operation in multitasking.
Parallelism: Multitasking can provide the appearance of parallelism, even on a single-core CPU.
Tasks are given time slices to execute, and they take turns using the CPU, creating the illusion of
simultaneous operation.
Multithreading: Some modern operating systems support multithreading, where a single
process is divided into multiple threads. Threads share the same memory space and resources
within a process, making communication and data sharing between threads more efficient.
Real-Time and Non-Real-Time:
Operating systems can support real-time multitasking for systems that require predictable and
immediate responses to events. Non-real-time multitasking is used for general-purpose
computing.
Inter-Process Communication (IPC): In a multitasking environment, tasks often need to
communicate or share data. The OS provides mechanisms for IPC, such as pipes, sockets, and
message queues.
Priority Levels: Some tasks or processes may be given higher or lower priorities based on their
importance or criticality. The OS schedules tasks according to their priority levels.
Resource Management: Multitasking OSes manage system resources like memory, I/O devices,
and network connections among multiple tasks, ensuring fair and efficient resource utilization.
Advantages Disadvantages
In a Symmetrical multiprocessing system, each processor executes the same copy of the
operating system, takes its own decisions, and cooperates with other processes to smooth the
entire functioning of the system.
Further, one processor may act as a master processor or supervisor processor while others are
treated as slave
Process:
A process is an independent program in execution. Each process has its own memory space,
system resources, and can execute independently of other processes. Processes are managed by
the operating system, which schedules them for execution.
Concurrency:
Concurrency is the property of multiple processes running at the same time. It gives the illusion
that multiple tasks are being executed simultaneously. In reality, the CPU rapidly switches
between processes, allowing them to make progress.
Multitasking:
Multitasking is a specific form of concurrency where the CPU switches between processes so
quickly that it appears as if all the tasks are running simultaneously. This is commonly used in
modern operating systems to provide a responsive and efficient environment for users.
Process Scheduling:
The operating system is responsible for scheduling processes and deciding which process to run
next. Process scheduling algorithms determine the order in which processes get access to the
CPU.
Multiprocessing: Multiprocessing, in the context of operating systems, refers to systems that
have multiple CPUs (Central Processing Units) or CPU cores. With multiprocessing, multiple
processes can be executed truly simultaneously because each CPU or core can run its own
process. This leads to improved performance and better multitasking.
Parallel Processing: In a multiprocessing system, if processes are specifically designed to run
on different CPUs or cores, it's called parallel processing
Advantages
Disadvantages
Time sharing, refers to the ability of an operating system to allocate CPU time to multiple tasks
or processes in a way that gives the illusion of parallel execution, even though there is only one
CPU.
Usage
Diagram
1. Active State – The user’s program is under the control of the CPU. Only one
program is available in this state.
2. Ready State – The user program is ready to execute but it is waiting for its
turn to get the CPU. More than one user can be in a ready state at a time.
3. Waiting State – The user’s program is waiting for some input/output
operation. More than one user can be in a waiting state at a time.
Time Slicing:
In time sharing systems, the CPU time is divided into small time slices or time quanta. Each
process is allocated a time slice during which it can execute. When the time slice expires, the
operating system switches to another process. This gives the appearance of concurrent execution,
as each process gets a fair share of CPU time.
Context Switching:
The operating system needs to save the state of the currently executing process and load the state
of the next process when switching between them. This operation is called a context switch. It
ensures that the CPU can seamlessly switch between multiple processes without any noticeable
interruption.
Fairness: Time sharing systems aim to provide fairness to all running processes.
response Time:
Time sharing systems are designed to provide quick response times to user inputs. Interactive
tasks like typing on a keyboard or clicking a mouse button require rapid responses, and time
sharing ensures that the operating system can quickly switch to these tasks.
Resource Sharing:
Time sharing also extends beyond CPU time. It includes sharing other system resources like
memory, input/output devices, and peripherals. Operating systems must manage these resources
effectively to ensure efficient time sharing.
Advantages
✓ Each task gets an equal opportunity.
✓ Fewer chances of duplication of software.
✓ CPU idle time can be reduced.
Disadvantages
✓ Reliability problem.
✓ One must have to take of the security and integrity of user programs and data.
✓ Data communication problem.
A disk operating system (DOS) is a type of operating system that manages data
on a disk storage device.
(DOS) is a type of computer software that helps manage files and data stored
on a computer's disk drive.
File System: DOS used a file system that was typically based on FAT (File Allocation Table).
FAT file systems are relatively simple and were widely used in early PCs.
Diagram
Types of DOS Commands
• Internal Commands − Internal commands are the commands that are built into the command
interpreter or the command prompt of the DOS operating system.
External commands
In DOS are commands that are not built into the command interpreter, but are separate
executable files that need to be located in the system's path
Limitations
✓ Do use the correct syntax for each command
✓ Don't use spaces in file or directory names
DOS was designed to work with limited memory (typically 640 KB of conventional memory).
This memory limitation was a significant constraint on the software that could be run.
Windows:
Windows provides a graphical user interface (GUI) with windows, icons, and a mouse pointer.
It's more user-friendly and intuitive for most users.
Windows 1.0 (1985):
The first version of Windows was more of a graphical user interface (GUI)
Windows 2000 (2000): Windows 2000 was part of the NT (New Technology) series and was
aimed at business users. It brought better stability and security.
Diagram
Key benefits
Graphical User Interface (GUI): Windows is known for its user-friendly GUI, featuring a
desktop with icons, a taskbar, and a start menu. This makes it accessible to a broad range of
users.
Multitasking: Windows supports multitasking, allowing users to run multiple applications
simultaneously. This is essential for productivity.
File System: NTFS (New Technology File System) is the primary file system used in Windows.
It offers features like file encryption, disk quotas, and file compression.
Software Compatibility: Windows has a vast library of software and applications, including
office suites, games, and productivity tools.
User Accounts: Windows allows for the creation of multiple user accounts, each with its own
settings, preferences, and access controls. This is important for shared or family computers.
Security: Security is a major concern, and Windows provides features such as Windows
Defender (antivirus), Windows Firewall, and user account controls to help protect against
malware and unauthorized access.
Kernel:
Linux: Linux has a monolithic kernel that is open source. The kernel is at the core of the
operating system and is responsible for managing hardware resources.
Linux: Linux is widely used in both commercial and non-commercial environments, from data
centers and embedded systems to desktop computers and mobile devices.
1.
• Linux is typically more cost-effective because it is open source, and
many distributions are freely available. Support can be obtained through
various channels, including community forums and paid services.
Diagram
Linux commands
Advantages of Linux
Disadvantages of Linux
It was developed in the 1970s by Ken Thompson, Dennis Ritchie, and others in
the AT&T Laboratories.
Unix was originally designed to run on large, expensive mainframe computers,
while Linux was designed to run on commodity hardware like PCs and servers.
Diagram
Unix Commands
pwd (Print Working Directory): Shows the current directory you are in.
ls (List): Lists the files and directories in the current directory.
cd (Change Directory): Allows you to navigate to different directories.
Touch: Creates an empty file.
touch filename: Creates a file with the given name.
mkdir (Make Directory): Creates a new directory.
mkdir directory_name: Creates a directory with the specified name.
rm (Remove): Deletes files and directories.
rm filename: Deletes a file.
cp (Copy): Copies files or directories.
cp source destination: Copies the source file or directory to the destination.
mv (Move): Moves or renames files and directories.
mv source destination: Moves or renames the source to the destination.
cat (Concatenate): Displays the content of a file.
cat filename: Outputs the contents of the specified file.
Advantages of UNIX:
Disadvantages of UNIX:
1. Complexity: UNIX can be complex and difficult to learn for users who are used to
graphical user interfaces (GUIs).
2. Cost: Some UNIX systems can be expensive, especially when compared to open-source
alternatives like Linux.