我正在开发一个使用unlocked_ioctl的内核模块.我用内核版本2.6.24-23-generic测试了它,它运行得很好.现在我尝试使用内核版本3.3.1-1-ARCH并且发生了一些奇怪的事情:当请求值(cmd)为2时,不会执行ioctl函数.它返回0,但函数未执行.为了检查它是否未执行,我执行了以下操作:
static long midriver_ioctl(struct file *file,
unsigned int cmd, unsigned long arg) {
printk("Called with cmd = %d\n", cmd);
Run Code Online (Sandbox Code Playgroud)
我写了一个测试程序,从0到4096调用此设备的ioctl,我可以在dmesg中看到所有这些值的消息"用cmd = n调用",除了"2",唯一没有显示的值.
关于我做错了什么的线索?
先感谢您,
我在C ++中具有以下类:
class Event {
//...
friend ofstream& operator<<(ofstream& ofs, Event& e);
};
class SSHDFailureEvent: public Event {
//...
friend ofstream& operator<<(ofstream& ofs, SSHDFailureEvent& e);
};
Run Code Online (Sandbox Code Playgroud)
我要执行的代码是:
main(){
Event *e = new SSHDFailureEvent();
ofstream ofs("file");
ofs << *e;
Run Code Online (Sandbox Code Playgroud)
}
这是一种简化,但是我要做的是将文件中几种类型的事件写入文件。但是,它不使用SSHDFailureEvent的运算符<<,而是使用Event的运算符<<。有什么办法可以避免这种行为?
谢谢
我需要使用win32线程并行化应用程序.代码的一部分涉及使用线程修改静态数组.
我将数组作为参数传递如下:
struct threadParameter {
float **array;
int row;
}
Run Code Online (Sandbox Code Playgroud)
示例代码如下:
// Main
float data[100][100]
for (int i = 0; i < 100; i ++) {
tp = (*threadParameter) new threadParameter;
tp->array = (float **) data;
tp->row = i;
AfxBeginThread... // Begin thread code
}
// Thread Code
UINT myThread(LPVOID param) {
threadParameter *pp = (threadParameter *) param;
for (int j = 0; j < 100; j ++) {
pp->array[pp->row][j] = NEWVALUE;
}
}
Run Code Online (Sandbox Code Playgroud)
但是,在执行项目时,当我尝试通过**数组指针加入数组时,出现"访问冲突错误".如果阵列数据是动态的,则不会发生此问题.有没有办法解决这个问题(我不允许将数组数据从静态更改为动态)?
c++ ×2
c ×1
friend ×1
inheritance ×1
ioctl ×1
linux-kernel ×1
module ×1
operators ×1
pointers ×1
winapi ×1