Find the answer to your Linux question:
Results 1 to 8 of 8
Hello fellow members, I need help as I am not proficient with Linux C++ Programming. There are two parts which I need to do in the coding provided below. 1. ...
  1. #1
    Just Joined!
    Join Date
    Apr 2011
    Posts
    4

    Lightbulb Need help on basic Linux C++ programming with simple RTAI functions

    Hello fellow members,

    I need help as I am not proficient with Linux C++ Programming. There are two parts which I need to do in the coding provided below.

    1. Produce the program so it can output the word "Hey there!" and wait two minute and print the word "See you later!".

    2. Produce the program that will output the text "Cool" every 20 seconds by setting a periodic task.
    #include <linux/kernel.h>
    #include <linux/module.h>
    MODULE_LICENSE("GPL");

    int init_module(void)
    {
    printk("Hey there!\n");

    return 0;
    }

    void cleanup_module(void)
    {
    printk("See you later!\n");

    return;
    }

  2. #2
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    sounds like a homework question

    though i'm curious if this actually needs to be a kernel module? or just a regular application???

  3. #3
    Linux Newbie
    Join Date
    Apr 2010
    Location
    Novosibirsk, Russia
    Posts
    136

  4. #4
    Just Joined!
    Join Date
    Apr 2011
    Posts
    4
    not homework question. its something i couldnt get working.

    its kernel stuff

  5. #5
    Just Joined!
    Join Date
    Apr 2011
    Posts
    4
    its kernel stuff if anyone know how to do it

  6. #6
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,974
    You are missing two macros that inform the kernel which is the init function, and which is the exit function. Try this:
    Code:
    #include <linux/init.h>
    #include <linux/module.h>
    MODULE_LICENSE("GPL");
    
    int init_module(void)
    {
        printk(KERN_ALERT "Hey there!\n");
        return 0;
    }
    
    void cleanup_module(void)
    {
        printk(KERN_ALERT "See you later!\n");
    }
    
    module_init(init_module);
    module_exit(cleanup_module);
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  7. #7
    Just Joined!
    Join Date
    Apr 2011
    Posts
    4
    oh thanks. but what am i missing here?

    1. Produce the program so it can output the word "Hey there!" and wait two minute and print the word "See you later!".

    2. Produce the program that will output the text "Cool" every 20 seconds by setting a periodic task.

  8. #8
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    i suggest you look at the previous link

    i'm treading lightly around this because it still sounds suspiciously like schoolwork/homework

    you need to look up what the module_init and module_exit functions are actually doing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...