TECHNOLOGY 

Published on
KembaraXtra-Computer Science - Operating System Software Libraries
I. Introduction
  • An Operating System API is a programmatic interface for interacting with the OS.
  • Software libraries provide the concrete implementation for invoking the OS API.
II. OS Software Libraries
  • Definition: A collection of code included with the OS that implements the OS API.
  • Similarity to Other Libraries: Similar to programming language standard libraries or community-maintained libraries.
  • Format:
    • A file containing machine code.
    • Typically lacks an entry point, so it can't run alone.
    • Exports a set of functions for use by programs.
  • Usage: Programs import (link to) functions from the library to use them.
  • Implementation:
    • Some functions are simple wrappers for kernel system calls.
    • Other functions are fully implemented in user mode code within the library.
    • Some functions implement logic in user mode but also make system calls.
III. Examples
  • Linux: GNU C Library (glibc)
    • Provides access to Linux kernel system calls.
    • Includes the C programming language's standard library functions (some of which don't require system calls).
    • Filename example: libc.so.6 (.so = shared object, 6 = version).
    • Widely used in Linux distributions, so considered part of the standard Linux API.
  • Windows API Libraries
    • Core Libraries:
      • kernel32.dll: Exposes system calls from the NT kernel to user-mode programs.
      • user32.dll: Exposes system calls related to windowing and user interface.
      • gdi32.dll: Exposes system calls related to graphics.
    • .dll Extension: Indicates a dynamic link library (shared library code that a process can load and run).
    • "32" Suffix: Remnant from the 16-bit to 32-bit Windows transition, retained for compatibility. 64-bit Windows includes both 32-bit and 64-bit versions of these files.
IV. Direct System Calls (Alternative, but Not Recommended)
  • Method: Programs can bypass the software library by:
    • Setting values in processor registers.
    • Issuing a processor-specific instruction (e.g., SVC on ARM, SYSCALL on x86).
  • Drawbacks:
    • Requires assembly language programming.
    • Code is not portable across processor architectures.
    • Doesn't provide access to OS API functions not implemented as system calls.
V. Windows Subsystem for Linux (WSL)
  • Challenge: Linux and Windows have different system calls and executable formats, making software incompatible.
  • WSL Solution: Allows running many 64-bit Linux programs on Windows without modification.
  • WSL Versions:
    • WSL1: Intercepts Linux system calls and handles them within the NT kernel.
    • WSL2: Uses a real Linux kernel running in a virtual machine alongside the NT kernel.



Picture
0 Comments