UNIX Internals: Rohit Jnagal
UNIX Internals: Rohit Jnagal
Rohit Jnagal
[email protected]
Introduction
First Steps
Course Prerequisites
Prerequisites for the course:
C programming concepts and principles
Basic Computer Architecture concepts (refresher today!)
Basic algorithms and data structure concepts
Exposure to UNIX/Linux programming environment
Job scheduling
Memory management ( Overlays)
CPU scheduling
Protection
Memory
Mgmt
MP
I/ O
Proc/
thread
mgmt
IPC
hardware
Misc...
LVM
File systems
shells
daemons
cmds
drivers
UNIX features
Files and Processes
File system has places ( / vs C:, D: )
Processes have life
Everything is a file
Processing environment
Hardware mode support
Interrupts and Exceptions
Processor Execution Levels
Process Management Subsystem
Memory Management Subsystem
Kernel/System Interfaces
So, whats different in a Non-UNIX system ?
Processor Modes
Supervisor or User Mode
Supervisor Mode
Can execute all instructions
Can reference all memory locations
Kernel execute in this mode
User Mode
Can execute subset of instructions
Can reference a subset of memory locations
System Hierarchies
User program
User Level
Libraries
Systemcall interface
Kernel Level
LVM
device drivers
Hardware Level
Process Management
Subsystem
Memory
Management
Subsystem
IPC
Scheduling
I/ O
Hardware control
Primary Subsystems
Process Management
Manages all active processes and threads
Memory Management
Allocates memory for processes at run-time
Performs translations of physical memory locations to virtual memory
locations
File Subsystem
Virtual File System Layer
Abstracts and manages data for different file system types
Physical File System Layer
Manages access for specific file systems of various types
I/O Subsystem
Manages system I/O resources, drivers, and data structures
Drives system configuration process
HP-UX History
HPUX release History
Hewlett Packard UNIX
HPUX 1.0 in 1983
HPUX 10.0 (1995) : based on SVR4 UNIX standard
HPUX 11.0 (1997) : First 64-bit version
HPUX 11.11(2001) -> 11i series (World War 1 Armistice)
HPUX 11.20 (2002): First Itanium release
HPUX 11.23 11i v2 (2003): supports both PA and Itanium,
supports ccNUMA
HP-UX Specials
HP-UX features
Clustering technology
Scaling
128 processors (expandable to 256)
1 Tb main memory
32 Tb maximum filesystem size
2 Tb maximum file size
Learning
check
Pipelining
Fetch, Decode, Execute
Superpipelined, Superscalar
Registers
General Purpose Registers
Program Counters
Program Status Word (PSW)
Interrupts
Generated by Hardware Devices
Asynchronous
Exceptions
Generated by executing instructions
Synchronous
Trap (expected) or fault (unexpected)
Interrupt/Exception Handling
Timers
How does OS take control of CPU from running programs?
Hardware timer
Timer Interrupt
Protected/Privileged Instructions
Direct I/O access
Memory State Management
Setting special mode bits
Halting a system
Memory Protection
Protect user programs from each other
Protect itself from user programs
Memory Management Unit
Segmentation
Virtual Memory
Page table, Page protection, TLBs
Base and Limit Registers
Solutions
Turn Off/On Interrupts
Use special atomic instructions
read-modify-write
test-and-set
Bus locks
Learning
check
System Calls
Methods to request system action on behalf of a user
Request
System Action
On behalf of a user
A Single program makes numerous system calls.
Program: Read from one file and write to another
System Calls
Passing Parameters
Three general methods:
Pass parameters in registers
Store them in memory and pass the address
Push the parameters on the stack
Usual rules apply: isolation, security, efficiency
System Calls
Types of System Calls
Process control
Create, execute, wait, end, abort, etc
File Management
Create, delete, open, close, read, write, copy, get/set attributes
ls, cat, more, grep etc.
Device Management
Read, write, attach, detach, get/set attributes
Information
Time, date, attributes
Communications
Send, receive, connect, accept, attributes
Learning
check