Past Questions Flashcards
What is the GNU Triplet System
The GNU triplet format is a standardized way of describing a computer system’s characteristics in three parts:
Architecture
Vendor
Operating System
Explain each parts
Architecture: It tells what type of processor the computer has, like Intel or ARM.
2. Vendor: This part usually identifies who made the operating system, but it’s often just labeled as “unknown.”
3. Operating System: It shows what software the computer runs, like Linux or Windows.
Why GNU
By using this format, developers can easily understand and describe the target system they’re working with, which helps in building and running software on different kinds of computers.
State a core characteristic each for Tier 1, Tier 2 and Tier 3 cargets.
Tier 1: Guaranteed Support, stable and reliable, highly efficient and high performance
Tier 2: Community supported , partial support
Tier 3: experimental, best effort supported
Why do I need to specify #[no main| when creating an OS Kernel in Rust?
To indicate to the compiler that the entry point of the program is not the standard main function used in regular Rust programs.
Custom entry point
No runtime init
Minimal dependencies
Why do lalso need to specify #|no sta| when creating an OS Kernel in Rust?
To indicate to the compiler that the standard library should not be included.
Why:
Minimalism
No Global allocator : The standard library includes a global memory allocator (alloc) that relies on runtime support and is not suitable for kernel development.
No operating System Abstraction
What is a firmware
Firmware is a type of software that is embedded into hardware devices to control their basic functions and provide instructions for their operation.
Three functions of firmware
- Hardware Initialization: Firmware initializes hardware components such as CPU, memory, peripherals, and interfaces upon system startup.
- Bootstrapping: Firmware is responsible for loading and executing the bootloader or operating system kernel from non-volatile memory (e.g., ROM, flash memory).
- Hardware Abstraction: Firmware provides an abstraction layer between hardware and higher-level software components, enabling portability and ease of development.
What is bootloader
! A bootloader is a small program or piece of firmware that is responsible for bootstrapping or initializing a computer system when it is powered on or reset
Functions of bootstrapping
- Bootstrapping: The bootloader is responsible for locating, loading, and executing the operating system kernel or application firmware from storage media such as disk drives, flash memory, or network interfaces.
- System Configuration: Bootloaders may perform system-specific configuration tasks before handing control over to the loaded operating system.
- Recovery and Maintenance: Bootloaders often include functionality for system recovery and maintenance, such as firmware updates, booting into diagnostic or maintenance modes, and recovering from failed boot attempts.
Briefly describe the boot process from system power up to operating system loading
Power-On Self-Test (POST): Upon powering up the system, the hardware components undergo a POST process where they are tested for functionality. The POST checks various hardware components such as the CPU, memory, storage devices, and peripherals to ensure they are functioning correctly.
- Firmware Initialization: After completing the POST, the system firmware (BIOS or UEFI) initializes the hardware components and performs basic system configuration tasks.
- Boot Device Selection: The firmware determines the bootable devices based on the boot order specified in firmware settings.
- Bootloader Execution: The firmware loads and executes the bootloader from the primary boot device. The bootloader is a small program responsible for locating, loading, and launching the operating system kernel.
- Operating System Loading: The bootloader locates the operating system kernel and any necessary boot parameters or configuration files on the boot device.
- Operating System Initialization: The operating system kernel initializes system services, device drivers, and other essential components required for the operating system to function
- User Interaction: Once the operating system is fully initialized, the user may interact with the system through a graphical user interface (GUI) or command-line interface (CLI).
What is a framebuffer
A framebuffer is a portion of computer memory used to store the image displayed on a screen, including colors for each pixel.
In addition to the ability to write to the framebuffer, here are three other core features that an OS kernel should have:
Memory Management: The OS kernel should provide memory management capabilities to allocate, manage, and deallocate memory resources efficiently.
Interrupt Handling: The OS kernel should handle interrupts generated by hardware devices or software exceptions.
Process and Thread Management: The OS kernel should support the creation, scheduling, and management of processes and threads
Explain this code:
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}
- # [panic_handler]: This is an attribute in Rust that marks the following function as the panic handler. When a panic occurs in the program, the Rust compiler looks for a function marked with this attribute to handle the panic
- fn panic(_info: &core::panic::PanicInfo) -> ! {: This line defines a function named panic that takes a parameter _info of type &core::panic::PanicInfo. The PanicInfo type provides information about the panic, such as the file and line number where it occurred. The -> ! syntax indicates that the function diverges, meaning it never returns (! is the never type in Rust).
- loop {}: This line contains a loop that executes indefinitely. When a panic occurs and the panic handler is invoked, the program enters this loop and remains there indefinitely. This effectively halts the program’s execution, preventing it from continuing in an undefined or erroneous state after encountering a panic.
In summary, the code defines a panic handler function in Rust that simply enters an infinite loop when a panic occurs. This is a common pattern for panic handlers in embedded systems or low-level code where recovery from a panic may not be possible or desirable.
[global_allocator]
static ALLOCATOR: SpinLockedAllocator = SpinLockedAllocator::empty();
[global_allocator]: This is an attribute in Rust that marks the following item as the global memory allocator. When this attribute is applied to a static or constant item, it designates that item as the global allocator for the entire program.
static ALLOCATOR: SpinLockedAllocator = SpinLockedAllocator::empty();: This line defines a static variable named ALLOCATOR of type SpinLockedAllocator. The SpinLockedAllocator is a custom allocator that is being used to manage memory allocations in the program. The = SpinLockedAllocator::empty(); part initializes the static variable with an empty instance of the SpinLockedAllocator.
Overall, the provided code sets up a custom memory allocator (SpinLockedAllocator) as the global allocator for the program using the #[global_allocator] attribute. This allocator will be responsible for managing memory allocations and deallocations throughout the entire program.