lec02.key

Size: px
Start display at page:

Download "lec02.key"

Transcription

1 第 2 讲进程控制 张雷雷 zhangl@nju.edu.cn 南京 大学计算机科学与技术系 1

2 主要内容 用户 / 程序员眼中的进程 基本概念 ps 命令 进程创建, 等待, 终 止 ; 程序执 行行 Linux 内核眼中的进程 Linux 进程描述 Linux 内核通 用链表 Linux 进程 / 线程的实现机制 系统调 用!2

3 进程及线程基本定义 进程 (process) 处于执 行行期的程序及其所包含资源的总称 程序 : 可执 行行程序代码 数据 资源 : 打开 文件 挂起信号 地址空间 数据段 环境变量量等 线程 (thread) 进程中活动的对象 有独 立的程序计数器器 进程栈及 一组进程寄存器器 节省主存 减少管理理开销 快速切换!3

4 进程与线程的区别 从形态 角度 一个进程可包含 一个或多个线程 从调度 角度 进程是资源分配的基本单位 线程是处理理器器调度的独 立单位 从虚拟化 角度 进程提供两种虚拟机制 虚拟处理理器器 : 进程独享处理理器器的假象 虚拟内存 : 进程拥有系统内所有内存资源的假象 线程之间可共享虚拟内存, 但各 自拥有独 立虚拟处理理器器 对 Linux 系统 而 言, 线程只是 一种特殊的进程, 都称作 tasks!!4

5 ps 命令 (process status) ps -e strace ps 虚拟 文件系统 /proc /proc/pid/comm /proc/pid/fd or lsof /proc/pid/maps or pmap /proc/pid/environ pstree more!5

6 进程构成要素 正 文段 存放进程运 行行的代码, 描述进程需完成的功能 进程数据段 ( 地址空间 ) 存放正 文段在执 行行期间所需的数据和 工作区 包括全局变量量 动态分配的空间 ( 调 用 malloc 函数 ) 用户栈也在该数据段开辟, 存放函数调 用时的栈帧 局部变量量等 系统堆栈 每个进程捆绑 一个, 进程在内核态下 工作时使 用 保存中断现场 执 行行函数调 用时的参数和返回地址等 其中最重要的数据结构是进程控制块 (PCB)!6

7 进程虚拟地址空间结构 以 Linux/x86-32 系统为例例 ( 共 4G 空间 ) 用户空间 (0x ~ 0x bfff ffff) 可执 行行映象 进程运 行行时堆栈 进程控制信息, 如进程控制块 内核空间 (0x c 以上 ) 内核被映射进程内核空间 只允许进程在核 心态下访问!7

8 Process API fork(): 创建进程 wait(&status): 等待进程终 止 execve(): 运 行行可执 行行 文件 exit(status): 结束进程!8

9 创建 Linux 进程 fork: called once, returns twice identical copy: data, bss, init, stack, heap, text, open file descriptors possible return values: 0, child_id, -1 int pid = fork(); if (pid == 0) { //child process exec( ls"); } else { //parent process waitpid(pid, &status, options); };!9

10 Explosive fork graphs #include <unistd.h> int main(void) { while(1) fork(); } fork bomb,rabbit virus 比较./fork 和./fork >a 结果的不不同!10

11 fork, buffers 比较 write 和 printf 的不不同!11

12 The wait() System Call parent to wait for a child process to finish #include <sys/wait.h> pid_t wait(int *status); returns process ID of terminated child, or 1 on error 任意 一个 child 终 止即返回, 否则阻塞 pid_t waitpid(pid_t pid, int *status, int options); returns process ID of child, 0 (see text), or 1 on error 等待特定 child 进程 (pid) 终 止 pid==-1:wait(&status) 等价!12

13 The exec() System Call 运 行行可执 行行 文件, 并不不创建新的进程 返回什什么? What happens if you run exec ls in your shell?!13

14 Effect of exec() and fork() on Process Attributes!14

15 Effect of exec() and fork() on Process Attributes!15

16 创建 Windows 进程 The system call on Windows for creating a process is called, surprisingly enough, CreateProcess: BOOL CreateProcess( LPCTSTR lpapplicationname, LPTSTR lpcommandline, LPSECURITY_ATTRIBUTES lpprocessattributes, LPSECURITY_ATTRIBUTES lpthreadattributes, BOOL binherithandles, DWORD dwcreationflags, LPVOID lpenvironment, LPCTSTR lpcurrentdirectory, LPSTARTUPINFO lpstartupinfo, LPPROCESS_INFORMATION lpprocessinformation );!16

17 fork, exec Decoupling fork/exec CreateProcess 合并成 一个系统调 用 分开好处 : fork 和 exec 之间操作 child 进程 :IO 重定向, 改变当前 工作 目录, 关闭 网络连接.. 这些操作不不需要加 入 CreateProcess 的 API 接 口中 fork() 接 口简洁, 不不需要参数!17

18 例例 子 :Web 服务器器 Multi-process webserver with blocking I/O fork(): separate processes handle separate connections, used by Apache 1 creating and destroying processes are expensive connection pooling/pre-forking: FastCGI context switch still remains page/file/process table: 5ms 10ms why is this model good? WebGame game; /* single, global instance */!18

19 例例 子 :Web 服务器器 C10k problem:1k conn, 64k ports easy to perform DoS attacks upgrade hardware? diminishing return from threaded servers to event-driven servers Apache, Nginx ( engine-x ), Node Easily supports 10k+ concurrent connections on laptops Used by Facebook, Dropbox, Wikipedia, Wordpress 2010s: 200k~1million conn on 24 core server!19

20 主要内容 用户 / 程序员眼中的进程 基本概念 ps 命令 进程创建, 等待, 终 止 ; 程序执 行行 Linux 内核眼中的进程 Linux 进程描述 Linux 内核通 用链表 Linux 进程 / 线程的实现机制 系统调 用!20

21 Linux 进程描述符 进程描述符 数据结构 :struct task_struct 定义位置 :include/linux/sched.h 内核数据结构 ~1.7KB on 32bit machine 160+ 成员变量量 也称进程控制块 PCB(control block)!21

22 Linux 进程描述符的信息组成 进程状态信息 (state, flags, ptrace) 调度信息 (static_prio, normal_proi, run_list, array, policy) 内存管理理 (mm, active_mm) 进程状态位信息 (binfmt, exit_state, exit_code, exit_signal) 身份信息 (pid, tgid, uid, suid, fsuid, gid, egid, sgid, fsgid) 家族信息 (real_parent, parent, children, sibling) 进程耗间信息 (realtime, utime, stime, starttime) 时钟信息 (it_prof_expires, it_virt_expires, it_sched_expires) 文件系统信息 (link_count, fs, files) IPC 信息 (sysvsem, signal, sighand, blocked, sigmask, pending)!22

23 进程描述符与进程资源相关的信息!23

24 进程状态 成员名 :volatile long state 功能 : 表征进程的可运 行行性 状态定义 [include/linux/sched.h#l70]!24

25 进程状态 类型定义说明 运 行行态 / 就绪态 TASK_RUNNING: 正在运 行行或已处于就绪只等待 CPU 调度 _TASK_TRACED: 供调试使 用 被挂起状态 TASK_INTERRUPTIBLE: 可被信号或中断唤醒进 入就绪队列列 TASK_UNINTERRUPTIBLE: 等待资源, 不不可被其他进程中断 _TASK_STOPPED: 被调试暂停, 或收到 SIGSTOP 等信号 不不可运 行行态 TASK_ZOMBIE: 正在终 止 ( 已释放内存 文件等资源, 但内核数据结构信息未释放 ), 等待 父进程通过 wait4() 或 waitpid() 回收 TASK_DEAD: 已退出且不不需 父进程回收的进程的状态 说明 调度器器主要处理理运 行行 / 就绪和被挂起两种状态下的进程!25

26 进程状态转换图

27 Linux 系统进程系统堆栈结构 每个进程都要单独分配 一个系统堆栈 (kernel stack) 抢占式内核 结构组成 内核态的进程堆栈 进程描述符信息 (task_struct) 结构特点 8192( 2 13 ) 字节, 两个 页框 占据连续两个 页框, 且第 一个 页框起始地址为 2 13 的倍数!27

28 Linux 进程系统堆栈结构 进程描述符由 slab 分配器器动态 生成 栈底 用新结构 struct thread_info, 指向进程描述符!28

29 Linux 当前运 行行进程描述符的获取 由 current( 宏 ) 来获取当前进程的进程描述符 根据 THREAD_SIZE 大 小, 分别屏蔽掉内核栈的 12-bit LSB(4K) 或 13-bit LSB(8K), 从 而获得内核栈的起始位置 对应汇编指令 movl $0xfffe000, %ecx andl %esp, %ecx movl %ecx, p current is not a static variable, useful for SMP!29

30 进程标识 成员名 :pid_t pid 功能 内核通过 pid 标识每个进程 pid 与进程描述符之间有严格的 一 一对应关系 数据类型说明 pid_t 实际上是 一个 int 类型 取值范围 :0 ~ 最 大值修改 :/proc/sys/kernel/pid_max 生成新 pid:get_pid() 获取进程 pid ps 命令 访问 /proc/pid getpid()->sys_getpid()!30

31 线程组 (thread group) 标识 成员名 :pid_t tgid 功能 标识进程是否属于同组, 组 ID 是第 一个组内线程 ( 父进程 ) 的 PID,getpid() returns this ID 线程组中的所有线程共享相同的 tgid 组 ID 赋值相关操作 单线程进程 :tgid 和 pid 相等 多线程进程 : 组内所有线程 tgid 都相等, 且等于 父进程 pid!31

32 获取 用户相关的进程标识信息代码 获取 用户相关的进程标识信息的 方法 :getxxx()!32

33 进程的家族关系 所有进程都是 init 进程 (pid=1) 的后代 struct task_struct *task; for (task = current; task!= &init_task; task = task->parent); /* task now points to init */ 每个进程必须有 一个 父进程 每个进程可以拥有零个或者多个 子进程 具有相同 父进程的进程称为兄弟!33

34 进程家族关系相关结构定义!34

35 进程家族结构图 最年年 长 子进程 最年年幼 子进程 struct task_struct struct list_head struct list_head struct list_head!35

36 Linux 进程描述符中进程链表成员 struct list_head run_list 优先级相同的进程组成的进程链表 struct list_head tasks 链接系统中所有进程的链表 struct list_head children 链接所有孩 子节点进程的链表 struct list_head sibling 链接所有兄弟节点进程的链表 Linux 内核链表中, 需要 用链表组织起来的数据通常会包含 一个 struct list_head 成员!36

37 主要内容 用户 / 程序员眼中的进程 基本概念 ps 命令 进程创建, 等待, 终 止 ; 程序执 行行 Linux 内核眼中的进程 Linux 进程描述 Linux 内核通 用链表 Linux 进程的实现机制 Linux 线程的实现机制 系统调 用!37

38 传统链表数据结构定义模式 基本组成 数据域 : 存储数据 指针域 : 建 立与下 一个节点的联系 typedef struct node { int data; struct node *next; } 单链表 双链表!38

39 内核通 用链表 通 用双向链表结构 :include/linux/list.h 说明 链表结构作为 一个成员嵌 入到宿主数据结构内 链表结构可放在宿主结构内的任何位置 一个宿主结构可有多个内核链表结构 通 用双向链表优点 : 避免为每个数据项类型定义 自 己的链表!39

40 内核通 用链表结构关系图 prev 空链表 next prev next list_head 结构 有两项链表的链表头 prev next 含 list_head 的定制结构 List_entry 宏的效果 prev next!40

41 内核通 用链表定义示例例 nf_sockopt_ops 结构!41

42 nf_sockopts 链表示意图 链表的头元素没有数据域!42

43 内核通 用链表的基本操作 声明与初始化 内核通 用链表节点的插 入 / 删除 / 移动 内核通 用链表的遍历与访问 内核通 用链表节点合并!43

44 内核通 用链表的声明与初始化 声明时初始化链表 #define LIST_HEAD_INIT(name) {&(name), &(name)} #define LIST_HEAD(name) \ struct list_head name = LIST_HEAD_INIT(name) 运 行行时初始化链表 #define INIT_LIST_HEAD(ptr) do { (ptr)->next = (ptr); (ptr)->prev = (ptr); } while (0) 内核通 用链表的创建示例例 方法 一 LIST_HEAD(nf_sockopts) 方法 二 struct list_head nf_sockopts; INIT_LIST_HEAD(&nf_sockopts)!44

45 内核通 用链表成员的访问 核 心问题 内核通 用链表仅保存宿主结构项中相应 list_head 成员变量量的地址 如何通过 list_head 成员访问到作为宿主结构地址, 并得到其他成员变量量信息 解决途径 :list_entry 宏定义 list_entry(ptr, type, member)!45

46 内核通 用链表访问 方法 :list_entry 由 list_head 链表节点获取对应的宿主结构项指针 list_entry(ptr, type, member) ptr: 当前 list_head 节点的指针 ( 宿主结构项的 list_head 成员 ) 举例例 type: 宿主数据结构类型 member: 宿主数据结构中定义的 list_head 类型变量量 访问 nf_sockopts 链表中 首个 nf_sockopt_ops 变量量 struct nf_sockopt_ops *ops = list_entry(nf_sockopts- >next, struct nf_sockopt_ops, list);!46

47 list_entry 的实现机制 list_entry 宏定义 #define list_entry(ptr, type, member) container_of(ptr, type, member) container_of 宏定义 (include/linux/kernel.h#l962) #define container_of(ptr, type, member) ({ \ // 将链表中 ptr 转换成宿主结构 type 中成员 member 的类型 const typeof( ((type *)0)->member ) * mptr = (ptr); \ // mptr 减去 member 成员偏移地址正好是 type 结构地址 (type *)( (char *) mptr - offsetof(type, member) );})!47

48 list_entry 的实现机制 offsetof 宏定义 (include/linux/stddef.h) #define offsetof(type, MEMBER) ((size_t) &((TYPE *)0)- >MEMBER) size_t: 定义为 unsigned int(i386) 先求得结构成员在结构中的偏移量量, 然后根据成员变量量的地址反过来得出属主结构变量量的地址 ((type *)0)->member: 将 0 地址强制 " 转换 " 为 type 结构的指针, 再访问到 type 结构中的 member 成员!48

49 offsetof() 的宏原理理说明 当结构 nf_sockopt_ops 正好在地址 0 上时其成员 list 的地址, 即成员位移 对 一给定结构,offsetof(type, member) 是 一个常量量, list_entry() 利利 用该不不变的偏移量量求得链表数据项的变量量地!49 址

50 内核通 用链表访问 方法 :list_for_each 遍历整个链表结构的各个 list_head 成员 list_for_each(pos, head) [include/linux/list.h] pos: list_head 类型结构变量量, 作为循环变量量 head: 链表头节点 利利 用 pos 作为循环变量量, 从表头 head 开始, 逐项向后 (next 方向 ) 移动 pos, 直 至 又回到 head 宏定义形式!50

51 内核通 用链表访问 方法 :list_for_each_entry 遍历整个链表结构的各个宿主结构项 #define list_for_each_entry(pos, head, member) pos: 宿主数据结构类型变量量, 而不不是 list_head 类型变量量 ( 与 list_for_each(pos, head) 的区别 ) head: 链表头节点 member: 宿主数据结构中定义的 list_head 类型变量量 举例例 struct task_struct *task; for_each_process(task) { printk("%s[%d]\n", task->comm, task->pid); }!51

52 主要内容 用户 / 程序员眼中的进程 基本概念 ps 命令 进程创建, 等待, 终 止 ; 程序执 行行 Linux 内核眼中的进程 Linux 进程描述 Linux 内核通 用链表 Linux 进程的实现机制 Linux 线程的实现机制 系统调 用!52

53 Linux 系统启动过程 打开 PC 电源 BIOS 开机 自检 按 BIOS 中设置的启动设备 ( 通常是硬盘 ) 启动 启动设备上安装的引导程序 lilo 或 grub 开始引导 Linux 内核引导 start_kernel() 如果有多个 CPU, 则先启 用 一个 CPU 来启动内核 执 行行 /sbin/init 程序 启动 getty, 打开终端供 用户登录系统 用户登录成功后, 进 入 Shell 环境!53

54 Linux 进程系统启动过程 0 号进程 : 1) 继续初始化内核 2) 执 行行 用户空间初始化程序 /sbin/init 3) 系统没有其他任务时执 行行0 号进程 0 号进程 1 号进程 0 号进程 : 系统 自举过程, 实质为内核本身 通过 int 0x80 系统调 用创建 1 号内核线程 判断 : 比较 ESP 和 ESI 值相等为 0 号进程, 否则为 1 号内核线程 bdflush dpiod kswapd 内核态 注意 : 没有使 用 fork()! 1 号进程 用户态 shell1 getty2 gettyn 用户进程 1 子进程 1 用户进程 2 子进程 2 首个 用户进程 (init 进程 ) 1) 按照配置 文件 /etc/initab 的要求, 完成系统启动 工作 2) 创建编号若 干个终端注册进程 getty!54

55 Linux 的 0 号进程 Process 0 称为 0 号进程或 idle 进程,one per CPU 维护 Linux 内核代码段 数据段及堆栈 是唯 一 一个通过静态分配创建的进程 [arch/x86/kernel/ init_task.c#l180] INIT_TASK 完成 init_task 变量量中进程描述符初始化 INIT_THREAD_INFO 完成对 init_thread_info 中 thread_info 及内核堆栈的初始化 INIT_MM, INIT_FS, INIT_FILES, INIT_SIGNALS, INIT_SIGHAND 等宏初始化进程描述符的各个对应域 start_kernel 函数 (/init/main.c) 是内核的主要接 入点, 初始化内核所需所有数据结构 激活中断 创建 1 号内核线程!55

56 start_kernel: init/main.c#l531!56

57 Process 1 Linux 的 1 号内核进程 又称为 init 进程 (PID=1),One per machine 由 0 号进程在 start_kernel 函数中调 用 rest_init 创建 调度程序选择到 init 进程时,init 进程开始执 行行 kernel_init() 函数 创建 init 进程后, 进程 0 执 行行 cpu_idle() 函数 该函数本质上是在开中断的情况下重复执 行行 hlt 汇编语 言指令, 只有没有其他进程处于 TASK_RUNNING 状态下才执 行行进程 0!57

58 kernel_init: init/main.c#l1057!58

59 distinguished processes The Linux/UNIX init process (Process 1): /sbin/init First and only user process instantiated by the kernel Kernel forks init and goes idle Responsible for forking all other processes: login screen, window manager Can be configured to start different things: read scripts in /etc/init.d on Linux The Android zygote process Also called main, parent of all managed (Java) applications Preloaded version of Dalvik runtime, libraries fork() makes new application loading very efficient Less memory, faster app start!59

60 Android process!60

61 Linux 进程创建 传统 UNIX 操作系统 子进程复制 父进程所拥有的资源 缺点 : 创建过程慢 效率低 子进程复制的很多资源不不会被使 用 现代 Linux/UNIX 内核 : 引 入三种机制优化进程创建效率 写时复制技术 (Copy-On-Writing) 轻量量级进程 允许 父 子进程共享 页表 打开 文件列列表 信号处理理等数据结构 但每个进程应该有 自 己的程序计数器器 寄存器器集合 核 心栈和 用户栈 vfork() 新进程可共享 父进程的内存地址空间!61

62 Linux 进程创建 进程创建函数 pid_t fork(void); pid_t vfork(void); int clone(int (*fn)(void * arg), void *stack, int flags, void * arg); 三函数都调 同 内核函数 do_fork( ) [kernel/fork.c] arch/x86/kernel/process_32.c asmlinkage int sys_fork(struct pt_regs regs) { return do_fork(sigchld, regs.esp, &regs, 0, NULL, NULL); }!62

63 do_fork() 内核函数原型 kernel/fork.c#l1354, 函数调 形式 do_fork(unsigned long clone_flag, unsigned long stack_start, struct pt_regs *regs, unsigned long stack_size, int _user *parent_tidptr, int _user *child_tidptr); 参数说明 clone_flag: 子进程创建相关标志 stact_start: 将 用户态堆栈指针赋给 子进程的 esp regs: 指向通 用寄存器器值的指针 stack_size: 未使 用 ( 总设为 0) parent_tidptr: 父进程的 用户态变量量地址, 若需 父进程与新轻量量级进程有相同 PID, 则需设置 CLONE_PARENT_SETTID child_tidptr: 新轻量量级进程的 用户态变量量地址, 若需让新进程具有同类进程的 PID, 需设置 CLONE_CHILD_SETTID!63

64 CLONE 参数标志分类 资源共享 ( 段 页 打开 文件共享 ) CLONE_VM: 子进程共享 父进程的内存描述符和进程 页表 ( 不不是 页 ), 即共享 父进程的整个地址空间 CLONE_FILES: 子进程共享 父进程打开的 文件 ( 即共享 文件描述表 ) CLONE_SETTLS: 为 子进程设置 一个新 TLS(Thread Local Storage) 段 进程关系 CLONE_THREAD: 子进程和 父进程处于同 一个线程组 ( 即 PCB 中的 tgid 值相同 ) 该标记必须和 CLONE_SIGHAND 及 CLONE_VM 联合使 用 CLONE_PARENT: 同 父, 创建者进程与新建进程是兄弟, 新进程不不是创建进程的 子进程, 即两进程 PCB 的 real_parent 相同 CLONE_PTRACE: 父进程处于被调试器器跟踪状态时可以使 用此标志, 表示希望 子进程也被调试 CLONE_UNTRACE: 不不论 父进程是否处于被调试器器跟踪状态, 子进程不不被跟踪 通常 用于创建内核线程!64

65 do_fork() 的主要任务 创建 PID, 分配内核堆栈 创建进程控制块 task_struct 进程 ID 信息 ( 线程组 ID 进程组 ID 会话 ID) 进程家族关系 进程资源及资源限制 进程状态 进程之间的通信 赋给 子进程的资源 子进程的栈 ( 父进程 alloc 的内存地址 ) 线程局部存储段 (tls) 返回 子进程 tid 的地址 父进程 用户空间内的地址 子进程 用户空间的地址 进程调度!65

66 do_fork: kernel/fork.c#l2092!66

67 copy_process: kernel/fork.c#l1605!67

68 copy_files: kernel/fork.c#l1353!68

69 exec 大多情况下 子进程从 fork 返回后都调 用 exec() 函数来执 行行新的程序 这种情况下, 子进程根本不不需要读或者修改 父进程拥有的所有资源 因此 fork 中地址空间的复制依赖于写时拷 贝技术, 降低 fork 的开销 进程调 用 exec() 函数时, 该进程完全由新程序替代, 新程序从 main 开始执 行行 exec() 并不不创建新进程, 前后进程 ID 不不变, 但 用另外 一个程序替代当前进程的正 文 数据 堆栈等!69

70 exec!70

71 主要内容 用户 / 程序员眼中的进程 基本概念 ps 命令 进程创建, 等待, 终 止 ; 程序执 行行 Linux 内核眼中的进程 Linux 进程描述 Linux 内核通 用链表 Linux 进程的实现机制 Linux 线程的实现机制 系统调 用!71

72 Linux 的线程描述机制 举例例 ( 包含两个线程的进程 ) 对于 非 Linux 系统 有 一个包含两个不不同线程指针的进程描述符 每个线程指针描述其独占资源 对于 Linux 系统 创建两个进程并分配两个普通 task_struct 结构 建 立两个进程时只要指定它们共享的某些资源 非 Linux 系统!72 Linux 系统

73 Linux 的线程描述机制 其他多线程操作系统 通过两种数据结构来表示线程和进程 : 进程表项和线程表项 每个进程表项可以指向若 干个线程表项, 调度器器在进程的时间 片内再调度线程 Linux 系统 从内核 角度, 没有线程概念, 所有线程当进程来实现 线程被视为与其他进程共享某些资源的进程, 都有 自 己的进程描述符 task_struct 内核没有针对线程的调度算法或数据结构!73

74 创建 用户线程 函数调 形式 int clone(int (*fn)(void * arg), void *stack, int flags, void * arg); int pthread_create(pthread_t *restrict tidp, const pthread_attr_t *restrict attr, void *(*start_rtn)(void), void *restrict arg); tidp: 新线程的线程描述表指针 attr: 为新线程定义不不同属性 ( 如栈尺 寸 ) 默认为 NULL 第三个和第四个参数指定执 行行的函数 start_rtn 和传递给函数的参数 arg 两者区别 clone() 创建内核 支持的 用户线程, 对内核可 见且由内核调度 pthread_create() 由基于 POSIX 标准的线程库创建的 用户线程 但在 Linux 里里, pthread_create() 最终调 用 clone() 实现!74

75 创建内核线程 只能由其他内核线程来创建 函数原型 int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags) 说明 函数返回时, 父线程退出, 并返回 一个指向 子线程 task_struct 的指针 子线程执 行行 fn 指向的函数,arg 是运 行行时所需的参数 flag 定义内核线程的常 用参数标志, 如 CLONE_FS, CLONE_FILES, CLONE_SIGHAND 一般情况下, 内核线程所调 用函数 一直执 行行 ( 该函数通常由 一个循环构成 ), 直到系统关闭!75

76 内核线程的创建过程!76

77 主要内容 用户 / 程序员眼中的进程 基本概念 ps 命令 进程创建, 等待, 终 止 ; 程序执 行行 Linux 内核眼中的进程 Linux 进程描述 Linux 内核通 用链表 Linux 进程的实现机制 Linux 线程的实现机制 系统调 用!77

78 系统调 用流程!78

79 2.x 内核 1. sys_foo 加 入系统调 用表 :arch/i386/kernel/entry.s 2. 对每个 支持的系统结构, 定义系统调 用号 :include/asm/ unistd.h 3. 加 入 sys_foo 源码 4. 编译内核重启 5. 使 用新系统调 用 Linux kernel is constantly changing Check the source to see how existing system calls are added, e,g,, getpid().!79

80 增加系统调 用 foo() ENTRY(sys_call_table).long sys_restart_syscall /* 0 */.long sys_exit.long sys_fork.long sys_read.long sys_write.long sys_open /* 5 */....long sys_eventfd2.long sys_epoll_create1.long sys_dup3 /* 330 */.long sys_pipe2.long sys_inotify_init1.long sys_preadv.long sys_pwritev.long sys_rt_tgsigqueueinfo /* 335 */.long sys_perf_event_open.long sys_recvmmsg.long sys_foo arch/i386/kernel/entry.s asmlinkage long sys_foo(void) { return THREAD_SIZE; }!80 /* * This file contains the system call numbers. */ #define NR_restart_syscall 0 #define NR_exit 1 #define NR_fork 2 #define NR_read 3 #define NR_write 4 #define NR_open 5... #define NR_signalfd4 327 #define NR_eventfd2 328 #define NR_epoll_create1 329 #define NR_dup3 330 #define NR_pipe2 331 #define NR_inotify_init1 332 #define NR_preadv 333 #define NR_pwritev 334 #define NR_rt_tgsigqueueinfo 335 #define NR_perf_event_open 336 #define NR_recvmmsg 337 #define NR_foo include/asm/unistd.h

81 实现系统调 用 kernel/sys.c#l891: sys_getpid() 内核空间与 用户空间的内存不不能直接互访 :copy_to_user, copy_from_user!81

82 使 用系统调 用 #define NR_foo 283 syscall0(long, foo) int main () { long stack_size; stack_size = foo (); printf ("The kernel stack size is %ld\n", stack_size); return 0; } _syscalln() 宏 (n=0 6),2n+2 个参数 long open(const char *filename, int flags, int mode) #define NR_open 5 _syscall3(long, open, const char *, filename, int, flags, int, mode)!82

83 系统调 用开销 User-mode instructions per cycles (IPC) of Xalan (from SPEC CPU 2006) in response to a system call exception event, as measured on an Intel Core i7 processor. FlexSC: Flexible System Call Scheduling with Exception-Less System Calls. Livio Soares, Michael Stumm, OSDI 2010!83

84 系统调 用指令 Int 0x80 system call number in eax register New system call hardware on x86:syscall/sysret use MSRs (machine specific registers) getpid() measurement Int 0x80: 371 cycles syscall: 231 cycles!84

85 4.x 内核增加系统调 用 修改系统调 用表 :arch/x86/entry/syscalls/syscall_64.tbl <number> <abi> <name> <entry point> 1 common write x64_sys_write 声明新系统调 用原型 :include/linux/syscalls.h asmlinkage long sys_foo(void); 添加新系统调 用源码 修改已有源码 文件 增加新源码 文件, 需要相应修改 Makefile!85

86 使 用新的系统调 用 #include <unistd.h> #include <sys/syscall.h> int main() { syscall(1, 1, Hello World, 11); return 0; } syscall wrapper provided by glibc 等价 syscall(1, 1, Hello World, 11); write (1, "Hello World", 11);!86

87 Lab2: Android Process Tree no pstree in Android 增加系统调 用, 按照深度优先的顺序返回进程树的信息 int prtree(struct prinfo *buf, int *nr); 调 用 pstree 打印进程树信息!87

88 谢谢! 下次课 : 基础实验楼 乙 126!88

Kernel Kernel Kernel Kernel load estimator runqueue kernel/sched.

Kernel Kernel Kernel Kernel load estimator runqueue kernel/sched. Linux Kernel 2.6 20321131 Kernel 2.4...3 Kernel 2.4...3 Kernel 2.4...3 Kernel 2.6...3...3 1....3 2....4 3. load estimator...4 4....4 5....4...4 1....4 2. runqueue kernel/sched.c...4 3. task_struct(include/linux/sched.h)...6...9

More information

提纲 1 2 OS Examples for 3

提纲 1 2 OS Examples for 3 第 4 章 Threads2( 线程 2) 中国科学技术大学计算机学院 October 28, 2009 提纲 1 2 OS Examples for 3 Outline 1 2 OS Examples for 3 Windows XP Threads I An Windows XP application runs as a seperate process, and each process may

More information

ebook

ebook 3 3 3.1 3.1.1 ( ) 90 3 1966 B e r n s t e i n P ( i ) R ( i ) W ( i P ( i P ( j ) 1) R( i) W( j)=φ 2) W( i) R( j)=φ 3) W( i) W( j)=φ 3.1.2 ( p r o c e s s ) 91 Wi n d o w s Process Control Bl o c k P C

More information

Microsoft PowerPoint - os_4.ppt

Microsoft PowerPoint - os_4.ppt 行 程 資 科 系 林 偉 川 行 程 概 念 行 程 與 程 式 主 要 的 不 同 點 : 程 式 是 被 放 在 外 部 的 儲 存 裝 置 如 磁 碟 上, 而 行 程 則 被 放 在 記 憶 體 中 程 式 在 儲 存 裝 置 中 是 靜 態 的, 而 行 程 在 記 憶 體 中 是 動 態 的, 它 會 隨 著 一 些 事 件 的 發 生 而 產 生 相 對 的 改 變 行 程, 就 是

More information

第一章 概论

第一章  概论 1 2 3 4 5 6 7 8 Linux 7.1 7.1.1 1 1 2 3 2 3 1 2 3 3 1 2 3 7.1.2 1 2 1 2 3 4 5 7.1.3 1 1 2 3 2 7.1 3 7.1.4 1 1 PCB 2 3 2 PCB PCB PCB PCB PCB 4 1 2 PSW 3 CPU CPU 4 PCB PCB CPU PCB PCB PCB PCB PCB PCB PCB

More information

C/C++ - 文件IO

C/C++ - 文件IO C/C++ IO Table of contents 1. 2. 3. 4. 1 C ASCII ASCII ASCII 2 10000 00100111 00010000 31H, 30H, 30H, 30H, 30H 1, 0, 0, 0, 0 ASCII 3 4 5 UNIX ANSI C 5 FILE FILE 6 stdio.h typedef struct { int level ;

More information

A Preliminary Implementation of Linux Kernel Virus and Process Hiding

A Preliminary Implementation of Linux Kernel Virus and Process Hiding 邵 俊 儒 翁 健 吉 妍 年 月 日 学 号 学 号 学 号 摘 要 结 合 课 堂 知 识 我 们 设 计 了 一 个 内 核 病 毒 该 病 毒 同 时 具 有 木 马 的 自 动 性 的 隐 蔽 性 和 蠕 虫 的 感 染 能 力 该 病 毒 获 得 权 限 后 会 自 动 将 自 身 加 入 内 核 模 块 中 劫 持 的 系 统 调 用 并 通 过 简 单 的 方 法 实 现 自 身 的

More information

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++;

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; Memory & Pointer trio@seu.edu.cn 2.1 2.1.1 1 int *p int a 0x00C7 0x00C7 0x00C7 2.1.2 2 int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; 2.1.3 1. 2. 3. 3 int A,

More information

<4D F736F F F696E74202D20B2D9D7F7CFB5CDB35F4C696E7578BDF8B3CCD3EBCFDFB3CC2E BBCE6C8DDC4A3CABD5D>

<4D F736F F F696E74202D20B2D9D7F7CFB5CDB35F4C696E7578BDF8B3CCD3EBCFDFB3CC2E BBCE6C8DDC4A3CABD5D> Linux 中的进程与线程 进程调度 Linux 线程 目录 1 进程控制块 (PCB) 是什么? PCB 的内容 Linux 下的 PCB 有什么特点? Task_struct 进程是程序执行时的一个实例 1. 有一段程序供其执行 2. 有起码的 私有财产, 也就是进程的专有的系统堆栈空间 3. 有 户口, 就是内核中的一个 task_struct 数据结构, 有了这个数据结构, 进程才能成为内核调度的一个基本单位,

More information

PowerPoint Presentation

PowerPoint Presentation 列 Kernel Objects Windows Kernel Object 來 理 行 行 What is a Kernel Object? The data structure maintains information about the object Process Object: 錄了 PID, priority, exit code File Object: 錄了 byte offset,

More information

Oracle 4

Oracle 4 Oracle 4 01 04 Oracle 07 Oracle Oracle Instance Oracle Instance Oracle Instance Oracle Database Oracle Database Instance Parameter File Pfile Instance Instance Instance Instance Oracle Instance System

More information

W. Richard Stevens UNIX Sockets API echo Sockets TCP OOB IO C struct C/C++ UNIX fork() select(2)/poll(2)/epoll(4) IO IO CPU 100% libevent UNIX CPU IO

W. Richard Stevens UNIX Sockets API echo Sockets TCP OOB IO C struct C/C++ UNIX fork() select(2)/poll(2)/epoll(4) IO IO CPU 100% libevent UNIX CPU IO Linux muduo C++ (giantchen@gmail.com) 2012-09-30 C++ TCP C++ x86-64 Linux TCP one loop per thread Linux native muduo C++ IT 5 C++ muduo 2 C++ C++ Primer 4 W. Richard Stevens UNIX Sockets API echo Sockets

More information

中文模板

中文模板 操作系统课程作业 源码阅读报告 1 源码阅读报告 1. Linux 内核中进程管理模块的整体结构 Linux 内核的进程管理模块包括进程的数据结构表示 进程的创建与终止 进程调度 进程间通信 CPU 调度 进程同步 死锁处理等 整个进程管理模块以结构体 task_struct 为核心, 其他的操作都针对这个结构体及其各个成员进行操作 比如, 创建一个进程就是新建一个 task_struct 结构体,

More information

华恒家庭网关方案

华恒家庭网关方案 LINUX V1.5 1 2 1 2 LINUX WINDOWS PC VC LINUX WINDOWS LINUX 90% GUI LINUX C 3 REDHAT 9 LINUX PC TFTP/NFS http://www.hhcn.com/chinese/embedlinux-res.html minicom NFS mount C HHARM9-EDU 1 LINUX HHARM9-EDU

More information

ebook15-10

ebook15-10 1 0 10.1 U N I X V 7 4. 3 B S D S V R 3 P O S I X. 1 100 % 10.2 S I G S I G A B RT a b o r t S I G A L R M a l a r m V 7 1 5 S V R 4 4. 3 + B S D 31 < s i g n a l. h > 0 10. 9 k i l l 0 P O S I X. 1 D

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 49 [P.51] C/C++ [P.52] [P.53] [P.55] (int) [P.57] (float/double) [P.58] printf scanf [P.59] [P.61] ( / ) [P.62] (char) [P.65] : +-*/% [P.67] : = [P.68] : ,

More information

untitled

untitled 3 C++ 3.1 3.2 3.3 3.4 new delete 3.5 this 3.6 3.7 3.1 3.1 class struct union struct union C class C++ C++ 3.1 3.1 #include struct STRING { typedef char *CHARPTR; // CHARPTR s; // int strlen(

More information

1 LINUX IDE Emacs gcc gdb Emacs + gcc + gdb IDE Emacs IDE C Emacs Emacs IDE ICE Integrated Computing Environment Emacs Unix Linux Emacs Emacs Emacs Un

1 LINUX IDE Emacs gcc gdb Emacs + gcc + gdb IDE Emacs IDE C Emacs Emacs IDE ICE Integrated Computing Environment Emacs Unix Linux Emacs Emacs Emacs Un Linux C July 27, 2016 Contents 1 Linux IDE 1 2 GCC 3 2.1 hello.c hello.exe........................... 5 2.2............................... 9 2.2.1 -Wall................................ 9 2.2.2 -E..................................

More information

C/C++程序设计 - 字符串与格式化输入/输出

C/C++程序设计 - 字符串与格式化输入/输出 C/C++ / Table of contents 1. 2. 3. 4. 1 i # include # include // density of human body : 1. 04 e3 kg / m ^3 # define DENSITY 1. 04 e3 int main ( void ) { float weight, volume ; int

More information

Kubenetes 系列列公开课 2 每周四晚 8 点档 1. Kubernetes 初探 2. 上 手 Kubernetes 3. Kubernetes 的资源调度 4. Kubernetes 的运 行行时 5. Kubernetes 的 网络管理理 6. Kubernetes 的存储管理理 7.

Kubenetes 系列列公开课 2 每周四晚 8 点档 1. Kubernetes 初探 2. 上 手 Kubernetes 3. Kubernetes 的资源调度 4. Kubernetes 的运 行行时 5. Kubernetes 的 网络管理理 6. Kubernetes 的存储管理理 7. Kubernetes 包管理理 工具 Helm 蔺礼强 Kubenetes 系列列公开课 2 每周四晚 8 点档 1. Kubernetes 初探 2. 上 手 Kubernetes 3. Kubernetes 的资源调度 4. Kubernetes 的运 行行时 5. Kubernetes 的 网络管理理 6. Kubernetes 的存储管理理 7. Kubernetes

More information

C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40

C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40 C C trio@seu.edu.cn C C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C 40 30 10 Project 30 C Project 3 60 Project 40 Week3 C Week5 Week5 Memory & Pointer

More information

C PICC C++ C++ C C #include<pic.h> C static volatile unsigned char 0x01; static volatile unsigned char 0x02; static volatile unsigned cha

C PICC C++ C++ C C #include<pic.h> C static volatile unsigned char 0x01; static volatile unsigned char 0x02; static volatile unsigned cha CYPOK CYPOK 1 UltraEdit Project-->Install Language Tool: Language Suite----->hi-tech picc Tool Name ---->PICC Compiler Executable ---->c:hi-picinpicc.exe ( Command-line Project-->New Project-->File Name--->myc

More information

51 C 51 isp 10 C PCB C C C C KEIL

51 C 51 isp 10   C   PCB C C C C KEIL http://wwwispdowncom 51 C " + + " 51 AT89S51 In-System-Programming ISP 10 io 244 CPLD ATMEL PIC CPLD/FPGA ARM9 ISP http://wwwispdowncom/showoneproductasp?productid=15 51 C C C C C ispdown http://wwwispdowncom

More information

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc 2 5 8 11 0 13 1. 13 2. 15 3. 18 1 23 1. 23 2. 26 3. 28 2 36 1. 36 2. 39 3. 42 4. 44 5. 49 6. 51 3 57 1. 57 2. 60 3. 64 4. 66 5. 70 6. 75 7. 83 8. 85 9. 88 10. 98 11. 103 12. 108 13. 112 4 115 1. 115 2.

More information

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File 51 C 51 51 C C C C C C * 2003-3-30 pnzwzw@163.com C C C C KEIL uvision2 MCS51 PLM C VC++ 51 KEIL51 KEIL51 KEIL51 KEIL 2K DEMO C KEIL KEIL51 P 1 1 1 1-1 - 1 Project New Project 1 2 Windows 1 3 N C test

More information

概述

概述 OPC Version 1.6 build 0910 KOSRDK Knight OPC Server Rapid Development Toolkits Knight Workgroup, eehoo Technology 2002-9 OPC 1...4 2 API...5 2.1...5 2.2...5 2.2.1 KOS_Init...5 2.2.2 KOS_InitB...5 2.2.3

More information

06721 main() lock pick proc() restart() [2][4] MINIX minix2.0 GDT, IDT irq table[] CPU CPU CPU CPU (IDTR) idt[] CPU _hwint00:! Interrupt

06721 main() lock pick proc() restart() [2][4] MINIX minix2.0 GDT, IDT irq table[] CPU CPU CPU CPU (IDTR) idt[] CPU _hwint00:! Interrupt MINIX ( 730000) ( 730000) MINIX MINIX2.0 MINIX : MINIX TP3 1 MINIX UNIX Tanenbaum UNIX MINIX LINUX MINIX MINIX MINIX1.0 UNIX V7 MINIX2.0[3] POSIX MINIX3 MINIX Gabriel A. Wainer 1994-1995 [5] 1998 I/O 2002

More information

第11章 可调内核参数

第11章 可调内核参数 11 11 Unix BSD 4.4 Linux sysctl Unix Linux /proc window /proc /proc/sys /proc/sys sysctl Unix root /proc/sys/vm root /proc/sys sysctl /proc/sys struct ctl_table 18274 struct ctl_tables /proc/sys struct

More information

, 7, Windows,,,, : ,,,, ;,, ( CIP) /,,. : ;, ( 21 ) ISBN : -. TP CIP ( 2005) 1

, 7, Windows,,,, : ,,,, ;,, ( CIP) /,,. : ;, ( 21 ) ISBN : -. TP CIP ( 2005) 1 21 , 7, Windows,,,, : 010-62782989 13501256678 13801310933,,,, ;,, ( CIP) /,,. : ;, 2005. 11 ( 21 ) ISBN 7-81082 - 634-4... - : -. TP316-44 CIP ( 2005) 123583 : : : : 100084 : 010-62776969 : 100044 : 010-51686414

More information

How to Debug Tuxedo Server printf( Input data is: %s, inputstr); fprintf(stdout, Input data is %s, inputstr); fprintf(stderr, Input data is %s, inputstr); printf( Return data is: %s, outputstr); tpreturn(tpsuccess,

More information

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc References (Section 5.2) Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 15-16, 2010 H.-T. Lin (NTU CSIE) References OOP 03/15-16/2010 0 / 22 Fun Time (1) What happens in memory? 1 i n t i ; 2

More information

WebSphere Studio Application Developer IBM Portal Toolkit... 2/21 1. WebSphere Portal Portal WebSphere Application Server stopserver.bat -configfile..

WebSphere Studio Application Developer IBM Portal Toolkit... 2/21 1. WebSphere Portal Portal WebSphere Application Server stopserver.bat -configfile.. WebSphere Studio Application Developer IBM Portal Toolkit... 1/21 WebSphere Studio Application Developer IBM Portal Toolkit Portlet Doug Phillips (dougep@us.ibm.com),, IBM Developer Technical Support Center

More information

epub83-1

epub83-1 C++Builder 1 C + + B u i l d e r C + + B u i l d e r C + + B u i l d e r C + + B u i l d e r 1.1 1.1.1 1-1 1. 1-1 1 2. 1-1 2 A c c e s s P a r a d o x Visual FoxPro 3. / C / S 2 C + + B u i l d e r / C

More information

一个开放源码的嵌入式仿真环境 ― SkyEye

一个开放源码的嵌入式仿真环境 ― SkyEye SkyEye SkyEye http://hpclab.cs.tsinghua.edu.cn/~skyeye/ I hear and I forget, I see and I remember, I do and I understand. SkyEye SkyEye SkyEye SkyEye SkyEye 1. SkyEye PC pervasive computing PC I O PDA

More information

内 容 1 2 3 4 培 训 目 标 基 础 知 识 常 用 监 控 命 令 在 实 战 中 综 合 运 用 2

内 容 1 2 3 4 培 训 目 标 基 础 知 识 常 用 监 控 命 令 在 实 战 中 综 合 运 用 2 Linux 常 用 监 控 命 令 介 绍 基 础 应 用 组 梁 若 羽 2011-07-12 1 内 容 1 2 3 4 培 训 目 标 基 础 知 识 常 用 监 控 命 令 在 实 战 中 综 合 运 用 2 培 训 目 标 掌 握 常 用 监 控 命 令 的 用 途 和 启 用 方 法 熟 悉 各 个 关 键 输 出 参 数 的 真 实 含 义 了 解 Linux 操 作 系 统 的 一

More information

目 录

目 录 1 Quick51...1 1.1 SmartSOPC Quick51...1 1.2 Quick51...1 1.3 Quick51...2 2 Keil C51 Quick51...4 2.1 Keil C51...4 2.2 Keil C51...4 2.3 1 Keil C51...4 2.4 Flash Magic...9 2.5 ISP...9 2.6...10 2.7 Keil C51...12

More information

Windows XP

Windows XP Windows XP What is Windows XP Windows is an Operating System An Operating System is the program that controls the hardware of your computer, and gives you an interface that allows you and other programs

More information

投影片 1

投影片 1 9 1 9-1 Windows XP Windows Server 2003 Mac OS Linux, 都 (OS, Operating System ) 2 3 , 來, 行 3 理 行 4 ,, (UI, User Interface), 滑, 令 列 (CLI, Command-Line Interface) (GUI, Graphical User Interface) 2 5 令 列,

More information

IP505SM_manual_cn.doc

IP505SM_manual_cn.doc IP505SM 1 Introduction 1...4...4...4...5 LAN...5...5...6...6...7 LED...7...7 2...9...9...9 3...11...11...12...12...12...14...18 LAN...19 DHCP...20...21 4 PC...22...22 Windows...22 TCP/IP -...22 TCP/IP

More information

ebook15-C

ebook15-C C 1 1.1 l s ( 1 ) - i i 4. 14 - d $ l s -ldi /etc/. /etc/.. - i i 3077 drwxr-sr-x 7 bin 2048 Aug 5 20:12 /etc/./ 2 drwxr-xr-x 13 root 512 Aug 5 20:11 /etc/../ $ls -ldi /. /..... i 2 2 drwxr-xr-x 13 root

More information

F4

F4 DOI:10.3969/j.issn.1009-6868.2016.01.002 网 络 出 版 地 址 :http://www.cnki.net/kcms/detail/34.1228.tn.20151117.1506.006.html Challenges and Countermeasures of Network Space Security 周 延 森 /ZHOU Yansen 周 琳 娜

More information

ebook 132-6

ebook 132-6 6 SQL Server Windows NT Windows 2000 6.1 Enterprise Manager SQL Server Enterprise Manager( ) (Microsoft Management C o n s o l e M M C ) Enterprise Manager SQL Server Enterprise Manager 6.1.1 Enterprise

More information

Microsoft Word - 正文.doc

Microsoft Word - 正文.doc 1 2 1 2 3 4 5 6 7 8 9 10 3 1 150 2 150 1 1 1.1 1.1.1 1.2 1.2.1 1.2.2 1.2.3 1.3 1.3.1 1.3.2 1.4 1.4.1 CPU 1.4.2 I/O 1.4.3 I/O 1.5 1.5.1 CISC RISC 1.5.2 1.5.3 1.6 1.6.1 1.6.2 N 1.6.3 2 2.1 2.1.1 2.1.2 2.1.3

More information

第7章-并行计算.ppt

第7章-并行计算.ppt EFEP90 10CDMP3 CD t 0 t 0 To pull a bigger wagon, it is easier to add more oxen than to grow a gigantic ox 10t 0 t 0 n p Ts Tp if E(n, p) < 1 p, then T (n) < T (n, p) s p S(n,p) = p : f(x)=sin(cos(x))

More information

Go构建日请求千亿微服务最佳实践的副本

Go构建日请求千亿微服务最佳实践的副本 Go 构建 请求千亿级微服务实践 项超 100+ 700 万 3000 亿 Goroutine & Channel Goroutine Channel Goroutine func gen() chan int { out := make(chan int) go func(){ for i:=0; i

More information

2 2 3 DLight CPU I/O DLight Oracle Solaris (DTrace) C/C++ Solaris DLight DTrace DLight DLight DLight C C++ Fortran CPU I/O DLight AM

2 2 3 DLight CPU I/O DLight Oracle Solaris (DTrace) C/C++ Solaris DLight DTrace DLight DLight DLight C C++ Fortran CPU I/O DLight AM Oracle Solaris Studio 12.2 DLight 2010 9 2 2 3 DLight 3 3 6 13 CPU 16 18 21 I/O DLight Oracle Solaris (DTrace) C/C++ Solaris DLight DTrace DLight DLight DLight C C++ Fortran CPU I/O DLight AMP Apache MySQL

More information

正文.indd

正文.indd 第 3 章 进程管理 本章引入进程的概念 进程是 Unix 操作系统抽象概念中最基本的一种 其中涉及进程的定 义以及相关的概念 比如线程 然后讨论 Linux 内核如何管理每个进程 它们在内核中如何被列 举 如何创建 最终又如何消亡 我们拥有操作系统就是为了运行用户程序 因此 进程管理就 是所有操作系统的心脏所在 Linux 也不例外 3.1 进程 进程就是处于执行期的程序 目标码存放在某种存储介质上

More information

新・明解C言語入門編『索引』

新・明解C言語入門編『索引』 !... 75!=... 48 "... 234 " "... 9, 84, 240 #define... 118, 213 #include... 148 %... 23 %... 23, 24 %%... 23 %d... 4 %f... 29 %ld... 177 %lf... 31 %lu... 177 %o... 196 %p... 262 %s... 242, 244 %u... 177

More information

untitled

untitled Lwip Swedish Institute of Computer Science February 20, 2001 Adam Dunkels adam@sics.se (QQ: 10205001) (QQ: 329147) (QQ:3232253) (QQ:3232253) QQ ARM TCPIP LCD10988210 LWIP TCP/IP LWIP LWIP lwip API lwip

More information

C 1

C 1 C homepage: xpzhangme 2018 5 30 C 1 C min(x, y) double C // min c # include # include double min ( double x, double y); int main ( int argc, char * argv []) { double x, y; if( argc!=

More information

K7VT2_QIG_v3

K7VT2_QIG_v3 ............ 1 2 3 4 5 [R] : Enter Raid setup utility 6 Press[A]keytocreateRAID RAID Type: JBOD RAID 0 RAID 1: 2 7 RAID 0 Auto Create Manual Create: 2 RAID 0 Block Size: 16K 32K

More information

chap07.key

chap07.key #include void two(); void three(); int main() printf("i'm in main.\n"); two(); return 0; void two() printf("i'm in two.\n"); three(); void three() printf("i'm in three.\n"); void, int 标识符逗号分隔,

More information

六域链联盟 SDChain-Matrix 节点搭建指南 2018/07/26 Version : 1.0.0

六域链联盟 SDChain-Matrix 节点搭建指南 2018/07/26 Version : 1.0.0 SDChain-Matrix 节点搭建指南 目录 1 环境要求... 3 2 软件下载... 4 3 安装部署... 4 3.1 部署可执行程序目录... 4 3.2 部署配置文件目录... 4 3.3 部署数据库文件目录... 4 3.4 部署日志文件目录... 4 3.5 部署依赖库文件目录... 4 4 配置参数... 5 5 启动运行... 7 5.1 普通模式启动... 7 5.2 加载启动模式...

More information

mvc

mvc Build an application Tutor : Michael Pan Application Source codes - - Frameworks Xib files - - Resources - ( ) info.plist - UIKit Framework UIApplication Event status bar, icon... delegation [UIApplication

More information

BOOL EnumWindows(WNDENUMPROC lparam); lpenumfunc, LPARAM (Native Interface) PowerBuilder PowerBuilder PBNI 2

BOOL EnumWindows(WNDENUMPROC lparam); lpenumfunc, LPARAM (Native Interface) PowerBuilder PowerBuilder PBNI 2 PowerBuilder 9 PowerBuilder Native Interface(PBNI) PowerBuilder 9 PowerBuilder C++ Java PowerBuilder 9 PBNI PowerBuilder Java C++ PowerBuilder NVO / PowerBuilder C/C++ PowerBuilder 9.0 PowerBuilder Native

More information

INTRODUCTION TO COM.DOC

INTRODUCTION TO COM.DOC How About COM & ActiveX Control With Visual C++ 6.0 Author: Curtis CHOU mahler@ms16.hinet.net This document can be freely release and distribute without modify. ACTIVEX CONTROLS... 3 ACTIVEX... 3 MFC ACTIVEX

More information

Guide to Install SATA Hard Disks

Guide to Install SATA Hard Disks SATA RAID 1. SATA. 2 1.1 SATA. 2 1.2 SATA 2 2. RAID (RAID 0 / RAID 1 / JBOD).. 4 2.1 RAID. 4 2.2 RAID 5 2.3 RAID 0 6 2.4 RAID 1.. 10 2.5 JBOD.. 16 3. Windows 2000 / Windows XP 20 1. SATA 1.1 SATA Serial

More information

Progress Report of BESIII Slow Control Software Development

Progress Report of BESIII Slow Control Software Development BESIII 慢控制系统高压和 VME 监控 系统的设计和实现 陈锡辉 BESIII 慢控制组 2006-4-27 Outline Design and implementation of HV system Features Implementation Brief introduction to VME system Features Implementation of a demo Tasks

More information

2/80 2

2/80 2 2/80 2 3/80 3 DSP2400 is a high performance Digital Signal Processor (DSP) designed and developed by author s laboratory. It is designed for multimedia and wireless application. To develop application

More information

Chapter 9: Objects and Classes

Chapter 9: Objects and Classes Java application Java main applet Web applet Runnable Thread CPU Thread 1 Thread 2 Thread 3 CUP Thread 1 Thread 2 Thread 3 ,,. (new) Thread (runnable) start( ) CPU (running) run ( ) blocked CPU sleep(

More information

EK-STM32F

EK-STM32F STMEVKIT-STM32F10xx8 软 件 开 发 入 门 指 南 目 录 1 EWARM 安 装... 1 1.1 第 一 步 : 在 线 注 册... 1 1.2 第 二 步 : 下 载 软 件... 2 1.3 第 三 步 : 安 装 EWARM... 3 2 基 于 STMEVKIT-STM32F10xx8 的 示 例 代 码 运 行... 6 2.1 GPIO Demo... 6 2.2

More information

软件测试(TA07)第一学期考试

软件测试(TA07)第一学期考试 一 判 断 题 ( 每 题 1 分, 正 确 的, 错 误 的,20 道 ) 1. 软 件 测 试 按 照 测 试 过 程 分 类 为 黑 盒 白 盒 测 试 ( ) 2. 在 设 计 测 试 用 例 时, 应 包 括 合 理 的 输 入 条 件 和 不 合 理 的 输 入 条 件 ( ) 3. 集 成 测 试 计 划 在 需 求 分 析 阶 段 末 提 交 ( ) 4. 单 元 测 试 属 于 动

More information

Microsoft Word - PS2_linux_guide_cn.doc

Microsoft Word - PS2_linux_guide_cn.doc Linux For $ONY PlayStatioin2 Unofficall General Guide Language: Simplified Chinese First Write By Beter Hans v0.1 Mail: hansb@citiz.net Version: 0.1 本 人 是 菜 鸟 + 小 白 欢 迎 指 正 错 误 之 处, 如 果 您 有 其 他 使 用 心 得

More information

WWW PHP

WWW PHP WWW PHP 2003 1 2 function function_name (parameter 1, parameter 2, parameter n ) statement list function_name sin, Sin, SIN parameter 1, parameter 2, parameter n 0 1 1 PHP HTML 3 function strcat ($left,

More information

OOP with Java 通知 Project 2 提交时间 : 3 月 14 日晚 9 点 另一名助教 : 王桢 学习使用文本编辑器 学习使用 cmd: Power shell 阅读参考资料

OOP with Java 通知 Project 2 提交时间 : 3 月 14 日晚 9 点 另一名助教 : 王桢   学习使用文本编辑器 学习使用 cmd: Power shell 阅读参考资料 OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 2 提交时间 : 3 月 14 日晚 9 点 另一名助教 : 王桢 Email: 51141201063@ecnu.cn 学习使用文本编辑器 学习使用 cmd: Power shell 阅读参考资料 OOP with Java Java 类型 引用 不可变类型 对象存储位置 作用域 OOP

More information

untitled

untitled A, 3+A printf( ABCDEF ) 3+ printf( ABCDEF ) 2.1 C++ main main main) * ( ) ( ) [ ].* ->* ()[] [][] ** *& char (f)(int); ( ) (f) (f) f (int) f int char f char f(int) (f) char (*f)(int); (*f) (int) (

More information

Oracle Solaris Studio makefile C C++ Fortran IDE Solaris Linux C/C++/Fortran IDE "Project Properties" IDE makefile 1.

Oracle Solaris Studio makefile C C++ Fortran IDE Solaris Linux C/C++/Fortran IDE Project Properties IDE makefile 1. Oracle Solaris Studio 12.2 IDE 2010 9 2 8 9 10 11 13 20 26 28 30 32 33 Oracle Solaris Studio makefile C C++ Fortran IDE Solaris Linux C/C++/Fortran IDE "Project Properties" IDE makefile 1. "File" > "New

More information

untitled

untitled 1 5 IBM Intel 1. IBM 第 1/175 页 第 2/175 页 第 3/175 页 80 第 4/175 页 2. IBM 第 5/175 页 3. (1) 第 6/175 页 第 7/175 页 第 8/175 页 = = 第 9/175 页 = = = = = 第 10/175 页 = = = = = = = = 3. (2) 第 11/175 页 第 12/175 页 第 13/175

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 9 [P.11] : Dev C++ [P.12] : http://c.feis.tw [P.13] [P.14] [P.15] [P.17] [P.23] Dev C++ [P.24] [P.27] [P.34] C / C++ [P.35] 10 C / C++ C C++ C C++ C++ C ( ) C++

More information

自由軟體教學平台

自由軟體教學平台 NCHC Opensource task force DRBL steven@nchc.gov.tw, c00hkl00@nchc.gov.tw National Center for High-Performance Computing http://www.nchc.gov.tw Jan, 2003 1 2003/1/28 ( ) 09:00-10:30 10:40-12:00 Linux 13:00-14:30

More information

PowerPoint 演示文稿

PowerPoint 演示文稿 Linux 操 作 系 统 基 础 介 绍 课 程 目 标 及 要 求 了 解 Linux 操 作 系 统 的 登 入 方 式 掌 握 常 用 命 令 的 基 本 用 法 能 够 熟 练 在 各 个 目 录 转 换 Outline 1. Linux 操 作 系 统 简 介 2. Linux 操 作 系 统 的 登 录 3. Linux 操 作 系 统 的 目 录 结 构 4. 常 用 命 令 5.

More information

C语言的应用.PDF

C语言的应用.PDF AVR C 9 1 AVR C IAR C, *.HEX, C,,! C, > 9.1 AVR C MCU,, AVR?! IAR AVR / IAR 32 ALU 1KBytes - 8MBytes (SPM ) 16 MBytes C C *var1, *var2; *var1++ = *--var2; AVR C 9 2 LD R16,-X ST Z+,R16 Auto (local

More information

Microsoft PowerPoint - ch6 [相容模式]

Microsoft PowerPoint - ch6 [相容模式] UiBinder wzyang@asia.edu.tw UiBinder Java GWT UiBinder XML UI i18n (widget) 1 2 UiBinder HelloWidget.ui.xml: UI HelloWidgetBinder HelloWidget.java XML UI Owner class ( Composite ) UI XML UiBinder: Owner

More information

ch_code_infoaccess

ch_code_infoaccess 地 產 代 理 監 管 局 公 開 資 料 守 則 2014 年 5 月 目 錄 引 言 第 1 部 段 數 適 用 範 圍 1.1-1.2 監 管 局 部 門 1.1 紀 律 研 訊 1.2 提 供 資 料 1.3-1.6 按 慣 例 公 布 或 供 查 閱 的 資 料 1.3-1.4 應 要 求 提 供 的 資 料 1.5 法 定 義 務 及 限 制 1.6 程 序 1.7-1.19 公 開 資

More information

untitled

untitled BEA WebLogic Server WebLogic Server WebLogic Server Domain Administration Server Managed Server 行 說 Domains Domain Server 1 Server 2 Cluster Server 4 Server 3 Machine A Machine B Machine A 1. Domain Domain

More information

ebook14-4

ebook14-4 4 TINY LL(1) First F o l l o w t o p - d o w n 3 3. 3 backtracking parser predictive parser recursive-descent parsing L L ( 1 ) LL(1) parsing L L ( 1 ) L L ( 1 ) 1 L 2 L 1 L L ( k ) k L L ( 1 ) F i r s

More information

Bus Hound 5

Bus Hound 5 Bus Hound 5.0 ( 1.0) 21IC 2007 7 BusHound perisoft PC hound Bus Hound 6.0 5.0 5.0 Bus Hound, IDE SCSI USB 1394 DVD Windows9X,WindowsMe,NT4.0,2000,2003,XP XP IRP Html ZIP SCSI sense USB Bus Hound 1 Bus

More information

untitled

untitled MODBUS 1 MODBUS...1 1...4 1.1...4 1.2...4 1.3...4 1.4... 2...5 2.1...5 2.2...5 3...6 3.1 OPENSERIAL...6 3.2 CLOSESERIAL...8 3.3 RDMULTIBIT...8 3.4 RDMULTIWORD...9 3.5 WRTONEBIT...11 3.6 WRTONEWORD...12

More information

1.ai

1.ai HDMI camera ARTRAY CO,. LTD Introduction Thank you for purchasing the ARTCAM HDMI camera series. This manual shows the direction how to use the viewer software. Please refer other instructions or contact

More information

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO Car DVD New GUI IR Flow User Manual V0.1 Jan 25, 2008 19, Innovation First Road Science Park Hsin-Chu Taiwan 300 R.O.C. Tel: 886-3-578-6005 Fax: 886-3-578-4418 Web: www.sunplus.com Important Notice SUNPLUS

More information

ebook140-8

ebook140-8 8 Microsoft VPN Windows NT 4 V P N Windows 98 Client 7 Vintage Air V P N 7 Wi n d o w s NT V P N 7 VPN ( ) 7 Novell NetWare VPN 8.1 PPTP NT4 VPN Q 154091 M i c r o s o f t Windows NT RAS [ ] Windows NT4

More information

Symantec™ Sygate Enterprise Protection 防护代理安装使用指南

Symantec™ Sygate Enterprise Protection 防护代理安装使用指南 Symantec Sygate Enterprise Protection 防 护 代 理 安 装 使 用 指 南 5.1 版 版 权 信 息 Copyright 2005 Symantec Corporation. 2005 年 Symantec Corporation 版 权 所 有 All rights reserved. 保 留 所 有 权 利 Symantec Symantec 徽 标 Sygate

More information

ARM JTAG实时仿真器安装使用指南

ARM JTAG实时仿真器安装使用指南 ARM JTAG Version 1.31 2003. 11. 12 ARM JTAG ARM JTAG.3 ARM 2.1.4 2.2.4 ARM JTAG 3.1 18 3.2 18 3.2.1 Multi-ICE Server.18 3.2.2 ADS..21 ARM JTAG 4.1 Multi-ICE Server 33 4.1.1 Multi-ICE Server..... 33 4.1.2

More information

3.1 num = 3 ch = 'C' 2

3.1 num = 3 ch = 'C' 2 Java 1 3.1 num = 3 ch = 'C' 2 final 3.1 final : final final double PI=3.1415926; 3 3.2 4 int 3.2 (long int) (int) (short int) (byte) short sum; // sum 5 3.2 Java int long num=32967359818l; C:\java\app3_2.java:6:

More information

FY.DOC

FY.DOC 高 职 高 专 21 世 纪 规 划 教 材 C++ 程 序 设 计 邓 振 杰 主 编 贾 振 华 孟 庆 敏 副 主 编 人 民 邮 电 出 版 社 内 容 提 要 本 书 系 统 地 介 绍 C++ 语 言 的 基 本 概 念 基 本 语 法 和 编 程 方 法, 深 入 浅 出 地 讲 述 C++ 语 言 面 向 对 象 的 重 要 特 征 : 类 和 对 象 抽 象 封 装 继 承 等 主

More information

前 言 首 先, 感 謝 你 購 買 了 Linux LPIC Level I + Novell CLA 11 這 本 書, 這 本 書 是 全 球 第 一 本 以 Novell SUSE Linux Enterprise Server 來 分 析 兩 大 Linux 認 證 的 自 學 手 冊 目 前 訪 間 充 斥 著 許 多 Linux 作 業 系 統 的 教 學 手 冊 考 照 的 書 籍,

More information

徐汇教育214/3月刊 重 点 关 注 高中生异性交往的小团体辅导 及效果研究 颜静红 摘 要 采用人际关系综合诊断量表 郑日昌编制并 与同性交往所不能带来的好处 带来稳定感和安全感 能 修订 对我校高一学生进行问卷测量 实验组前后测 在 够度过更快乐的时光 获得与别人友好相处的经验 宽容 量表总分和第 4 项因子分 异性交往困扰 上均有显著差 大度和理解力得到发展 得到掌握社会技术的机会 得到 异

More information

Microsoft PowerPoint - ds-1.ppt [兼容模式]

Microsoft PowerPoint - ds-1.ppt [兼容模式] http://jwc..edu.cn/jxgl/ HomePage/Default.asp 2 说 明 总 学 时 : 72( 学 时 )= 56( 课 时 )+ 16( 实 验 ) 行 课 时 间 : 第 1 ~14 周 周 学 时 : 平 均 每 周 4 学 时 上 机 安 排 待 定 考 试 时 间 : 课 程 束 第 8 11 12 章 的 内 容 为 自 学 内 容 ; 目 录 中 标 有

More information

概述

概述 OPC Version 1.8 build 0925 KOCRDK Knight OPC Client Rapid Development Toolkits Knight Workgroup, eehoo Technology 2002-9 OPC 1...4 2 API...5 2.1...5 2.2...5 2.2.1 KOC_Init...5 2.2.2 KOC_Uninit...5 2.3...5

More information

1 o o o CPU o o o o o SQL Server 2005 o CPU o o o o o SQL Server o Microsoft SQL Server 2005

1 o o o CPU o o o o o SQL Server 2005 o CPU o o o o o SQL Server o Microsoft SQL Server 2005 1 o o o CPU o o o o o SQL Server 2005 o CPU o o o o o SQL Server o Microsoft SQL Server 2005 1 1...3 2...20 3...28 4...41 5 Windows SQL Server...47 Microsoft SQL Server 2005 DBSRV1 Microsoft SQL Server

More information

Microsoft Word - 100118002.htm

Microsoft Word - 100118002.htm 100 年 度 11800 電 腦 軟 體 應 用 乙 級 技 術 士 技 能 檢 定 學 科 測 試 試 題 本 試 卷 有 選 擇 題 80 題, 每 題 1.25 分, 皆 為 單 選 選 擇 題, 測 試 時 間 為 100 分 鐘, 請 在 答 案 卡 上 作 答, 答 錯 不 倒 扣 ; 未 作 答 者, 不 予 計 分 准 考 證 號 碼 : 姓 名 : 選 擇 題 : 1. (3)

More information

c_cpp

c_cpp C C++ C C++ C++ (object oriented) C C++.cpp C C++ C C++ : for (int i=0;i

More information

1 目 錄 1. 簡 介... 2 2. 一 般 甄 試 程 序... 2 3. 第 一 階 段 的 準 備... 5 4. 第 二 階 段 的 準 備... 9 5. 每 間 學 校 的 面 試 方 式... 11 6. 各 程 序 我 的 做 法 心 得 及 筆 記... 13 7. 結 論..

1 目 錄 1. 簡 介... 2 2. 一 般 甄 試 程 序... 2 3. 第 一 階 段 的 準 備... 5 4. 第 二 階 段 的 準 備... 9 5. 每 間 學 校 的 面 試 方 式... 11 6. 各 程 序 我 的 做 法 心 得 及 筆 記... 13 7. 結 論.. 如 何 準 備 研 究 所 甄 試 劉 富 翃 1 目 錄 1. 簡 介... 2 2. 一 般 甄 試 程 序... 2 3. 第 一 階 段 的 準 備... 5 4. 第 二 階 段 的 準 備... 9 5. 每 間 學 校 的 面 試 方 式... 11 6. 各 程 序 我 的 做 法 心 得 及 筆 記... 13 7. 結 論... 20 8. 附 錄 8.1 推 甄 書 面 資 料...

More information

<4D6963726F736F667420576F7264202D2032303130C4EAC0EDB9A4C0E04142BCB6D4C4B6C1C5D0B6CFC0FDCCE2BEABD1A15F325F2E646F63>

<4D6963726F736F667420576F7264202D2032303130C4EAC0EDB9A4C0E04142BCB6D4C4B6C1C5D0B6CFC0FDCCE2BEABD1A15F325F2E646F63> 2010 年 理 工 类 AB 级 阅 读 判 断 例 题 精 选 (2) Computer mouse How does the mouse work? We have to start at the bottom, so think upside down for now. It all starts with mouse ball. As the mouse ball in the bottom

More information

C/C++语言 - C/C++数据

C/C++语言 - C/C++数据 C/C++ C/C++ Table of contents 1. 2. 3. 4. char 5. 1 C = 5 (F 32). 9 F C 2 1 // fal2cel. c: Convert Fah temperature to Cel temperature 2 # include < stdio.h> 3 int main ( void ) 4 { 5 float fah, cel ;

More information

Measurement Studio Expands Your Test and Measurement Programming Power

Measurement Studio Expands Your Test and Measurement Programming Power NI-DAQmx NI-DAQ NI-DAQmx NI-DAQ NI-DAQmx NI-DAQmx NI-DAQ NI-DAQmx NI-DAQmx LabVIEW LabWindows/CVI ANSI C Measurement Studio Visual Studio I/O 1. I/O API I/O NI NI NI NI ADE 1.NI-DAQmx NI & MAX DAQ Assistant

More information

LSI U320 SCSI卡用户手册.doc

LSI U320 SCSI卡用户手册.doc V1.0 Ultra320 SCSI SCSI 2004 7 PentiumIntel MS-DOS Windows Novell Netware Novell Sco Unix Santa Cruz Operation LSI U320 SCSI SCSI SCSI Integrated Mirroring/Integrated Striping BIOS Firmware LSI U320 SCSI

More information

Learning Java

Learning Java Java Introduction to Java Programming (Third Edition) Prentice-Hall,Inc. Y.Daniel Liang 2001 Java 2002.2 Java2 2001.10 Java2 Philip Heller & Simon Roberts 1999.4 Java2 2001.3 Java2 21 2002.4 Java UML 2002.10

More information

C/C++ 语言 - 循环

C/C++ 语言 - 循环 C/C++ Table of contents 7. 1. 2. while 3. 4. 5. for 6. 8. (do while) 9. 10. (nested loop) 11. 12. 13. 1 // summing.c: # include int main ( void ) { long num ; long sum = 0L; int status ; printf

More information