π 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
- Application Layer β Apps generate UI requests
- GUI System/Toolkit β Handles rendering of windows, buttons, etc.
- Windowing System β Manages windows, drawing, and user input
- 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
-
Kernel β Core of the OS
-
Manages CPU, memory, I/O, and processes
-
Shell β Command-line interface
-
Accepts user commands and passes them to the kernel
-
File System β Hierarchical structure
-
All files and directories originate from the root (
/) -
Utilities/Tools β Hundreds of small programs
-
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 parentwait()β 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 |