Day-9 of internship at Aartronix

Kernel module

  • What: It is a piece of compiled code (like a.ko file) that acts as a plugin.

  • Why: To keep the system efficient and flexible, loading code only when hardware is present, or it would be stored in storage.

  • How: The kernel reads the file, uses the Vendor/Product IDs to match the driver, and performs Dynamic Linking to connect the function calls.

  • When: It happens on demand (e.g., hot-plugging a USB).

  • Where: It runs in Kernel Space, sharing the highest privileges (and risks) with the OS core.

    Revise C and Embedded C to use for kernel module.

    1) check for armstrong numbers. 

    #include <stdio.h>
    int length(int n)
    {
    int len = 0;
    while (n != 0)
    {
    n = (int)(n / 10);
    len++;
    }
    return len;
    }
    int number_separator(int n, int *arr)
    {
    int a = n;
    int len = length(n);
    for (int i = len - 1; i >= 0; i--)
    {
    arr[i] = (a % 10);
    a = a / 10;
    }
    }
    void main()
    {
    int n;
    scanf("enter a number : %d", &n);
    int arr[length(n)];
    number_separator(n, arr);
    int sum = 0;
    for (int i = 0; i < length(n); i++)
    {
    int a = n;
    sum += arr[i] * arr[i] * arr[i];
    }
    if (sum == n)
    {
    printf("The number %d is a armstrong number.\n", n);
    }
    else
    {
    printf("The number %d is not a armstrong number.\n", n);
    }
    }

     

     

Comments

Popular posts from this blog

Day - 1 of internship at Aartronix