2

我在 kernel_module 中实现用户模式调度程序,当我在设备中调用“ums_dev_release”时,我必须杀死所有关联的 UMS_scheduler_threads,我正在尝试使用 kill_pid() 函数,但出现此错误:

error: implicit declaration of function ‘kill_pid’; did you mean ‘si_pid’? [-Werror=implicit-function-declaration] . 我也在进口:

#include <linux/sched.h>
#include <linux/pid.h>

从模块:

int ums_dev_release(struct inode *inodep, struct file *filep){
    int ret = release_scheduler(&sched_data,filep);
    if(ret<0){
        ERR_PRINTK(MODULE_NAME_LOG "ERROR UMS_DEV_RELEASE\n");
        return -EINVAL;
    }
    return 0;}

从模块调用的辅助函数:

int release_scheduler(struct list_head *sched_data, unsigned long int filep){
int ret;
struct list_head *current_item_list;
UMS_sched_data *current_UMS, *UMS_temp;
list_for_each_entry_safe(current_UMS,UMS_temp,sched_data, next)
{
    if (current_UMS->id_counter == filep)
    {
        struct list_head *current_thread_list;
        scheduler_thread  *cursor, *temp;
        list_for_each_entry_safe(cursor, temp, &current_UMS->scheduler_thread, next)
        {   
            kill_pid(cursor->pid, SIGTERM);
            list_del(&cursor->next);
            kfree(cursor);
        }
      
        ret=list_empty(&current_UMS->scheduler_thread);
        if(!ret){
            ERR_PPRINTK(MODULE_NAME_LOG"list is not empty ret=%d\n",ret);
            return -1;
        }
        list_del(&current_UMS->next);
        kfree(current_UMS);
         return 0;
    }
}
return -1;}

这些是2个结构:

typedef struct scheduler_thread{
        pid_t pid; 
        struct list_head  next;
}scheduler_thread;


typedef struct UMS_sched_data{ 
       struct list_head scheduler_thread;
       struct list_head  next;
       unsigned long int id_counter;
}UMS_sched_data;
4

0 回答 0