Re: [問題] 請問 kernel thread ..

看板LinuxDev作者 (1976。)時間17年前 (2008/03/10 15:47), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串6/6 (看更多)
過了很久,我來自問自答一下, 其實是個蠻蠢的問題, orz.... 這篇的錯誤在於 rwlock_t 要作初始化, 所以把 rwlock_t myevent_lock; 這行改成: DEFINE_RWLOCK(myevent_lock); 就可以了。 當然要記得 #include <linux/spinlock_types.h> 這樣大概就沒問題了吧。(?!) ※ 引述《nfsnfs (Busy)》之銘言: : 我嘗試寫了一個很簡單的 kernel thread, : 可是總是會在 read_lock 的時候跳出錯誤訊息, : 然後 kernel thread 有跑,但是跑一陣子就會整台電腦 freeze 了 @_@" : 以下附上錯誤訊息和 source code,希望哪位可以指正我做錯的地方,感恩 :) : error message: : BUG: rwlock bad magic on CPU#0, test_thread/2784, c078c59c : [<c04d9eaf>] _raw_read_lock+0x16/0x25 : [<c05b7b90>] test_thread+0x0/0x7c : [<c05b7bed>] test_thread+0x5d/0x7c : [<c05b7b90>] test_thread+0x0/0x7c : [<c0404927>] kernel_thread_helper+0x7/0x10 : ======================= : source code: : rwlock_t myevent_lock; : int test_thread (void *unused) : { : int num; : current->test_thread.enable = 1; : daemonize ("test_thread"); : allow_signal (SIGKILL); : for (;;) { : set_current_state (TASK_INTERRUPTIBLE); : schedule_timeout(30); : if (signal_pending (current)) break; : num = current->test_thread.num; : read_lock (&myevent_lock); : if (num > 0) { : read_unlock (&myevent_lock); : printk("Debug: num = %d\n", num); : } : else { : read_unlock (&myevent_lock); : } : } : set_current_state (TASK_RUNNING); : return 0; : } -- http://nfsnfs.pixnet.net 灰熊。紅襪。阿森納。 http://nfstry.blogspot.com 海邊。天空 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.115.53.138 ※ 編輯: nfsnfs 來自: 140.115.53.138 (03/10 15:49)
文章代碼(AID): #17rEUN5Q (LinuxDev)
文章代碼(AID): #17rEUN5Q (LinuxDev)