정기적으로 정보를 인쇄하는 리눅스 장치 드라이버 코드를 작성해야합니다. 이 정보는 모듈이 언로드 될 때까지 인쇄되어야합니다. 나는 (내가 __init 때문에 가정 및 __exit 동시에 작동 할 수 없기 때문에 부울 값은 변경할 수 없습니다)이 코드는 작동하지 않습니다, 분명히이주기적으로 정보를 출력하는 리눅스 장치 드라이버
int boolean = 1;
static int hello_init(void)
{
while(boolean){
printk(KERN_ALERT "An information\n");
msleep(1000);
}
return 0;
}
static void hello_exit(void)
{
boolean=0;
printk(KERN_ALERT "Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
같은 것을 작성해야합니다. 누구든지이 문제를 해결하도록 도와 줄 수 있습니까?
printk()의 경우에만 매우 정확한 타이머가 필요하지 않으므로 해당 기능도 고려해야합니다. https://www.kernel.org/doc/htmldocs/device-drivers/ch01s03.html – Ray