System Calls & API
Interface between user programs and operating system kernel
Key Concepts
System call interface, kernel mode, user mode transitions
Applications
Operating system design, system programming, application development
Exam Focus
System call types, execution mechanism, parameter passing
System Call Categories
File Operations System Calls
open()
Open a file or device
read()
Read data from file descriptor
write()
Write data to file descriptor
close()
Close file descriptor
lseek()
Change file position
stat()
Get file information
System Call Execution Mechanism
Execution Steps
User Mode Call
Application calls system call wrapper function
Library function prepares arguments and issues software interrupt
Mode Switch
CPU switches from user mode to kernel mode
Hardware saves user context and jumps to kernel handler
Kernel Handler
Kernel identifies and executes system call
System call number used to index into dispatch table
Return to User
Kernel completes operation and returns to user mode
Result returned to application, user context restored
System Call Trace
Parameter Passing Methods
Registers
- • Method: Pass parameters in CPU registers
- • Advantage: Fast access
- • Limitation: Limited number of registers
- • Best for: Few parameters
Stack
- • Method: Push parameters onto stack
- • Advantage: Unlimited parameters
- • Limitation: Stack management overhead
- • Best for: Many parameters
Memory Block
- • Method: Store parameters in memory block
- • Advantage: Large data structures
- • Limitation: Memory management complexity
- • Best for: Complex data
System Call vs Function Call
| Aspect | Function Call | System Call |
|---|---|---|
| Execution Mode | User mode | Kernel mode |
| Context Switch | No | Yes |
| Overhead | Low | High |
| Access to Resources | Limited | Full system access |
| Error Handling | Application-level | Kernel-level validation |
📝 Exam Tips
- • Understand the difference between user mode and kernel mode
- • Know the system call execution mechanism steps
- • Be familiar with different parameter passing methods
- • Practice identifying appropriate system calls for different operations
- • Understand the overhead and security implications of system calls