多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > 服務器 > Linux內核進程和線程組織模型 (基于Kernel 4.3-rc3)

Linux內核進程和線程組織模型 (基于Kernel 4.3-rc3)

來源:程序員人生   發布時間:2016-04-08 08:40:21 閱讀次數:3005次

在linux內核代碼里面,看到有for_each_process()和for_each_process_thread()兩個函數,不太明白怎樣回事,就做了個代碼實驗

1. 驗證代碼

/***************************************************************** * Copyright (C) 2015 Intel Technology Co.,Ltd.* ****************************************************************** * lsitprocess.c * * DESCRIPTION: * 列出所有的進程/線程 * AUTHOR: * 劉峰 11579502 * * CREATED DATE: * 2015年09月17日 * REVISION: * 1.0 * * MODIFICATION HISTORY * -------------------- * $Log:$ * 劉峰 2015年09月17日 Creation *****************************************************************/ #include <linux/module.h> #include <linux/kernel.h> #include <linux/types.h> #include <linux/init.h> #include <linux/err.h> #include <linux/proc_fs.h> #include <linux/time.h> #include <linux/hrtimer.h> #include <linux/kvm_para.h> #include <linux/seq_file.h> #include <asm/uaccess.h> #include <stdbool.h> #include <asm/msr.h> #include <linux/slab.h> #include <asm/page_64_types.h> #include <linux/sched.h> #define LOCAL static #define KMOD_DBGDUMP(fmt, args...) printk(KERN_DEBUG "LISTPROCESS[%d] "fmt" ", __LINE__, args); #define KMOD_RAWDUMP(args...) printk(args); /* RAW 信息輸出 */ LOCAL struct proc_dir_entry *proc_file = NULL; LOCAL int32_t kmod_action_sw = 8; #define TEST_CASE_1 (1) #define TEST_CASE_2 (2) #define TEST_CASE_3 (3) #define KMODSEPC /****************************************************************************** * DESCRIPTION: * 利用list_for_each_entry進行打印 * INPUTS: * none * OUTPUTS: * none * RETURNS: * none ******************************************************************************/ void listprocess_test_case_1(void){ struct task_struct *task = NULL; struct task_struct *p = NULL; struct list_head *pos; int count = 0; printk("list_for_each "); printk("PID COMM "); task = &init_task; list_for_each(pos, &task->tasks ) { p = list_entry(pos, struct task_struct, tasks); count++; printk("%d %s ", p->pid, p->comm); } printk("Total process %d ", count); return; } /****************************************************************************** * DESCRIPTION: * 利用for_each_process進行打印 * INPUTS: * none * OUTPUTS: * none * RETURNS: * none ******************************************************************************/ void listprocess_test_case_2(void){ struct task_struct *tsk; int count = 0; printk("for_each_process "); printk("PID COMM "); for_each_process(tsk){ count++; printk("%d %s ", tsk->pid, tsk->comm); } printk("Total process %d ", count); return; } /****************************************************************************** * DESCRIPTION: * 利用for_each_process_thread進行打印 * INPUTS: * none * OUTPUTS: * none * RETURNS: * none ******************************************************************************/ void listprocess_test_case_3(void){ struct task_struct *p; struct task_struct *t; int count = 0; printk("for_each_process_thread "); printk("PID COMM "); for_each_process_thread(p,t){ count++; printk("%d %s ", t->pid, t->comm); } printk("Total thread %d ", count); return; } #if 1 KMODSEPC #endif /****************************************************************************** * DESCRIPTION: * PROC 文件讀方法 * INPUTS: * none * OUTPUTS: * none * RETURNS: * none ******************************************************************************/ LOCAL int kmod_proc_read(struct seq_file * m, void * v) { seq_printf(m, "Entering kmod_proc_read "); return 0; } /****************************************************************************** * DESCRIPTION: * PROC 文件寫方法 * INPUTS: * none * OUTPUTS: * none * RETURNS: * none ******************************************************************************/ static ssize_t kmod_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) { char debug_string[sizeof("4294967295")]; kmod_action_sw = 0; KMOD_DBGDUMP("%s","Entering kmod_proc_write"); if (count >= sizeof(debug_string)) return -EINVAL; if (copy_from_user(debug_string, buffer, count)) return -EFAULT; debug_string[count] = ' 主站蜘蛛池模板: 樱花aⅴ一区二区三区四区 影视精品网站入口 | 欧美黑人巨大 | 亚洲欧美成人中文在线网站 | 国产精品亚洲午夜不卡 | www.xxx欧美| 一区二区中文字幕在线观看 | 日本高新1区2区3区 日本国产亚洲 | 欧美人与物videos新另类性 | 欧美 中文字幕 | 欧美一级免费观看 | 在线观看美女网站 | 亚洲视频成人 | 在线视频一区二区三区四区 | 日韩 国产 欧美视频一区二区三区 | 亚洲国产精品第一区二区三区 | 国产亚洲一区二区在线观看 | 国产亚洲视频网站 | 亚洲视频精品在线观看 | 精品国产日韩亚洲一区在线 | 亚洲欧美日韩精品中文乱码 | 另类图片综合网 | 久久99精品国产99久久 | 国产成人精品一区二区三在线观看 | 福利一区二区三区视频午夜观看 | 最近中文字幕无 | 日日摸人人拍人人澡 | 国产一区不卡 | 亚洲精品综合久久 | 久久这里只有精品9 | 一区自拍| 日本叼嘿| 国产视频每日更新 | 国产日韩欧美综合一区二区三区 | 拍拍拍无挡视频免费全程1000 | 风间由美一区二区av101 | 欧美日韩中文国产 | 动漫日本在线免费观看 | 亚洲国产精品ⅴa在线观看 亚洲国产精品aaa一区 | 嫩草影院在线观看未满十八 | 精品久久一区二区 | 日一区二区 |