EXPORT_SYMBOL () in the module

Source: Internet
Author: User
Module-Linux general technology-Linux programming and kernel information. The following is a detailed description. I have written two modules (Compilation and loading are normal ):
(1) global. ko (read and write the globalvar variable)
Globalvar is defined and exported for reading by the hello module. The definition is as follows:
Int globalvar = 0;
EXPORT_SYMBOL (globalvar );

(2) hello. ko (read globalvar)
The definition is as follows:
Void _ init hello_init ()
{
Extern int globalvar; // declare the exported globalvar variable
Printk ("var = % d \ n", globalvar); // read the globalvar value of the global module
Globalvar = 89; // reset the globalvar value for The golbal module to read.
......
}
Insmod./global. ko first, then insmod./hello. ko
After insmod is written to the kernel, the global module can read and write normally (for example, write 23 to globalvar and read 23), but the globalvar read in the hello module is not 23. Similarly, the globalvar value 89 set in the hello module cannot be correctly read in the global module.
My intention is to allow one module to write the value of globalvar to another module and read it correctly. Hope you can give me some advice. Thank you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.