Linux内核模块中的module_init和init_module有什么区别?(What is the difference between module_init and init_module in a Linux kernel module?)
我一直在尝试移植几个Linux驱动程序,并意识到内核版本2.4和2.6之间的Linux有很大的区别。
在2.4版本的内核中,模块编程如下 -
#define MODULE #include <linux/module.h> #include <linux/kernel.h> int init_module(void) { printk(KERN_INFO "Hi \n"); return 0; } void cleanup_module(void) { printk(KERN_INFO "Bye \n"); }
但是,对于2.6版本的内核,必须对模块进行以下操作 -
#include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> static int hi_init(void) { printk(KERN_ALERT "Hi \n"); return 0; } static void hi_exit(void) { printk(KERN_ALERT "Bye \n"); } module_init(hi_init); module_exit(hi_exit);
内核2.6中这种变化的优点是什么?为什么Linux内核2.6中需要这种变化?
I have been trying to port few linux drivers and realized that there is substantial difference between kernel version 2.4 and 2.6 of linux.
In the 2.4 version of kernel, the module programming was as below -
#define MODULE #include <linux/module.h> #include <linux/kernel.h> int init_module(void) { printk(KERN_INFO "Hi \n"); return 0; } void cleanup_module(void) { printk(KERN_INFO "Bye \n"); }
But, with the 2.6 version of kernel, the following has to be done for modules -
#include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> static int hi_init(void) { printk(KERN_ALERT "Hi \n"); return 0; } static void hi_exit(void) { printk(KERN_ALERT "Bye \n"); } module_init(hi_init); module_exit(hi_exit);
What is the advantage of such changes in Kernel 2.6 and Why was that change required in kernel 2.6 of linux ?
原文:https://stackoverflow.com/questions/3218320
最满意答案
您编写的MySQL代码很好,但视图代码不起作用,因为它设计用于处理日期/时间而不是相对时间段。
您应该通过将秒数除以这样得出小时/分钟:
$hours = floor($seconds / 3600); $minutes = floor($seconds / 60) % 60;
The MySQL code you've written is fine, but the view code won't work as it's designed to work with dates/times and not with relative periods of time.
You should derive the hours/minutes by dividing the seconds out like this:
$hours = floor($seconds / 3600); $minutes = floor($seconds / 60) % 60;
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
有什么数据库专业书籍介绍?[2022-05-19]
mysql -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
您编写的MySQL代码很好,但视图代码不起作用,因为它设计用于处理日期/时间而不是相对时间段。 您应该通过将秒数除以这样得出小时/分钟: $hours = floor($seconds / 3600); $minutes = floor($seconds / 60) % 60; The MySQL code you've written is fine, but the view code won't work as it's designed to work with dates/times and n ...
-
您可以使用临时变量来计算累计和: SELECT a.num, (@s := @s + a.num) AS cumulative FROM ID a, (SELECT @s := 0) dm ORDER BY a.num; I think I figured out the solution. Select num as n, (select sum(num) from ID where num <= n) from ID order by n;
-
MySQL计算特定列在分组后出现的次数(MySQL Count for the number of times a specific column appears after grouping)[2022-03-13]
SELECT mh.super_category AS parentDescription, mh.super_category AS parentSlug, mh.description AS subDescription, mh.slug AS subSlug, (SELECT COUNT(*) FROM Category_Groups AS countCg WHERE countCg.MenuHeading = mh.id) As qty, c ... -
所以你可以很容易地得到这张表的信息。 您需要查询information_schema以获取表格的create_time。 例如: SELECT create_time FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'your_schema' AND table_name = 'your_table' 点击此处查看更多信息: https : //dev.mysql.com/doc/refman/5.7/en/tables-table.html ...
-
我想你错过了execute()命令? 您可能还想使用fetchAll而不是fetch来获取所有内容。 try { $DBH = new PDO("mysql:host=localhost;dbname=$dbname",$dbuser,$dbpass); $DBH->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $STH = $DBH->prepare("SELECT status, COUNT(*) AS coun ...
-
试用: SELECT * FROM table_name WHERE time > CURTIME() ORDER BY time ASC LIMIT 1 编辑: 也许这是要走的路 SELECT * FROM table_name AS T WHERE T.time = (SELECT MIN(T2.time) FROM table_name AS T2 WHERE T2.time > ?) '?' 是您的参考时间的占位符(通过PHP)。 Try out: S ...
-
从mysql中的datetime列创建日期和时间列(Creating a date and time column from datetime column in mysql)[2022-03-28]
MySQL的日期和时间功能派上用场: SELECT DATE(yourDatetimeColumn), TIME(yourDatetimeColumn) FROM yourTable; 有关详细信息,请参阅手册中的日期和时间 。 使用STR_TO_DATE,您可以获得计算列的正确数据类型: SELECT STR_TO_DATE(DATE(yourDatetimeColumn), '%Y-%m-%d') As yourDate, STR_TO_DATE(TIME(yourDatetimeCo ...