Skip to content

πŸ“˜ Operating System – Unit 5: Windowing Technology

πŸ–₯️ Topic: Graphical User Interface (GUI)


🧠 What is a Graphical User Interface (GUI)?

A Graphical User Interface (GUI) is a visual interface that allows users to interact with the computer using graphical elements like:

  • Windows
  • Icons
  • Menus
  • Buttons
  • Pointers (mouse cursor)

πŸ“Œ Unlike Command-Line Interface (CLI), GUI is user-friendly and does not require command syntax knowledge.


🎯 Goals of GUI:

  • Make computer systems easier to use
  • Allow point-and-click interaction
  • Improve efficiency and accessibility
  • Provide multitasking via multiple windows

🧩 Components of GUI

Component Description
Window A rectangular area on screen to display information (app, file, etc.)
Icon A small graphical symbol representing a program, file, or action
Menu A list of commands/options (e.g., File, Edit, View)
Pointer A visual cursor moved by a mouse or touchpad to interact with GUI elements
Button Clickable area that performs an action (e.g., OK, Cancel)
Scrollbar Used to scroll content up/down or left/right within a window

πŸ“Ί GUI Architecture Overview

  1. Application Layer – Apps generate UI requests
  2. GUI System/Toolkit – Handles rendering of windows, buttons, etc.
  3. Windowing System – Manages windows, drawing, and user input
  4. Operating System – Provides access to hardware and memory

πŸ–ΌοΈ GUI Examples

OS GUI Name/Interface
Windows Windows GUI (Explorer, Start Menu)
macOS Aqua GUI
Linux GNOME, KDE, XFCE
Mobile (Android) Touch-based GUI

βš™οΈ Features of GUI:

  • WYSIWYG: What You See Is What You Get
  • Event-Driven: Responds to user actions like click, drag, scroll
  • Multitasking: Allows multiple windows/apps open at once
  • Drag and Drop: Move files/folders with a mouse
  • Customizable: Change themes, layouts, accessibility settings

βœ… Advantages of GUI:

Advantage Description
User-Friendly No need to remember commands
Intuitive Navigation Use icons and visuals
Multitasking Support Multiple apps open in different windows
Accessibility Features Support for disabled users

⚠️ Disadvantages of GUI:

Disadvantage Description
Resource-Heavy Requires more RAM, CPU, and storage
Slower than CLI For expert users, CLI is faster
Limited Control Cannot access all system functions easily

🧠 Comparison: GUI vs CLI

Feature GUI CLI
Ease of Use Easy for beginners Requires learning commands
Speed Slower for experts Fast once mastered
Resource Usage High Low
Learning Curve Low High

πŸ“ Summary

Point Details
GUI Definition Visual interface for human-computer interaction
Key Components Window, icon, menu, pointer, buttons
Features WYSIWYG, multitasking, event-driven, drag-and-drop
Advantages User-friendly, intuitive, accessible
OS Examples Windows, Linux (GNOME/KDE), macOS

🧩 Topic: Components of GUI (Graphical User Interface)

🧠 What are GUI Components?

GUI components are the graphical elements through which users interact with a computer system or application. These include windows, icons, buttons, and more β€” enabling visual, interactive control over the OS and applications.


🧩 Main Components of a GUI


1. Window

  • A rectangular area on the screen that displays:

  • An application

  • A document
  • A dialog box
  • Can be resized, moved, minimized, or closed

πŸ“Œ Example: Word document window, browser window


2. Icon

  • A small graphic symbol representing a file, folder, application, or action
  • Enables quick access to resources

πŸ“Œ Example: Recycle Bin icon, My Computer, App shortcuts


3. Menu

  • A list of commands or options shown when clicked
  • Types:

  • Drop-down menu – expands vertically

  • Context menu (right-click menu) – appears based on context

πŸ“Œ Example: File β†’ Save, Edit β†’ Copy


4. Pointer (Cursor)

  • A moving symbol (usually an arrow) that reflects mouse movements
  • Used to select, click, drag, and interact with other GUI elements

πŸ“Œ Example: Arrow, I-beam (text), hourglass (loading)


5. Button

  • A clickable object that performs a specific action when pressed
  • Typically labeled with a name or icon

πŸ“Œ Example: OK, Cancel, Submit, Close ❌


6. Text Box / Input Field

  • Allows users to type and enter text
  • Often used in forms or dialog boxes

πŸ“Œ Example: Username and password fields on a login screen


7. Labels

  • Text used to identify or describe other components
  • Usually not clickable

πŸ“Œ Example: β€œEnter your name:”


8. Scroll Bar

  • Used to navigate content that does not fit within a window
  • Two types:

  • Vertical scroll bar

  • Horizontal scroll bar

πŸ“Œ Example: Scrolling through a long document


9. Checkbox

  • Allows users to select or deselect one or more options independently

πŸ“Œ Example: β˜‘ I agree to the terms and conditions


10. Radio Button

  • Allows the user to choose only one option from a set

πŸ“Œ Example: ( ) Male  ( ) Female  (βœ“) Other


11. Drop-Down List (Combo Box)

  • Displays a list of choices when clicked
  • Saves screen space

πŸ“Œ Example: Selecting a country from a list


12. Toolbar

  • A row of shortcut icons or buttons for common functions
  • Often found at the top of applications

πŸ“Œ Example: Save πŸ–«, Print πŸ–¨, Undo ↩️


βœ… Summary Table: GUI Components

Component Purpose Example
Window Displays applications/documents Browser window
Icon Represents files/programs My Computer, Recycle Bin
Menu Offers list of commands File, Edit menus
Pointer Used for selection and control Mouse cursor
Button Performs an action OK, Cancel, Close
Text Box User input area Login form fields
Label Describes another component "Enter your name:"
Scroll Bar Scroll through content Scroll in PDF or web page
Checkbox Multiple independent selections βœ“ Accept terms
Radio Button Single selection from options (β€’) Option A
Drop-Down Choose from a list Country selector
Toolbar Quick access to tools Save, Print, Zoom in

🧩 Topic: Requirements of a Windows-Based GUI

🧠 What is a Windows-Based GUI?

A Windows-Based GUI is a graphical user interface where multiple application windows can be displayed, managed, and interacted with simultaneously on a screen. It is multi-window, event-driven, and user-friendly.

πŸ“Œ Common examples: Windows OS, Linux desktop environments (GNOME, KDE), macOS.


βœ… Requirements of a Windows-Based GUI System

To support windowing features, a GUI system must fulfill the following technical and functional requirements:


πŸ”Ή 1. Window Management System

  • Create, display, move, resize, minimize/maximize, and close windows
  • Maintain Z-ordering (which window is on top)
  • Enable focus switching between windows
  • Handle overlapping and tiling of windows

πŸ“Œ Manages the visual representation and interaction of windows.


πŸ”Ή 2. Input Device Support

  • Must support mouse, keyboard, touch, stylus, etc.
  • Should handle pointer events like click, drag, drop, scroll
  • Keyboard events for shortcuts (e.g., Ctrl+C, Alt+Tab)

πŸ”Ή 3. Graphical Output System

  • Ability to render shapes, text, and images
  • Support for:

  • Fonts and anti-aliasing

  • Icons and colors
  • Layers and transparency

πŸ“Œ Handles visual display of GUI elements.


πŸ”Ή 4. Event-Driven Programming Model

  • GUI must respond to user-generated events like:

  • Mouse clicks

  • Keystrokes
  • Window resizing
  • Each event triggers a callback or event handler function

πŸ“Œ Makes the GUI interactive and responsive.


πŸ”Ή 5. Multitasking and Multiwindow Support

  • Allows multiple windows or applications to run concurrently
  • Each window may belong to a separate process or thread

πŸ“Œ Ensures users can switch and work across apps seamlessly.


πŸ”Ή 6. Window Communication (Message Passing)

  • Mechanism to send messages between OS, apps, and window manager
  • Example: Windows OS uses message queues (e.g., WM_PAINT, WM_CLOSE)

πŸ”Ή 7. Memory Management

  • Efficient handling of memory for GUI processes and graphics
  • Support for:

  • Caching window content

  • Shared memory (for drag-and-drop between apps)
  • Virtual memory usage for large applications

πŸ”Ή 8. Device-Independent Graphics Interface

  • GUI must work across different hardware devices
  • Provide abstract graphics API so developers don’t worry about low-level hardware

πŸ“Œ Example: Win32 GDI, X11 (for Linux), Quartz (for macOS)


πŸ”Ή 9. User Interface Components Library

  • Predefined set of GUI elements:

  • Buttons, menus, scrollbars, toolbars, sliders

  • Dialog boxes, forms, combo boxes

πŸ“Œ These components make GUI development faster and consistent.


πŸ”Ή 10. Security and Access Control

  • GUI must restrict access to windows and system controls
  • Prevent unauthorized programs from capturing keystrokes or injecting events

πŸ“Š Summary Table: Windows-Based GUI Requirements

Requirement Purpose
Window Manager Handle window creation, positioning, and behavior
Input Device Support Accept user input via mouse, keyboard, etc.
Graphical Output System Render visual content
Event-Driven Model Respond to user actions
Multitasking Support Run multiple apps/windows concurrently
Message Passing Mechanism Enable communication between windows and processes
Memory Management Optimize memory usage of GUI processes
Device-Independent Graphics Work across various hardware and display systems
UI Component Library Provide reusable GUI elements
Security Prevent unauthorized GUI manipulation

πŸͺŸ Topic: MS-Windows and Windows NT

🧠 What is MS-Windows?

MS-Windows (Microsoft Windows) is a graphical operating system developed by Microsoft. It provides a user-friendly GUI and supports multitasking, memory management, device management, and networking.

πŸ“Œ It's the most widely used OS on personal computers.


πŸ“… Evolution of MS-Windows

Version Features Highlighted
Windows 1.0 – 3.x Early GUI, ran over MS-DOS
Windows 95/98 Start menu, taskbar, Plug and Play
Windows XP Stable, user-friendly, multi-user
Windows 7/8/10/11 Modern UI, improved security and networking

🧱 Key Features of MS-Windows

  • Graphical User Interface (GUI)
  • Multitasking
  • File Explorer for file management
  • Control Panel for settings and configurations
  • Plug and Play device support
  • Built-in applications: Notepad, Paint, etc.
  • User Management (in later versions)
  • Supports 32-bit and 64-bit architectures

πŸ› οΈ What is Windows NT (New Technology)?

Windows NT is a more secure, stable, and powerful version of Windows designed for business, enterprise, and professional use.

πŸ›‘οΈ NT stands for β€œNew Technology”


πŸ” Key Features of Windows NT

Feature Description
Multitasking True preemptive multitasking
Security File permissions, access control, domain-based authentication
Multi-user Support Supports multiple user accounts with permissions
Hardware Independence Works on multiple CPU architectures
Modular Kernel Hybrid kernel for flexibility and stability
File System Uses NTFS – supports encryption, journaling, compression
Networking Built-in TCP/IP stack, domain controller, Active Directory

πŸ”„ Comparison: MS-Windows vs Windows NT

Feature MS-Windows (95/98/ME) Windows NT (NT/2000/XP/10 Pro)
Kernel Type Monolithic + DOS-based Hybrid Kernel
Security Basic Advanced (NTFS permissions, domains)
Stability Less stable Highly stable
Networking Limited Enterprise-level (Active Directory)
User Access Single-user (early versions) Multi-user with permission control
System Type Consumer-focused Business/Professional-focused

🧠 Why Windows NT Was Important

  • Provided the foundation for modern Windows versions (Windows XP, Vista, 7, 10, 11)
  • Introduced secure architecture with proper memory and process isolation
  • Used in servers, enterprise environments, and professional desktops

βœ… Summary

Point MS-Windows Windows NT
GUI Yes Yes
Target Users Home users Business and enterprise users
Stability Moderate High
Security Low (in early versions) High (with NTFS and domains)
Networking Basic Advanced networking (TCP/IP, AD)

πŸ“˜ Operating System – Unit 5: History of UNIX


🧠 What is UNIX?

UNIX is a powerful, multiuser, multitasking operating system originally developed in the 1970s. It has formed the foundation for many modern OSs like Linux, macOS, Android, and more.


πŸ•°οΈ Timeline of UNIX History


πŸ”Ή 1969 – Origin at AT\&T Bell Labs

  • Developed by Ken Thompson, Dennis Ritchie, and others
  • Written initially in assembly language
  • Designed for simplicity, flexibility, and reusability

πŸ”Ή 1971 – First UNIX Version (Version 1)

  • Ran on PDP-11
  • Had basic system calls, shell, and file system

πŸ”Ή 1973 – UNIX Rewritten in C

  • Major milestone: rewritten in the C programming language
  • Made UNIX portable across different hardware
  • Led to wider adoption in academic and commercial environments

πŸ”Ή 1975 – Version 6 UNIX (V6)

  • First UNIX version widely distributed to universities
  • Gained attention in academic research and teaching

πŸ”Ή 1979 – Version 7 UNIX (V7)

  • Considered the last "true" UNIX from Bell Labs
  • Included C compiler, shell, tools, and improved I/O

πŸ”Ή 1980s – Commercialization and Variants

  • BSD (Berkeley Software Distribution): Focused on networking and tools
  • System V (AT\&T): Introduced features like init, run levels, streams
  • X/Open, POSIX standards: Tried to unify UNIX systems

πŸ”Ή 1991 – Linux Inspired by UNIX

  • Linus Torvalds released the Linux kernel, a UNIX-like system
  • Free and open-source alternative to UNIX

πŸ”Ή 2000s – Modern UNIX Systems

  • macOS (based on BSD/Darwin)
  • AIX, Solaris, HP-UX – UNIX variants used in enterprises
  • UNIX certification (Single UNIX Specification)

🌐 Key Features Introduced by UNIX

Feature Description
Portability Written in C, easy to move across systems
Multitasking Run multiple processes simultaneously
Multiuser Support for many users on one system
Hierarchical File System Organized files in tree structure
Shell Interface Command-line for user interaction
Tools Philosophy Small programs that do one job well

🧬 UNIX Family Tree Overview

                   +------------------+
                   |     UNIX         |
                   +------------------+
                       /        \
                 System V      BSD
                    |            \
              Solaris, AIX      FreeBSD, NetBSD
                                |
                            macOS, Linux (inspired)

βœ… Summary Table

Year Milestone Description
1969 Birth of UNIX at Bell Labs Written in assembly
1973 Rewritten in C Made portable
1979 Version 7 UNIX Widely adopted standard version
1980s BSD & System V split Led to many commercial variants
1991 Linux (UNIX-like) developed Open-source, became widely used
2000s POSIX standards and modern UNIX Includes macOS, AIX, Solaris

πŸ“˜ Operating System – Unit 5: Overview of UNIX

🧠 What is UNIX?

UNIX is a powerful, multiuser, multitasking operating system designed for flexibility, portability, and security. It was originally developed in 1969 at AT\&T Bell Labs by Ken Thompson, Dennis Ritchie, and others.


🧬 Key Characteristics of UNIX

Feature Description
Multiuser Multiple users can work on the same system simultaneously
Multitasking Can run multiple processes at the same time
Portability Written in C language – runs on many hardware platforms
Security Built-in user and permission-based access control
Stability Used in servers and critical systems due to its robustness
Modularity Follows β€œsmall tools that do one job well” philosophy

πŸ—‚οΈ Basic Structure of UNIX

  1. Kernel – Core of the OS

  2. Manages CPU, memory, I/O, and processes

  3. Shell – Command-line interface

  4. Accepts user commands and passes them to the kernel

  5. File System – Hierarchical structure

  6. All files and directories originate from the root (/)

  7. Utilities/Tools – Hundreds of small programs

  8. Example: ls, cd, cp, grep, chmod


πŸ› οΈ Main Components of UNIX OS

Component Function
Kernel Manages system resources and hardware access
Shell Acts as a user interface (CLI)
Commands Utilities to perform tasks
File System Organizes files in a tree-like structure
Processes Units of execution that are managed by the OS

πŸ“‚ UNIX File System Highlights

  • Hierarchical structure
  • Everything is a file (including devices)
  • Root directory: /
  • Home directories: /home/user
  • File permissions: read (r), write (w), execute (x) for user/group/others

πŸ”„ Common UNIX Commands

Command Purpose
ls List files and directories
cd Change directory
cp Copy files
mv Move/rename files
rm Delete files
chmod Change permissions
ps Show running processes
kill Terminate a process

πŸ“Š Uses of UNIX

  • Servers (web, database, mail)
  • Embedded systems
  • Education and research
  • Network and cloud infrastructure
  • Foundation for OS like Linux, macOS, Android

βœ… Summary

Feature UNIX Description
Type Multiuser, multitasking OS
Language Written in C
Interface Command-line (Shell), GUI (in some versions)
Security Strong user-based permissions
Portability Runs on many hardware platforms
Popular Variants Solaris, AIX, HP-UX, BSD, Linux, macOS

πŸ“˜ Operating System – Unit 5: UNIX File System

🧠 What is a File System?

A file system is the way an operating system organizes, stores, manages, and retrieves files on a disk.

The UNIX file system is hierarchical, meaning it is structured like a tree with the root directory / at the top.


🌲 Structure of UNIX File System

/
β”œβ”€β”€ bin
β”œβ”€β”€ boot
β”œβ”€β”€ dev
β”œβ”€β”€ etc
β”œβ”€β”€ home
β”‚   β”œβ”€β”€ user1
β”‚   └── user2
β”œβ”€β”€ lib
β”œβ”€β”€ tmp
β”œβ”€β”€ usr
└── var

πŸ“‚ Important Directories

Directory Purpose
/ Root directory – top of the file system
/bin Essential binary programs (e.g., ls, cp, mv)
/boot Boot files and kernel images
/dev Device files (e.g., /dev/sda, /dev/tty)
/etc System configuration files (e.g., /etc/passwd)
/home User home directories (e.g., /home/user1)
/lib System libraries needed by programs in /bin and /sbin
/tmp Temporary files (cleared on reboot)
/usr User programs, libraries, and documentation
/var Variable data like logs, mail, spool files

πŸ“ Types of Files in UNIX

Type Description
Regular File Text or binary data files
Directory Contains list of file names and inodes
Special File Represents devices (block or character)
Link Pointer to another file (hard or symbolic)
Socket For inter-process communication
FIFO (Named Pipe) Special file for communication between processes

πŸ†” Inodes (Index Nodes)

  • Each file is represented by a unique inode.
  • The inode stores metadata about the file:

  • File size

  • File type
  • Owner and permissions
  • Timestamps (created, modified, accessed)
  • Pointers to data blocks

πŸ“Œ Inode does NOT store file name – file name is stored in the directory entry.


πŸ” File Permissions in UNIX

UNIX uses a permission model with three types of users and three types of access:

-rwxr-xr--
Symbol Meaning
r Read
w Write
x Execute
Position Meaning
1st char File type (- = file, d = directory)
2–4 Owner's permissions
5–7 Group's permissions
8–10 Others' permissions

πŸ› οΈ File System Operations

Operation Command
List files ls, ls -l
Change dir cd
View file cat, less
Copy file cp
Move/rename mv
Delete file rm
Change permissions chmod

πŸ“¦ Mounting in UNIX

  • UNIX allows multiple file systems to be mounted into the directory tree.
  • Example: Mounting a USB drive into /media/usb
mount /dev/sdb1 /media/usb

βœ… Summary Table

Feature Description
Structure Hierarchical (tree-based) with / root
File Types Regular, directory, link, device, socket
File Metadata Stored in inodes
File Permissions Read, write, execute for user/group/others
Mounting Attach new file systems into main tree

πŸ“˜ Operating System – Data Structures for Process and Memory Management

🧠 Why are Data Structures Needed?

In operating systems, data structures are essential for organizing and managing resources such as processes and memory efficiently.


🧩 Data Structures for Process Management

These data structures help the OS manage the life cycle, status, and scheduling of processes.


πŸ”Ή 1. Process Control Block (PCB)

A PCB is a data structure that stores information about each process.

Field Description
Process ID (PID) Unique identifier for the process
Process State Ready, running, waiting, etc.
Program Counter Next instruction to execute
CPU Registers Contents of CPU registers
Memory Info Base & limit registers, memory map
Scheduling Info Priority, queue pointers, etc.
I/O Status Info List of I/O devices assigned
Accounting Info CPU time used, job ID, etc.

πŸ“Œ The PCB is stored in process table, which the OS uses to track all processes.


πŸ”Ή 2. Queues

The OS maintains various queues to manage process states:

Queue Type Used For
Ready Queue All processes ready to run
Job Queue All processes in the system
Device Queue Processes waiting for I/O devices
Waiting Queue Blocked processes waiting for an event

Each queue is implemented using linked lists or arrays.


🧠 Data Structures for Memory Management

These structures help track memory allocation, deallocation, and protection.


πŸ”Ή 1. Page Table

Used in paging to map virtual addresses to physical frames.

Virtual Page Frame Number
0 5
1 3
2 8

πŸ“Œ Each process has its own page table.


πŸ”Ή 2. Frame Table

  • Tracks which physical memory frames are free, occupied, or reserved.
  • Used during page replacement and allocation.

πŸ”Ή 3. Segment Table

Used in segmentation to store information about segments.

Segment No. Base Address Limit (Size)
0 4000 500
1 8000 1000

πŸ“Œ Supports protection and isolation between memory segments.


πŸ”Ή 4. Free Memory List / Bitmap

Tracks free and used memory blocks.

  • Bitmap: 0 = Free, 1 = Used Example: 0 1 1 0 0 1
  • Free List: Linked list of free memory holes (used in dynamic allocation)

πŸ”Ή 5. Swap Space Table

  • Tracks pages or segments moved to disk (swap space)
  • Used in virtual memory management

🧠 Summary Table

Area Data Structure Purpose
Process Mgmt PCB Holds process info
Ready/Job/Device Queue Manage process states and scheduling
Memory Mgmt Page Table Virtual to physical memory mapping
Frame Table Tracks physical memory usage
Segment Table Supports segmentation
Bitmap / Free List Tracks available memory blocks
Swap Space Table Tracks memory pages swapped to disk

πŸ“˜ Operating System – Process States and State Transitions

🧠 What is a Process?

A process is a program in execution, managed by the operating system. As it runs, it goes through different states based on its interaction with the CPU and other resources.


πŸ”„ Common Process States

State Description
New Process is being created and initialized
Ready Process is ready to run, waiting for CPU
Running Process is currently being executed by the CPU
Waiting/Blocked Process is waiting for an I/O event or resource to become available
Terminated Process has finished execution or is killed by the OS

πŸ” Process State Transitions Diagram

     +-------+
     |  New  |
     +-------+
         |
         v
     +--------+      CPU Assigned     +-----------+
     | Ready  | --------------------> |  Running  |
     +--------+ <-------------------- +-----------+
         ^        CPU Released           |
         |                               | I/O Request or Event Wait
     I/O Complete                        v
     +----------+ <----------------- +-----------+
     | Waiting  |     I/O Complete   | Terminated|
     +----------+ ------------------ +-----------+

πŸ”€ State Transition Events Explained

Transition Event That Triggers It
New β†’ Ready Process is created and admitted to the ready queue
Ready β†’ Running CPU scheduler assigns the process to CPU
Running β†’ Ready Time slice expires (preemption)
Running β†’ Waiting (Blocked) Process needs I/O or resource
Waiting β†’ Ready I/O completed; process is ready again
Running β†’ Terminated Process finishes or is terminated by the system

🧠 Extra: Preemption vs Non-preemption

Term Meaning
Preemptive Scheduling OS can forcibly take CPU from a running process (e.g., Round Robin)
Non-Preemptive Scheduling Running process voluntarily gives up CPU (e.g., FCFS)

βœ… Summary Table

State Meaning
New Process is being created
Ready Waiting to be assigned to CPU
Running Currently being executed
Waiting Waiting for I/O or event
Terminated Execution is completed or aborted

πŸ“˜ Operating System – Executing and Terminating a Program in UNIX

🧠 What is Execution in UNIX?

Executing a program in UNIX means starting a process from a file (usually a script or compiled binary) so it runs using CPU and memory resources.


πŸš€ Executing a Program in UNIX

There are three common ways to run a program:

1. Using a Shell Command

./program_name
  • ./ tells the shell to run the file from the current directory
  • Example:

bash ./hello.out

2. Using Shell Script

If the program is a script (like .sh), run with:

sh script.sh
# or, if executable:
./script.sh

3. Using exec() Family System Calls (in C)

In programming, you can start another process using:

execl("/bin/ls", "ls", "-l", NULL);

βœ… Steps Involved in Execution (Behind the Scenes)

Step Action
1 User gives command or clicks to run a program
2 Shell locates the binary or script
3 System call fork() creates a new child process
4 Child process uses exec() to load the new program into memory
5 Process runs and executes instructions

πŸ“Œ This is how most UNIX programs start: fork() + exec()


πŸ›‘ Terminating a Program in UNIX

A program (process) ends when it:

  • Completes execution normally, or
  • Is killed by the system or user, or
  • Encounters an error (e.g., segmentation fault)

πŸ”š Methods of Termination

Method Command/Explanation
Normal Exit Program ends using exit() in code
Manual Termination User stops it using Ctrl + C or kill
kill Command kill PID – sends SIGTERM to the process
kill -9 Command kill -9 PID – forces termination (SIGKILL)

🧠 System Calls Involved in Termination

  • exit(status) – Process ends normally and returns status to the parent
  • wait() – Parent waits for child to finish and collects exit status

πŸ“Š Example: Running and Killing a Program

$ ./loop.sh         # Starts the program
^C                  # Press Ctrl+C to stop it

$ ps                # List processes
$ kill 1234         # Kill process with PID 1234

βœ… Summary Table

Action Command/System Call
Execute ./file, sh script.sh
Fork process fork()
Replace code exec()
Exit process exit(), Ctrl+C, kill

πŸ“˜ Operating System – Process Scheduling

🧠 What is Process Scheduling?

Process Scheduling is the technique used by the Operating System (OS) to decide which process runs next on the CPU when there are multiple processes in the ready queue.

It ensures efficient CPU usage, fairness, and good system responsiveness.


🎯 Objectives of Process Scheduling

  • Maximize CPU utilization
  • Minimize waiting time and turnaround time
  • Ensure fairness among processes
  • Provide priority and responsiveness to important tasks

πŸ” Types of Schedulers in OS

Scheduler Type Description
Long-Term Scheduler Selects which jobs to admit into the system (job scheduling)
Short-Term Scheduler Selects which process gets the CPU (CPU scheduling) – runs frequently
Medium-Term Scheduler Swaps out and back processes to manage memory (used in multitasking)

⏱️ CPU Scheduling Criteria

Metric Description
CPU Utilization Keep the CPU as busy as possible
Throughput Number of processes completed per unit time
Turnaround Time Time from submission to completion of a process
Waiting Time Total time a process spends in the ready queue
Response Time Time from submission to first response

πŸ”„ Process States in Scheduling

Processes move between these states:

New β†’ Ready β†’ Running β†’ Waiting β†’ Ready β†’ Running β†’ Terminated

CPU scheduling happens when:

  • A process switches from Running β†’ Waiting
  • A process switches from Running β†’ Ready (preemption)
  • A process finishes (Running β†’ Terminated)
  • A process enters Ready from New or Waiting

πŸ“œ Common CPU Scheduling Algorithms

Algorithm Description
FCFS (First Come First Serve) Non-preemptive, simple, poor average time
SJF (Shortest Job First) Best average time, non-preemptive or preemptive
Round Robin Preemptive, time-sharing, fair for all
Priority Scheduling Based on process priority (can be preemptive)
Multilevel Queue Multiple queues with different scheduling policies

πŸ“Œ You’ll typically draw Gantt charts for these in exams.


🧠 Preemptive vs Non-Preemptive Scheduling

Type Description
Preemptive OS can interrupt a running process to assign CPU to another process
Non-Preemptive Running process keeps the CPU until it finishes or waits

βœ… Summary

Term Meaning
Scheduling Choosing next process for CPU
Ready Queue Queue of processes ready for execution
Context Switch CPU switches from one process to another
Preemption OS takes CPU from running process
Scheduler OS module that selects the process

πŸ“˜ Operating System – Memory Management

🧠 What is Memory Management?

Memory management is the process of controlling and coordinating computer memory, assigning portions to various running processes and managing it efficiently.


🎯 Objectives of Memory Management

  • Allocate memory to processes efficiently and safely
  • Ensure process isolation and protection
  • Maximize CPU and memory utilization
  • Support multiprogramming and virtual memory

🧱 Functions of Memory Management

Function Description
Allocation & Deallocation Allocate memory when process starts, deallocate when it ends
Tracking Usage Keep track of which parts are free or used
Swapping Move processes between main memory and disk (swap space)
Protection Prevent one process from accessing another's memory
Relocation Adjust memory addresses during execution

πŸ“š Types of Memory Allocation Techniques


πŸ”Ή 1. Single Contiguous Allocation

  • One big block of memory for one process
  • Simple, but wastes space and allows only one process at a time

πŸ”Ή 2. Fixed Partitioning

  • Memory divided into fixed-size blocks (partitions)
  • Each process fits into one partition
  • Causes internal fragmentation

πŸ”Ή 3. Variable Partitioning

  • Memory divided dynamically based on process size
  • May cause external fragmentation

πŸ”Ή 4. Paging (Non-contiguous)

  • Physical memory is divided into fixed-size frames
  • Logical memory is divided into pages
  • Pages are mapped to frames using a page table
  • Eliminates external fragmentation

πŸ”Ή 5. Segmentation

  • Memory divided into segments: code, data, stack
  • Each segment has a base and limit
  • Supports logical program structure

πŸ”Ή 6. Virtual Memory

  • Enables programs to use more memory than physically available
  • Uses disk (swap space) as an extension of RAM
  • Key methods:

  • Demand Paging

  • Page Replacement Algorithms (FIFO, LRU, etc.)

πŸ“Š Fragmentation in Memory

Type Description
Internal Unused space inside fixed partitions
External Wasted space between allocated blocks

πŸ”„ Swapping

  • Temporarily moves inactive processes to disk to free up RAM
  • Helps support multiprogramming

βœ… Summary Table

Term Description
Memory Management Controls allocation and access to memory
Paging Fixed-size blocks, removes external fragmentation
Segmentation Logical division of memory (code, stack, etc.)
Virtual Memory Uses disk as extended RAM, supports large programs
Fragmentation Wasted memory (internal/external)
Swapping Move processes between RAM and disk