- Published on
KembaraXtra-Computer Science - Compiled vs. Interpreted Languages
I. Core Concepts
I. Core Concepts
- Source Code: Human-readable program instructions written by developers.
- Machine Language: Instructions that a CPU can directly execute.
- Compilation: The process of translating source code into machine code (or an intermediate form).
- Interpretation: The process of reading and executing source code instructions line by line (or bytecode).
- Definition: Languages where source code is converted into machine code before runtime.
- Process:
- Developer writes source code (e.g., in C).
- Compiler translates the source code into an executable file (binary).
- End user runs the executable file directly.
- Example: C (using gcc compiler)
- Advantages:
- Fast execution speed because the code is already in machine language.
- Disadvantages:
- Platform-dependent: Executables are specific to the architecture they were compiled for.
- Requires a compilation step during development.
- Definition: Languages where source code is executed line by line by an interpreter during runtime.
- Process:
- Developer writes source code (e.g., in Python).
- End user runs the source code using an interpreter.
- The interpreter reads and executes the code.
- Example: Python
- Advantages:
- Platform-independent: As long as an interpreter exists for a platform, the code can run.
- No compilation step required for the end user.
- Disadvantages:
- Slower execution speed due to the overhead of interpretation.
- Requires the user to have an appropriate interpreter installed.
- Definition: A combination of compilation and interpretation, using an intermediate language called bytecode.
- Process:
- Developer writes source code.
- Compiler translates source code into bytecode.
- A virtual machine (VM) executes the bytecode.
- Bytecode:
- Similar to machine code but designed for a virtual machine, not a specific CPU.
- Virtual Machine (VM):
- A software platform that provides a virtual CPU and execution environment.
- Abstracts away the details of the underlying hardware and OS.
- Examples:
- Java (Java bytecode runs on the Java Virtual Machine - JVM).
- C# (CIL or Common Intermediate Language runs on the .NET Common Language Runtime - CLR).
- Python (CPython implementation compiles to bytecode internally).
- Advantages:
- Combines platform independence (like interpreted languages) with some of the performance benefits of compiled code.
- Disadvantages:
- Still requires a VM to run.
- Execution is generally slower than native compiled code.
- Published on
- Published on
KembaraXtra-Computer Science - Programming Without an Operating System
Core Concept: Direct Hardware Access
Core Concept: Direct Hardware Access
- Definition: In a system without an operating system (OS), software (like a game) directly interacts with the hardware. There's no intermediary layer managing resources or providing services.
- Examples: Atari 2600, Nintendo Entertainment System (NES), Sega Genesis
- How they worked:
- Game code resided on a cartridge.
- Inserting the cartridge and turning on the console started the game.
- The console executed the game's code directly, with no OS intervention.
- Only one program (the game) ran at a time.
- Switching games required turning off the system, swapping cartridges, and turning it back on.
- Total Control: The game developer was responsible for:
- Game logic
- Initializing the system (setting up hardware components)
- Controlling video hardware
- Reading controller inputs
- Managing all hardware interactions
- Hardware Specificity: Deep understanding of the target console's hardware was crucial. Different consoles had significantly different hardware designs.
- Challenges:
- Porting to different consoles required rewriting substantial portions of code due to hardware differences.
- Redundant code: Every game cartridge needed code for basic tasks (hardware initialization, etc.), leading to duplicated effort across different developers and games.
- Maximum Performance: Knowing the exact hardware specifications allowed developers to optimize their code to squeeze the maximum possible performance from the system.
- Stable environment: The hardware design was consistent during the manufacturing years, which allowed developers to target their code to that specific hardware
- Porting: It was hard to port the games, so they often had to rewrite a substantial portion of their code.
- Duplicated work: Every game cartridge had to include similar code to accomplish fundamental tasks, such as initializing the hardware.
- Published on
KembaraXtra-Computer Science - Operating Systems Overview
I. Introduction to Operating Systems (OS)
I. Introduction to Operating Systems (OS)
- Definition: Software that communicates with computer hardware, providing an environment for program execution.
- Purpose:
- Abstracts hardware details, allowing developers to focus on application logic.
- Provides a common set of services for applications.
- Manages hardware resources (memory, I/O devices, etc.).
- Enables multitasking (running multiple programs concurrently).
- Enforces isolation between programs and the OS, as well as user access control.
- Role as a Layer: Acts as an intermediary between hardware and applications.
- Hides hardware complexity.
- Offers a consistent programming model.
- Facilitates software development across diverse hardware.
- Two Major Categories:
- Kernel: The core of the OS.
- Everything Else: Non-kernel components that provide usability.
- The Kernel:
- Responsibilities:
- Memory management.
- Device I/O facilitation.
- Providing system services to applications.
- Enabling multitasking and resource sharing.
- Limitation: By itself, it doesn't provide a user interface.
- Shell:
- Definition: User interface for interacting with the kernel.
- Types:
- Command Line Interface (CLI): e.g., Bash shell (Linux/Unix).
- Graphical User Interface (GUI): e.g., Windows shell (desktop, Start menu, taskbar, File Explorer).
- Daemons/Services:
- Definition: Background processes that provide OS capabilities.
- Examples:
- Task Scheduler (Windows).
- cron (Unix/Linux) - Scheduling programs to run at specific times.
- Software Libraries:
- Purpose: Provide common code for applications and OS components (shell, services) to use.
- Benefit: Promotes code reuse and simplifies development.
- Device Drivers:
- Definition: Software designed to interact with specific hardware devices.
- Role: Bridge the gap between the kernel and diverse hardware.
- OS Inclusion: OSes include drivers for common hardware and mechanisms for installing additional drivers.
- Utilities:
- Definition: Basic applications included with most OSes (text editor, calculator, web browser).
- Classification: Arguably not core OS components, but often bundled for convenience.
- Foundation: Kernel and device drivers directly interact with hardware.
- Libraries: Provide functionality that both OS components (shell, services, utilities) and applications build upon.
- Layered Architecture (from bottom to top):
- Hardware
- Kernel & Device Drivers
- Libraries
- Shell, Services, Utilities, Applications
- Published on
- Published on
KembaraXtra- Computer Science-Kernel Mode and User Mode
I. Core Concept: Privilege Levels
I. Core Concept: Privilege Levels
- Definition: A CPU capability that grants the operating system special rights while restricting other code. It's a way to control what different parts of the software can do.
- Purpose: Ensures programs behave well, prevents interference between programs and the OS, restricts direct hardware access, and protects system files.
- Kernel Mode (Supervisor Mode):
- Privileges: Highest level of privilege; full access to the system (memory, I/O devices, special CPU instructions).
- Trust: Code running in kernel mode is trusted.
- Components: Kernel, device drivers, and key OS components.
- User Mode:
- Privileges: Lower level of privilege; limited access.
- Trust: Code running in user mode is untrusted.
- Components: Most applications.
- Ensuring Trust: Only trusted code runs in kernel mode.
- Control: Allows the operating system to enforce rules and prevent user mode code from misbehaving.
- Security: Prevents direct access to hardware and critical system resources by user applications.
- Key Components:
- Kernel & Executive: Core kernel-mode functionalities (often discussed together). Stored in ntoskrnl.exe.
- Hardware Abstraction Layer (HAL): Isolates the kernel, executive, and device drivers from hardware differences.
- Windowing and Graphics System (win32k): Provides graphics drawing and user interface interaction capabilities.
- Published on
KembaraXtra-Case Law-Processes
What is a Process?
KembaraXtra-Computer Science -Threads
1. Introduction to Threads
What is a Process?
- Definition: A process is a running instance of a program. It's the OS's way of executing a program.
- Analogy: Think of a program as a recipe, and a process as someone actually following that recipe to bake a cake.
- Location: Processes operate in user mode.
- Container: A process acts as a container for a program's execution.
- Private Virtual Memory Address Space: A dedicated memory space for the process (more on this later).
- Program Code: A copy of the program's instructions loaded into the process's memory.
- State Information: Data about the current status of the process.
- Multiple Instances: You can run the same program multiple times, creating a separate process for each instance.
- Process ID (PID): A unique numerical identifier assigned to each process by the OS.
- Parent Process: The process that starts (creates) another process.
- Child Process: The process created by a parent process.
- Process Tree: The hierarchical relationship between processes, with parent processes branching out to child processes.
- Orphan Process: A child process whose parent has terminated before the child.
- Windows Behavior: The orphaned process remains parentless.
- Linux Behavior: The init process (the first user-mode process) typically adopts the orphaned process.
- Linux:
- pstree utility: Displays the process tree in a textual format.
- Child threads shown with curly braces.
- pstree utility: Displays the process tree in a textual format.
- Windows:
- Process Explorer (Microsoft): A GUI-based tool providing a comprehensive view of running processes.
KembaraXtra-Computer Science -Threads
1. Introduction to Threads
- Default Program Execution: Programs typically execute instructions sequentially, handling one task at a time.
- Need for Parallelism: Threads enable programs to perform multiple tasks concurrently (in parallel). Example: A program performing a long calculation while simultaneously updating the user interface (e.g., a progress bar).
- Definition of a Thread: A thread is a schedulable unit of execution within a process, allowing for parallel execution of tasks. It can execute any program code loaded within that process.
- Task Focus: The code run by a thread typically encompasses a specific task the program aims to accomplish.
- Shared Resources: Threads within a process share the same address space, code, and other resources.
- Thread Creation: A process starts with one thread and can create additional threads as needed for parallel task handling.
- Thread ID (TID): Each thread has a unique identifier.
- Windows: Threads and processes are distinct object types. A process acts as a container for threads.
- Linux: Both processes and threads are represented using a single data type. A group of threads sharing an address space and a common process identifier is considered a process. There is no separate process type.
- User Mode: Processes have a Process ID (PID), and threads have a Thread ID (TID).
- Kernel Mode: The Linux kernel refers to a thread's ID as a PID and a process's ID as a thread group identifier (TGID).
- The Illusion of Parallelism: Although threads are said to run in parallel, the actual simultaneous execution depends on the number of processor cores.
- Processor Cores: Each processor core can execute only one thread at a time. The number of cores determines how many threads can run concurrently.
- Physical Core: A hardware implementation of a core within a CPU.
- Logical Core: The ability of a single physical core to run multiple threads simultaneously (one thread per logical core). Intel's hyper-threading is an example. Logical cores do not achieve the full parallelism of physical cores.
- Scheduling: The operating system uses a scheduler, a software component, to manage thread execution.
- Time Allocation: The scheduler allocates short periods of time (quantum) for each thread to run before suspending it to allow other threads to execute.
- Transparency: This scheduling process is mostly hidden from the thread's code, giving the illusion of continuous parallel execution.
- Developer Perspective: Developers write multithreaded applications as if all threads are running continuously in parallel.
- Published on
Computer Science - Virtual Reality (VR) and Augmented Reality (AR)
I. Introduction
V. XR Development
I. Introduction
- VR and AR are technologies that change how we interact with computers.
- XR is a general term referring to VR and AR technologies.
- Definition: Immerses the user in a 3D virtual space, usually with a headset.
- Interaction: Users interact with virtual objects using:
- Gaze
- Voice commands
- Handheld controllers
- History:
- Attempts have been made for decades, but became mainstream in the 2010s.
- Google Cardboard (2014): Popularized VR due to its low cost and accessibility.
- Concept: Headset made from cardboard, lenses, and a smartphone.
- How it Works:
- Apps render content for each eye on separate halves of the smartphone screen.
- Uses the smartphone's gyroscope to track head movement.
- 3 Degrees of Freedom (3DoF):
- Tracks head movement (looking around).
- Cannot track physical movement in space (moving around).
- Supports basic one-button input.
- Impact: Introduced VR to a wide audience.
- 3DoF: Tracks rotational movement (looking around).
- 6 Degrees of Freedom (6DoF): Tracks both rotational and positional movement (moving around in space).
- More immersive experience.
- VR headsets and controllers can have either 3DoF or 6DoF.
- 6DoF controllers enable natural interactions in VR.
- Smartphone-based: (Samsung Gear VR, Google Daydream)
- PC-connected: (Oculus Rift, HTC Vive, Windows Mixed Reality)
- Provide the highest graphical fidelity.
- Most expensive due to the cost of the PC.
- Standalone: (Oculus Go, Oculus Quest, Lenovo Mirage Solo)
- Do not require a smartphone or PC.
- Definition: Overlays virtual elements onto the real world.
- Implementation:
- Mobile Devices: Uses the rear-facing camera to observe the real world and overlays virtual elements.
- Dedicated Devices: (Google Glass, Magic Leap, Microsoft HoloLens) Worn on the head and superimpose computer-generated graphics.
- Advanced AR: Software understands physical elements, allowing virtual elements to interact with the environment.
- Interaction: Users interact using voice commands or hand tracking.
V. XR Development
- Platforms: VR and AR technologies are platforms for software developers.
- Game Engines: Many VR developers use game engines like Unity and Unreal.
- Familiar to game developers.
- Facilitate building software for multiple VR platforms.
- Web Development: WebVR and WebXR (JavaScript APIs)
- WebVR: Focused on VR specifically (older).
- WebXR: Supports both AR and VR (newer).
- Published on
Computer Science- The Internet of Things (IoT)
1. Introduction to IoT
1. Introduction to IoT
- Traditional Internet Model: Servers provide services, and users interact with them via devices like PCs, laptops, and smartphones.
- IoT Definition: Extending internet connectivity to everyday devices (speakers, TVs, thermostats, cars, etc.).
- Driving Forces:
- Decreasing costs and size of electronic components.
- Widespread Wi-Fi and cellular internet access.
- Consumer demand for "smarter" devices.
- Growth of cloud computing (as IoT devices often rely on web services).
- Applications:
- Consumers: "Smart homes" (monitoring and controlling appliances).
- Business: Manufacturing, healthcare, transportation, etc.
- Security:
- IoT devices often have weak security measures.
- Compromised devices can be used as entry points into secure networks.
- They can also be used to launch remote attacks.
- Consumers often overlook security when connecting devices.
- Privacy:
- IoT devices collect data, which is often sent to cloud services.
- Concerns about how organizations handle personal data.
- Risk of data breaches, even with well-intentioned organizations.
- Devices like smart speakers pose risks of accidentally recording private conversations.
- Trade-off between convenience and privacy.
- Reliance on Cloud Services:
- Functionality can be limited or lost if the internet connection is down.
- Manufacturer may eventually discontinue service, rendering the device useless.
- Published on
KembaraXtra- Computer Science - Modems: A Study Guide
I. Core Concept:
Modems act as translators between the digital language of computers and the analog language of older communication systems (like phone lines or cable TV lines). This translation is crucial because computers use digital signals (0s and 1s), while older transmission technologies use analog signals (continuous waves).
II. Key Terms & Definitions:
(Include a diagram here – a simple flow chart showing data transmission through a modem would be beneficial. The diagram should illustrate the conversion from digital to analog and back again.)
For example:
[Computer (Digital)] --> [Modem (Modulation: Digital to Analog)] --> [Transmission Medium (Analog Signal)] --> [Modem (Demodulation: Analog to Digital)] --> [Computer (Digital)]
This study guide provides a structured approach to understanding the fundamental concepts of modems. Remember to review the key terms, the process of modulation and demodulation, and the historical and modern applications to solidify your understanding.
I. Core Concept:
Modems act as translators between the digital language of computers and the analog language of older communication systems (like phone lines or cable TV lines). This translation is crucial because computers use digital signals (0s and 1s), while older transmission technologies use analog signals (continuous waves).
II. Key Terms & Definitions:
- Modem: A contraction of "modulator-demodulator." It's a device that facilitates communication between digital and analog systems.
- Modulation: The process of converting a digital signal into an analog signal suitable for transmission over a specific medium (e.g., converting digital data into audio waves for transmission over a phone line).
- Demodulation: The reverse process of modulation; converting an analog signal back into a digital signal. This occurs at the receiving end.
- Transmission: A computer sends digital data. The modem modulates this data, transforming it into an analog signal compatible with the transmission medium (e.g., phone lines, cable lines).
- Transmission Across Medium: The analog signal travels across the chosen medium.
- Reception: At the receiving end, another modem demodulates the analog signal, converting it back into digital data for the receiving computer to understand.
- Early Modems: Primarily used to connect computers via telephone lines, allowing computers to communicate over audio signals. Think of it as enabling computers to "talk" to each other over the phone.
- Modern Modems: Continue to play a vital role:
- DSL Modems: Used for high-speed internet access over existing telephone lines.
- Cable Modems: Used for high-speed internet access via cable television infrastructure.
- What is the primary function of a modem?
- Define modulation and demodulation. Explain the difference.
- How did the use of modems change computer communication?
- Give examples of modern applications of modems.
- Why is the conversion between digital and analog signals necessary for communication over older technologies?
(Include a diagram here – a simple flow chart showing data transmission through a modem would be beneficial. The diagram should illustrate the conversion from digital to analog and back again.)
For example:
[Computer (Digital)] --> [Modem (Modulation: Digital to Analog)] --> [Transmission Medium (Analog Signal)] --> [Modem (Demodulation: Analog to Digital)] --> [Computer (Digital)]
This study guide provides a structured approach to understanding the fundamental concepts of modems. Remember to review the key terms, the process of modulation and demodulation, and the historical and modern applications to solidify your understanding.