🔧

Understanding System Calls and Their Importance

Apr 24, 2025

Lecture Notes: System Calls

Introduction

  • System Call: A programmatic way to shift from user mode to kernel mode to access operating system functionality.
  • Used when an application or program needs to access kernel-level operations.

User Mode vs Kernel Mode

  • User Mode: Where applications run; limited access to system resources.
  • Kernel Mode: Full access to hardware and resources; accessed via system calls.

Example Use Cases

  • Printing on a monitor or accessing a printer requires kernel mode.
  • Accessing or modifying files on a hard disk also requires kernel mode.

System Calls in Different Operating Systems

  • Linux: Direct use of system calls like read, write, open, close, fork, etc.
  • Windows: Around 700 system calls.
  • Many systems use APIs or libraries that internally use system calls (e.g., printf).

Categories of System Calls

1. File Related

  • Operations like creating, opening, reading, writing files.
  • Programs become processes which require kernel privileges to access files.

2. Device Related

  • Access hardware like hard disks, printers, monitors through system calls.
  • Privileges for device access are managed by the operating system.

3. Information Related

  • Access process or device information, like metadata (size, permissions).
  • Examples include getpid (process ID), getppid (parent process ID).

4. Process Control

  • Managing process execution, loading into memory.
  • Fork System Call: Used in multiprocessing environments to create child processes.
  • Wait & Signal: Used for process synchronization, semaphore management.

5. Communication

  • Inter-process Communication (IPC): Processes communicate via methods like Pipe() or shared memory (Shmget()).

6. Protection and Security

  • Manage file permissions and security levels (e.g., chmod, umask).

Conclusion

  • Understanding system calls is crucial for understanding how programs interact with the kernel.
  • Importance in ensuring program access to necessary resources and hardware.

Thank you for listening!