Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views23 pages

OS Unit 1 Notes

The document provides a comprehensive overview of operating systems, detailing their types, functions, and components, including process management and scheduling. It discusses various operating system architectures and specific examples such as Linux and Windows. Additionally, it covers the advantages and disadvantages of different operating systems, including real-time and mobile operating systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views23 pages

OS Unit 1 Notes

The document provides a comprehensive overview of operating systems, detailing their types, functions, and components, including process management and scheduling. It discusses various operating system architectures and specific examples such as Linux and Windows. Additionally, it covers the advantages and disadvantages of different operating systems, including real-time and mobile operating systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Syllabus Topics :- Unit 1- Introduction to Operating System and Process :

Introduction to operating systems, Types of OS, real time OS,


the Linux Operating Systems Process: process abstraction, system calls for process
management, process creation: process states, data structures, process execution mechanisms
process api, process control and users
Case study : Windows 11/Linux

1 .Introduction to operating systems:-


An operating system acts as an intermediary between the user of a computer and computer hardware. In short its an
interface between computer hardware and user.

● The purpose of an operating system is to provide an environment in which a user can execute programs
conveniently and efficiently.
● An operating system is software that manages computer hardware and software. The hardware must provide
appropriate mechanisms to ensure the correct operation of the computer system and to prevent user programs
from interfering with the proper operation of the system.
● The operating system (OS) is a program that runs at all times on a computer. All other programs, including
application programs, run on top of the operating system.
● It does assignment of resources like memory, processors and input / output devices to different processes that
need the resources. The assignment of resources has to be fair and
secure.
2. Functions of an Operating System
1. Process Management
○ Creation, scheduling, and termination of processes
○ CPU scheduling algorithms
2. Memory Management
○ Allocation and deallocation of memory spaces
○ Virtual memory and paging
3. File System Management
○ File creation, deletion, access control, and storage

4. Device Management
○ Managing I/O devices through drivers and I/O scheduling

5. Security and Protection


○ Preventing unauthorized access
○ Ensuring data integrity

6. User Interface
○ Command-Line Interface (CLI)
○ Graphical User Interface (GUI)
3 .What is an Operating System Used for?

 As a platform for Application programs: It provides a platform, on top of which, other programs, called application
programs can run.
 Managing Input-Output unit: It also allows the computer to manage its own resources such as memory, monitor,
keyboard, printer, etc. Management of these resources is required for effective and fair utilization.
 Multitasking: It manages memory and allows multiple programs to run in their own space and even communicate
with each other through shared memory.
 Manages memory and Files: It manages the computer’s main memory and second storage. Additionally, it allows
and deallocates memory to all tasks and applications.
 Provides Security: It helps to maintain the system and applications safe through the authorization process. Thus,
the OS provides security to the system

3. Types of Operating Systems


● Batch Operating System

● Time-Sharing (Multitasking) Operating System

● Distributed Operating System

● Real-Time Operating System (RTOS)

● Multi-User and Single-User OS

● Mobile OS

1.Batch Operating System


This type of operating system does not interact with the computer directly. There is an operator which takes similar jobs
having the same requirements and groups them into batches. It is the responsibility of the operator to sort jobs with
similar needs. Batch Operating System is designed to manage and execute a large number of jobs efficiently by
processing them in groups.
Advantages of Batch Operating System

 Multiple users can share the batch systems.


 The idle time for the batch system is very little.
 It is easy to manage large work repeatedly in batch systems.

Disadvantages of Batch Operating System


 CPU is not used efficiently. When the current process is doing IO, the CPU is free and could be utilized by other
processes waiting.
 The other jobs will have to wait for an unknown time if any job fails.
 In a batch operating system, average response time increases as all processes are processed one by one.

Examples of Batch Operating Systems: Payroll Systems, Bank Statements, etc.

2.Multi-Programming Operating System


Multiprogramming Operating Systems can be simply illustrated as more than one program is present in the main memory
and any one of them can be kept in execution. This is used for better utilization of resources.

Advantages of, Multi-Programming Operating System

 CPU is better utilized, and the overall performance of the system improves.
 It helps in reducing the response time.

3. Multi-tasking/Time-sharing Operating systems-


It is a type of Multiprogramming system with every process running in round robin manner. Each task is given some time
to execute so that all the tasks work smoothly. Each user gets the time of the CPU as they use a single system. These
systems are also known as Multitasking Systems. The task can be from a single user or different users. The time that
each task gets to execute is called quantum. After this time interval is over, the OS switches over to the next task.
Advantages of Time-Sharing OS

 Each task gets an equal opportunity.


 Fewer chances of duplication of software.
 CPU idle time can be reduced.
 Resource Sharing: Time-sharing systems allow multiple users to share hardware resources such as the CPU,
memory, and peripherals, reducing the cost of hardware and increasing efficiency.
 Improved Productivity: Time-sharing allows users to work concurrently, thereby reducing the waiting time for their
turn to use the computer. This increased productivity translates to more work getting done in less time.
 Improved User Experience: Time-sharing provides an interactive environment that allows users to communicate with
the computer in real time, providing a better user experience than batch processing.

Disadvantages of Time-Sharing OS

 Reliability problem.
 One must take care of the security and integrity of user programs and data.
 Data communication problem.
 High Overhead: Time-sharing systems have a higher overhead than other operating systems due to the need for
scheduling, context switching, and other overheads that come with supporting multiple users.
 Complexity: Time-sharing systems are complex and require advanced software to manage multiple users
simultaneously. This complexity increases the chance of bugs and errors.
 Security Risks: With multiple users sharing resources, the risk of security breaches increases. Time-sharing systems
require careful management of user access, authentication, and authorization to ensure the security of data and
software.
Examples of Time-Sharing OS with explanation

 IBM VM/CMS: IBM VM/CMS is a time-sharing operating system that was first introduced in 1972. It is still in use
today, providing a virtual machine environment that allows multiple users to run their instances of operating systems
and applications.
 TSO (Time Sharing Option): TSO is a time-sharing operating system that was first introduced in the 1960s by IBM
for the IBM System/360 mainframe computer. It allowed multiple users to access the same computer simultaneously,
running their applications.
 Windows Terminal Services: Windows Terminal Services is a time-sharing operating system that allows multiple
users to access a Windows server remotely. Users can run their applications and access shared resources, such as
printers and network storage, in real time.

4.Multi-Processing Operating System


A Multi-Processing Operating System is a type of Operating System in which more than one CPU is used for the
execution of resources. It betters the throughput of the System.

Advantages of a Multi-User Operating System


 It increases the throughput of the system as processes can be parallelized.
 As it has several processors, so, if one processor fails, we can proceed with another processor.

5.. Multi-User Operating Systems


These systems allow multiple users to be active at the same time. This system can be either a multiprocessor or a single
processor with interleaving.
6. Distributed Operating System
These types of operating systems are a recent advancement in the world of computer technology and are being widely
accepted all over the world and, that too, at a great pace. Various autonomous interconnected computers communicate
with each other using a shared communication network. Independent systems possess their own memory unit and
CPU. Systems. These systems' processors differ in size and function. The major benefit of working with these types of
operating systems is that it is always possible that one user can access the files or software which are not present on his
system but on some other system connected within this network, i.e., remote access is enabled within the devices
connected to that network.

Advantages of Distributed Operating System


 Failure of one will not affect the other network communication, as all systems are independent of each other.
 Electronic mail increases the data exchange speed.
 Since resources are being shared, computation is highly fast and durable.
 Load on host computer reduces.
 These systems are easily scalable as many systems can be easily added to the network.
 Delay in data processing reduces.

Disadvantages of Distributed Operating System


 Failure of the main network will stop the entire communication.
 To establish distributed systems, the language is not yet well-defined.
 These types of systems are not readily available as they are very expensive. Not only that the
underlying software is highly complex and not understood well yet.
Examples of Distributed Operating Systems are LOCUS, etc

7. Network Operating System


These systems run on a server and provide the capability to manage data, users, groups, security, applications, and
other networking functions. These types of operating systems allow shared access to files, printers, security, applications,
and other networking functions over a small private network. One more important aspect of Network Operating Systems
is that all the users are well aware of the underlying configuration, of all other users within the network, their connections,
etc., and that’s why these computers are popularly known a tightly coupled systems.
Advantages of Network Operating System

 Highly stable, centralized servers.


 Security concerns are handled through servers.
 New technologies and hardware upgrades are easily integrated into the system.
 Server access is possible remotely from different locations and types of systems.

Disadvantages of Network Operating System

 Servers are costly.


 The user has to depend on a central location for most operations.
 Maintenance and updates are required regularly.
Examples of Network Operating Systems are Microsoft Windows Server 2003, Microsoft Windows Server 2008, UNIX,
Linux, Mac OS X, Novell NetWare, BSD, etc.
7. Real-Time Operating System
These types of OSs serve real-time systems. The time interval required to process and respond to inputs is very small.
This time interval is called response time. Real-time systems are used when there are time requirements that are very
strict like missile systems, air traffic control systems, robots, etc.

Types of Real-Time Operating Systems

 Hard Real-Time Systems: Hard Real-Time OSs are meant for applications where time constraints are very strict,
and even the shortest possible delay is not acceptable. These systems are built for saving lives like automatic
parachutes or airbags which are required to be readily available in case of an accident. Virtual memory is rarely
found in these systems.
 Soft Real-Time Systems: These OSs are for applications where time is less strict.
Advantages of RTOS

 Maximum Consumption: Maximum utilization of devices and systems, thus more output from all the resources.
 Task Shifting: The time assigned for shifting tasks in these systems is very less. For example, in older systems, it
takes about 10 microseconds to shift from one task to another, and in the latest systems, it takes 3 microseconds.
 Focus on Application: Focus on running applications and give less importance to applications that are in the queue.
 Real-time operating system in the embedded system: Since the size of programs is small, RTOS can also be
used in embedded systems like in transport and others.
 Error-Free,: These types of systems are error-free.
 Memory Allocation: Memory allocation is best managed in these types of systems.

Disadvantages of RTOS
 Limited Tasks: Very few tasks run at the same time and their concentration is very less on a few applications to
avoid errors.
 Use heavy system resources: Sometimes the system resources are not so good and they are expensive as well.
 Complex Algorithms: The algorithms are very complex and difficult for the designer to write.
 Device driver and interrupt signals: It needs specific device drivers and interrupt signals to respond earliest to
interrupts.
 Thread Priority: It is not good to set thread priority, as these systems are much less prone to switching tasks.
Examples of Real-Time Operating Systems are Scientific experiments, medical imaging systems, industrial control
systems, weapon systems, robots, air traffic control systems, etc.

8. Mobile Operating Systems


Mobile operating systems are designed specifically for mobile devices such as smartphones and tablets. Examples of
such operating systems are Android and iOS. These operating systems manage the hardware and software resources of
the device, providing a platform for running applications and ensuring a seamless user experience.

 Advantages of Mobile Operating Systems


User-Friendly Interfaces: Mobile operating systems are designed to be intuitive and easy to use, making them
accessible to a wide range of users.
Extensive App Ecosystems: The availability of a vast number of applications allows users to customize their devices to
meet their specific needs.
Connectivity Options: Mobile operating systems support multiple connectivity options, enabling users to stay connected
wherever they go.
Regular Updates: Mobile operating systems receive regular updates, including new features, security patches, and
performance improvements.

 Disadvantages Mobile Operating Systems

Battery Life Constraints: Despite advancements in power management, battery life remains a challenge for mobile
devices, especially with heavy usage.
Security Risks: Mobile devices are susceptible to various security threats, such as malware and phishing attacks, which
can compromise user data.
Fragmentation: In the case of Android, the wide range of devices and customizations can lead to fragmentation, making
it difficult for developers to ensure compatibility across all devices.
Limited Hardware Resources: Mobile devices have limited processing power, memory, and storage compared to
desktop computers, which can affect the performance of resource-intensive applications.
4. System Components
● Kernel: Core component that controls everything in the system

● Shell: Interface between the user and the kernel

● System Calls: APIs for the OS to execute functions requested by the program

5. Process Concepts
● Definition of a Process: A process is a program in execution.

● Process States:

○ New

○ Ready

○ Running

○ Waiting (Blocked)

○ Terminated

● Process Control Block (PCB):

○ Process ID, state, registers, program counter, etc.

6. Process Scheduling
● Schedulers:

○ Long-term scheduler (Job scheduler)

○ Short-term scheduler (CPU scheduler)

○ Medium-term scheduler

● Context Switching:

○ Saving and loading process states during a switch

7. Threads
● Definition: A thread is the smallest unit of CPU execution
● Multithreading:

○ Allows multiple threads within the same process

○ Shared memory space among threads

● Benefits:

○ Faster context switching

○ Efficient resource sharing

8. Process vs Program
Process Program

Dynamic Static

In execution Stored on disk

Needs Doesn’t need resources


resources

9. Types OF Operating System Architectures


● Monolithic Kernel

● Microkernel

● Layered Architecture

● Modular Kernel

● Hybrid Kernel
 The Linux Operating System: Process Management Overview:-

In Linux, a process refers to a program in execution. The operating system uses process abstraction to manage and
allocate system resources. The goal is to provide a way to run multiple processes concurrently while ensuring that each
gets a fair share of the CPU, memory, and I/O devices.

Here's a breakdown of various aspects related to process management in Linux:

1. Process Abstraction

● Process: The basic unit of execution. A process is a running instance of a program and includes:

○ Program code (text section)

○ Data (global variables, stack, heap)

○ Process Control Block (PCB): Stores the state of the process, program counter, registers, etc.

● Process vs Thread: A process can contain one or more threads. A thread is a single sequence of instructions within
a process. Threads share resources of the process, such as memory, but each has its own execution context.

2. System Calls for Process Management

System calls are the interface between user applications and the kernel. For process management, some of the commonly
used system calls include:

● fork(): Creates a new process by duplicating the calling process. The child process is a copy of the parent.

● exec(): Replaces the current process image with a new one (used after a fork() to run a different program).

● wait(): Makes the parent process wait until one of its child processes terminates.

● exit(): Terminates the calling process and sends an exit status to its parent.

● getpid(): Retrieves the process ID (PID) of the calling process.

● kill(): Sends a signal to a process. It can be used to terminate a process or communicate with it.

3. Process Creation

Process creation in Linux involves the following steps:

● fork(): When a process calls fork(), a child process is created. The child process is a copy of the parent, but they
have separate memory spaces and their own PIDs.
● exec(): After fork(), the child process can call exec() to replace its memory space with a new program, allowing it to
run a different executable.

● init process: Every process is created as a descendant of the init process (PID = 1). It is responsible for system
startup and spawning other processes.

4. Process States

A process can exist in one of several states:

● New: The process is being created.

● Ready: The process is ready to run, waiting for the CPU to execute it.

● Running: The process is actively executing on the CPU.

● Waiting: The process is waiting for some event or resource, such as I/O completion or a signal.

● Terminated: The process has finished execution or has been killed. It is then cleaned up by the kernel (zombie state)
before being removed entirely.

5. Data Structures

In Linux, processes are represented by a Process Control Block (PCB), which contains crucial information about a process.
The PCB stores:

● PID: The unique process identifier.

● Parent PID (PPID): The process ID of the parent process.

● State: The current state of the process (running, waiting, etc.).

● Registers: The values of the CPU registers during the process's execution.

● Memory management information: Information about memory allocation for the process.

● File descriptors: A list of open files associated with the process.

● Scheduling information: Information used by the scheduler to decide when the process should run.

These data structures are essential for managing and tracking processes in the system.

6. Process Execution Mechanisms

● Context Switching: The kernel periodically suspends one process and switches to another. This process involves
saving the state (context) of the current process and loading the state of the next process. It's critical for
multitasking.
● Scheduling: Linux uses several scheduling policies (such as Completely Fair Scheduler (CFS)) to determine which
process gets CPU time next. The scheduler ensures fair distribution of CPU time among all processes.

● Preemption: Linux is a preemptive multitasking system, which means that the kernel can interrupt running
processes to give CPU time to other processes if needed.

7. Process API

The Process API is an interface that allows programs to interact with processes. Some of the common functions provided by
the API include:

● fork(): Creates a new child process.

● exec(): Replaces the current process with a new program.

● waitpid(): Allows a parent process to wait for a specific child process to terminate.

● getpid(): Retrieves the PID of the current process.

● getppid(): Retrieves the PID of the parent process.

8. Process Control

Process control refers to the actions that can be taken to manage processes, including:

● Termination: A process can be terminated through system calls like exit() or signals like kill(). The termination can
be either normal (successful completion) or abnormal (due to a crash or manual intervention).

● Signals: A signal is a message sent to a process to notify it of an event. Signals can be used for inter-process
communication (IPC) or to control process execution (e.g., SIGTERM, SIGKILL).

9. User Interaction with Processes

Linux allows users to interact with processes in a variety of ways:

● ps: Displays the current processes.

● top: Displays a real-time view of running processes, including CPU and memory usage.

● kill: Sends signals to a process, often used to terminate processes.

● nice: Changes the priority of a process.

● strace: Traces system calls made by a process, useful for debugging.


Summary

Process management in Linux is a sophisticated mechanism that ensures processes run concurrently and efficiently. Linux
provides system calls, data structures, and process states to manage these processes. The process API allows interaction
between user programs and the kernel to create, control, and terminate processes. Understanding these mechanisms is key
to understanding how Linux handles multitasking, scheduling, and inter-process communication.

—--------------------------------------------------------------------------------------------------

1. Process Abstraction in Linux

In Linux, a process is an instance of a running program. The OS abstracts and manages each process separately,
assigning resources like memory, CPU time, and I/O.

Key Elements of a Process:


● PID (Process ID): Unique identifier

● Memory space: Includes code, data, stack, and heap

● Registers and Program Counter

● Open file descriptors

● Parent process ID (PPID)

Example:

When you run a program like:

bash

CopyEdit

gedit file.txt

The Linux kernel creates a new process for gedit with a unique PID.

2. System Calls for Process Management

System calls are kernel-level services accessible by user programs to perform operations like creating or killing processes.
Common System Calls:
System Call Description

fork() Creates a new process (child)

exec() Replaces current process with a new program

wait() Makes parent wait for child to finish

exit() Terminates the process

getpid() Returns process ID

kill() Sends signal to process (e.g., terminate)

Example in C:

C lang:-

#include <unistd.h>

#include <stdio.h>

int main() {

pid_t pid = fork();

if (pid == 0) {

printf("This is the child process\n");

} else {

printf("This is the parent process\n");

return 0;

3. Process Creation in Linux

Linux uses a parent-child model for creating processes.


Steps:

1. Parent calls fork() – a child is created as a copy.

2. Child calls exec() (optional) to load a new program.

3. Parent can call wait() to wait for the child.

Example:

bash

CopyEdit

bash$ sleep 100 &

[1] 3456 # PID 3456

The sleep command becomes a background process.

4. Process States

A process transitions between several states during its lifetime:

State Description

Running Currently executing on CPU

Ready Ready to run, waiting for CPU

Waiting Waiting for I/O or event

Stopped Suspended (e.g., with Ctrl+Z)

Zombie Finished but not cleaned up

Terminated Completed execution


Example:

● Run ps -el to view process states (look under the “STAT” column).

5. Data Structures in Linux (Kernel-level)

Linux maintains internal data structures to track processes:

task_struct

Defined in the kernel, holds all process info.

Important fields:

● pid: Process ID

● state: Current state

● mm: Memory info

● files: Open files

● parent: Pointer to parent process

Example:

You can view process details with:

bash

CopyEdit

cat /proc/1234/status

6. Process Execution Mechanism

Context Switching

● The kernel switches from one process to another.

● Saves current state and loads the next.

Scheduler

● The Linux scheduler (CFS) picks which process to run next.

● Scheduling policies:
○ SCHED_NORMAL: Default for most processes

○ SCHED_FIFO, SCHED_RR: For real-time

○ nice: Sets priority (-20 to 19)

Example:

bash

CopyEdit

nice -n 10 ./heavy_process

7. Process API (Interaction & Monitoring)

Common tools and functions:

Example:

API/Tool Purpose

ps, top, htop View running processes

kill, killall Send signals

strace Trace system calls

nice, renice Adjust priority


bash

CopyEdit

ps aux | grep firefox

kill -9 1234 # Forcefully kill Firefox

8. Process Control and Users

Linux controls process ownership and permissions:

Each process has:

● UID (User ID) – who owns it

● GID (Group ID) – which group it belongs to

Only the owner or root can:

● Kill or renice the process

● Debug or trace it

Example:

bash

CopyEdit

ps -u username # Show processes by a specific user


Summary
Component Description

Process Abstraction Encapsulates program execution

System Calls fork(), exec(), wait() etc.

Process States Running, Waiting, Zombie, etc.

Data Structures task_struct in kernel

Execution Mechanism Context switching, scheduling

Process API Tools and interfaces like ps, kill

User Control UID/GID manage permissions

Process Creation Flowchart


 Linux Process States Diagram

State Description

New Process is being created

Ready Waiting to be scheduled

Running Currently executing

Waiting Waiting for I/O or event

Zombie Finished execution but not yet cleaned by parent

Exit Process is terminated and about to be cleaned up

You might also like