- Published on
- Published on
KembaraXtra-Computer Suite - Networking as Computing
Core Idea:
Core Idea:
- Networking isn't separate from computing; it's a part of it. The internet is a vast, distributed computing system.
- Hardware & Software: The internet and networks rely on both.
- Hardware: Cables, routers, switches, network interface cards (NICs).
- Software: Protocols, operating systems, device drivers, application libraries.
- Data Representation: Data transmitted over networks is ultimately represented as bits (0s and 1s). These bits are physically encoded (e.g., as voltages).
- Networking Interface as I/O: A network interface card (NIC) (like Wi-Fi or Ethernet) is treated by a computer as an input/output (I/O) device.
- Device Drivers: The OS uses device drivers to communicate with NICs.
- Software Libraries: The OS provides libraries that simplify network communication for applications.
- Abstraction: The OS hides the low-level details of networking, allowing applications to send and receive data more easily.
- Routers and switches are specialized computers.
- They perform specific tasks like routing network traffic.
- Extension of Local Computing: Networking extends computing beyond a single device.
- Data Transfer & Processing: It enables data to be transferred and processed across different machines and locations.
- Published on
KembaraXtra-Case Law- Security in Operating Systems
I. What is Security in the Context of Operating Systems?
I. What is Security in the Context of Operating Systems?
- Definition: Security means that software and users should only access appropriate parts of the system. Access is restricted to minimize damage from mistakes or malicious software.
- Why is it Important?
- Single-User Systems: Even on personal devices, users can make mistakes (e.g., running untrustworthy code). The OS limits damage from accidental execution of malicious software.
- Multi-User Systems: Users should not be able to access or modify other users' data without permission.
- User Mode Bubble:
- Isolates applications, preventing them from interfering with other applications or the kernel.
- Filesystem Security:
- Controls access to files and data, allowing only authorized users and processes to access specific files.
- Virtual Memory Security:
- Memory regions can be marked as read-only or executable.
- Helps prevent memory misuse (e.g., executing data as code).
- Login System:
- Allows the OS to manage security based on user identity.
- Enforces access control based on user permissions.
- Baseline Expectations: The above techniques are basic security measures in modern OS.
- Vulnerabilities: Security flaws are frequently discovered, allowing malicious actors to bypass defenses.
- Importance of Updates: Keeping internet-connected OS updated is essential to address vulnerabilities and maintain security.
- Published on
KembaraXtra-Case Law- Services and Daemons
Core Concept: Background Processes
Core Concept: Background Processes
- Definition: Services (Windows) and daemons (Unix-like systems) are processes that run automatically in the background, without direct user interaction.
- Purpose: Provide system-level capabilities that:
- Are not tied to a specific user.
- Do not require kernel-mode privileges.
- Need to be available on demand.
- Examples:
- Configuring network settings
- Running scheduled tasks
- Responsibility: Operating systems have components to manage services/daemons. This includes:
- Starting services/daemons at boot.
- Starting services/daemons in response to events.
- Restarting services/daemons after failures.
- Function: Manages Windows services.
- Executable: services.exe
- Startup: Started early in the boot process and runs continuously.
- Function: Manages daemons (and acts as the init process).
- Status: Standard daemon manager for many modern Linux distributions.
- Startup: Started very early in the boot process and runs continuously.
- Daemon Origin: Inspired by Maxwell's demon, a background "helper" in a physics experiment.
- Pronunciation: "DAY-mon" (common in computing) or "demon" are both acceptable when referring to background processes.
- Service vs. Daemon: Historically, "service" was Windows-specific, but is now also used on Linux, often for daemons managed by systemd.
- Published on
KembaraXtra-Computer Science- Filesystems
1. Storage Devices & Partitions
1. Storage Devices & Partitions
- Secondary Storage: Devices like HDDs and SSDs used for persistent data storage (data remains even when the power is off).
- Partitions: Storage devices are divided into regions called partitions.
- Filesystems: Operating systems use filesystems to organize data on storage devices into files and directories. A partition must be formatted with a particular filesystem before it can be used by the operating system.
- Formatting: Preparing a partition with a specific filesystem.
- Filesystem Examples:
- Linux: ext2, ext3, ext4 (ext family)
- Windows: FAT (File Allocation Table), NTFS (NT File System)
- Volumes: Some OSes use "volumes" as a logical abstraction built on one or more partitions. Filesystems reside on volumes in this case.
- File: A container for data. The structure of the data is defined by the program that created the file.
- Directory (Folder): A container for files and other directories.
- Unix-like Systems (e.g., Linux):
- Unified Hierarchy: A single, tree-like structure of directories.
- Root Directory: The top-level directory, represented by /. All other directories are descendants of the root.
- Example: /usr/lib (lib is a subdirectory of usr, which is a subdirectory of root)
- Mounting: Attaching an additional storage device to a location in the directory structure (e.g., a USB drive mounted to /mnt/usb1).
- Microsoft Windows:
- Drive Letters: Each volume is assigned a drive letter (A-Z).
- Separate Hierarchies: Each drive has its own root and directory structure.
- Directory Paths: Use backslashes (\) in directory paths and a colon (:) after a drive letter.
- Example: C:\windows\system32
- Historical Context: Drive letters A and B were initially reserved for floppy disks. C is typically the drive for the Windows installation.
- Published on
KembaraXtra-Computer Science - Application Binary Interface (ABI)
1.
1.
- Published on
KembaraXtra-Computer Science - Operating System Software Libraries
I. Introduction
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.
- 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.
- 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.
- Core Libraries:
- 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.
- 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.
- Published on
- Published on
KembaraXtra- Computer Science - User Mode Bubble and System Calls
I. User Mode Limitations
ii.Put parameters into other registers.
iii.Execute the system call instruction.
IV. System Calls in Practice
I. User Mode Limitations
- Definition: Code running in user mode has restricted system access.
- Capabilities:
- Read/Write to its own virtual memory.
- Perform mathematical and logical operations.
- Control program flow of its own code.
- Limitations:
- Cannot access physical memory addresses (including memory-mapped I/O).
- Cannot directly perform I/O operations (e.g., printing, keyboard input, graphics, sound, network communication, file access).
- "User Mode Bubble": Analogy representing user mode's isolation from direct hardware interaction.
- Practical Effect: User mode code can do work but requires assistance to share results.
- Definition: A request from user mode code for kernel mode code to perform a privileged operation on its behalf.
- Purpose: Allows user mode applications to interact with the outside world (perform I/O).
- Mechanism:
- User mode code requests a specific operation (e.g., reading from a file).
- The kernel (with device drivers) performs the operation.
- The kernel returns the results to the user mode process.
- Kernel's Role:
- Acts as an intermediary between user mode code and hardware resources.
- Provides an abstraction layer, hiding hardware details.
- Constraints: The kernel enforces security and access control policies (e.g., preventing unauthorized file access).
- CPU Instructions: Specific instructions facilitate system calls.
- ARM: SVC (Supervisor Call).
- x86: SYSCALL, SYSENTER.
- System Call Numbers: Each system call is identified by a unique number.
- Example (Linux ARM): write (file writing) is number 4.
- Process:
ii.Put parameters into other registers.
iii.Execute the system call instruction.
IV. System Calls in Practice
- Abstraction: Developers typically don't make system calls directly.
- OS APIs and Standard Libraries: Operating systems and programming languages provide interfaces for system calls (e.g., open, CreateFileA).
- Transparency: Programmers write code at a higher level and may not be aware of the underlying system calls.
- Published on
KembaraXtra-Conputer Science - API Study Guide
I. Core Concept: Application Programming Interface (API)
I. Core Concept: Application Programming Interface (API)
- Definition: A specification that defines how a program interacts with an operating system (OS).
- Purpose: Allows applications to request services from the OS (e.g., creating files, accessing hardware).
- Components:
- Functions: Specific actions an application can request (e.g., open(), CreateFileA(), fopen()).
- Data Structures: Formats for data passed between the application and the OS.
- Implementation: APIs are implemented in software libraries that are included with the OS.
- UI (Shell):
- Interface for users to interact with the OS (e.g., taskbar, Start menu, command line).
- Translates user commands into API calls.
- API:
- Interface for applications to interact with the OS.
- Applications call the API directly, bypassing the UI.
- User Action (via UI): User clicks "New File" in a graphical shell.
- Shell Translation: The UI translates the click into an API call (e.g., a function call to create a file).
- API Call: The API function is invoked (e.g., open() in Unix/Linux, CreateFileA() in Windows).
- OS Action: The OS code (behind the API) executes the request, creating the file.
- Application Action (via API): The application directly invokes open() or CreateFileA() to create a file.
- C:
- Direct access to OS APIs.
- Example (Unix/Linux): open("hello.txt", O_WRONLY|O_CREAT);
- Example (Windows): CreateFileA("hello.txt", GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
- C (Standard Library):
- Provides portable functions that work across different OSes.
- Internally calls the OS-specific API.
- Example: fopen("hello.txt", "w");
- Python:
- Uses a Python interpreter to handle OS-specific API calls.
- The interpreter translates Python code into the correct OS API calls.
- Example: open('hello.txt', 'w')
- POSIX (Portable Operating System Interface):
- Standard for Unix-like systems (Linux, macOS, etc.).
- Defines standards for the OS API, shell behavior, and utilities.
- macOS/iOS:
- Cocoa (macOS): Apple's API for macOS.
- Cocoa Touch (iOS): Apple's API for iOS.
- Android:
- Android Platform APIs: A set of programming interfaces for Android development.
- Windows:
- Win16: Original 16-bit Windows API.
- Win32: 32-bit Windows API.
- Win64: 64-bit Windows API.
- Universal Windows Platform (UWP): Introduced in Windows 10 to provide a consistent API across different Windows devices.