Past Questions Flashcards

1
Q

What is the GNU Triplet System

A

The GNU triplet format is a standardized way of describing a computer system’s characteristics in three parts:
Architecture
Vendor
Operating System

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Explain each parts

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Why GNU

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

State a core characteristic each for Tier 1, Tier 2 and Tier 3 cargets.

A

Tier 1: Guaranteed Support, stable and reliable, highly efficient and high performance

Tier 2: Community supported , partial support

Tier 3: experimental, best effort supported

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why do I need to specify #[no main| when creating an OS Kernel in Rust?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Why do lalso need to specify #|no sta| when creating an OS Kernel in Rust?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a firmware

A

Firmware is a type of software that is embedded into hardware devices to control their basic functions and provide instructions for their operation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Three functions of firmware

A
  1. Hardware Initialization: Firmware initializes hardware components such as CPU, memory, peripherals, and interfaces upon system startup.
    1. Bootstrapping: Firmware is responsible for loading and executing the bootloader or operating system kernel from non-volatile memory (e.g., ROM, flash memory).
    2. Hardware Abstraction: Firmware provides an abstraction layer between hardware and higher-level software components, enabling portability and ease of development.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is bootloader

A

! 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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Functions of bootstrapping

A
  1. 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.
    1. System Configuration: Bootloaders may perform system-specific configuration tasks before handing control over to the loaded operating system.
    2. 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Briefly describe the boot process from system power up to operating system loading

A

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.

  1. Firmware Initialization: After completing the POST, the system firmware (BIOS or UEFI) initializes the hardware components and performs basic system configuration tasks.
  2. Boot Device Selection: The firmware determines the bootable devices based on the boot order specified in firmware settings.
  3. 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.
  4. Operating System Loading: The bootloader locates the operating system kernel and any necessary boot parameters or configuration files on the boot device.
  5. Operating System Initialization: The operating system kernel initializes system services, device drivers, and other essential components required for the operating system to function
  6. 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).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a framebuffer

A

A framebuffer is a portion of computer memory used to store the image displayed on a screen, including colors for each pixel.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In addition to the ability to write to the framebuffer, here are three other core features that an OS kernel should have:

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Explain this code:
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}

A
  1. # [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
  2. 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).
  3. 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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

[global_allocator]

static ALLOCATOR: SpinLockedAllocator = SpinLockedAllocator::empty();

A

[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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

[no_mangle]

pub extern “C” fn _start() -> ! {
// Entry point of the OS kernel
loop {}
}

A

[no_mangle]: This attribute in Rust prevents the compiler from applying name mangling to the function name. . In this case, #[no_mangle] ensures that the function _start keeps its exact name when compiled, making it easier to interface with from other programming languages or during low-level system programming.

pub extern “C” fn _start() -> ! {: This line declares a function named _start. The pub keyword makes the function publicly accessible from outside the module where it is defined. extern “C” specifies the calling convention for the function, which is typically used for interoperability with C code. This ensures that the function can be called from C code without any issues regarding the calling convention. fn _start() -> ! indicates that the function _start takes no arguments (()) and returns never (!). Returning ! means that the function does not return a value and will never complete normally. This is often used for functions that represent entry points to programs or kernels, indicating that they will run indefinitely or terminate the program in a controlled manner.

loop {}: This line contains a loop that runs indefinitely. Inside the loop, there are no statements, so the loop effectively becomes an infinite loop. In the context of an operating system kernel, this infinite loop ensures that the kernel continues to run indefinitely after it has been started. This is a common pattern for kernel entry points, as the kernel typically needs to continuously handle hardware events, schedule tasks, and respond to user interactions.

17
Q
A