0
我想創建一個使用Kernel_thread()作爲學校任務的一部分的內核線程。我根據我認爲已經過時的教授例子編寫代碼。我收到錯誤,我不知道如何繼續。使用kernel_thread創建內核線程
我在做什麼:
mypid = kernel_thread(myFirstFunctionOne, NULL, CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
其中myFirstFunctionOne被定義爲:
static int myFirstFunctionOne(void *unused){
struct task_struct *tsk = current;
spin_lock_irq(¤t->sighand->siglock);
flush_signal_handlers(current, 1);
spin_unlock_irq(¤t->sighand->siglock);
strcpy(tsk->comm, "My name: m_k_t_do_something_1");
set_task_state(tsk, TASK_RUNNING);
printk(KERN_NOTICE "My name: m_k_t_do_something_1 is about to be scheduled.\n");
schedule();
printk(KERN_NOTICE "My name: m_k_t_do_something_1 is now scheduled.\n");
return 0;
}
我打電話,只是創建具有如下功能:1行代碼向Kernel_init結束,create_my_first_processes ()。
static int __ref kernel_init(void *unused)
{
int ret;
kernel_init_freeable();
/* need to finish all async __init code before freeing the memory */
async_synchronize_full();
free_initmem();
mark_readonly();
system_state = SYSTEM_RUNNING;
numa_default_policy();
flush_delayed_fput();
rcu_end_inkernel_boot();
create_my_first_processes();
if (ramdisk_execute_command) {
ret = run_init_process(ramdisk_execute_command);
if (!ret)
return 0;
pr_err("Failed to execute %s (error %d)\n",
ramdisk_execute_command, ret);
}
...
這是啓動時,我得到的錯誤:
附加信息:內核上運行Ubuntu 4.8.6