Safaribooks online 打折 原价一年399刀 现价一年199刀。
读的第一本书 Linux kernel development
Linux has a unique implementation of threads: It does not differentiate between threads and processes. To Linux, a thread is just a special kind of process.
对 linux 来说 ，thread 和 process 并没有区别。
thread 只是特殊的 process
On modern operating systems, processes provide two virtualizations: a virtualized processor and virtual memory. The virtual processor gives the process the illusion that it alone monopolizes the system, despite possibly sharing the processor among hundreds of other processes.
Chapter 4, “Process Scheduling,” discusses this virtualization.
Virtual memory lets the process allocate and manage memory as if it alone owned all the memory in the system.
Virtual memory is covered in Chapter 12, “Memory Management.”
对 process 来说， process 好像独占cpu 和 memory。
The task_struct is a relatively large data structure, at around 1.7 kilobytes on a 32-bit machine. This size, however, is quite small considering that the structure contains all the information that the kernel has and needs about a process. The process descriptor contains the data that describes the executing program—open files, the process’s address space, pending signals, the process’s state, and much more.
The kernel stores the list of processes in a circular doubly linked list called the task list.
在kernel中 进程描述符存储在环形双向链表（task list）中。
进程描述符 process descriptor ，定义在
在 Understanding the Linux kernel 笔记(三) 第三章 进程 有贴出pd全部的定义
The system identifies processes by a unique process identification value or PID.
PID 有个默认的最大值 32768
this is controlled in
the administrator may increase the maximum value via
x86 架构不能将 当前运行的process 的 PD 存在寄存器中，因为它的寄存器太少了，但是 ppc 架构的可以 ，ppc 架构的寄存器多。
Contrast this approach with that taken by PowerPC (IBM’s modern RISC-based microprocessor), which stores the current task_struct in a register. Thus, current on PPC merely returns the value stored in the register r2. PPC can take this approach because, unlike x86, it has plenty of registers. Because accessing the process descriptor is a common and important job, the PPC kernel developers deem using a register worthy for the task.
x86 架构存储的是 thread_info <
The thread_info structure is defined on x86 in <include/asm-x86_64/thread_info.h>>
pd 结构体中的 状态变量
• TASK_UNINTERRUPTIBLE—This state is identical to TASK_INTERRUPTIBLE except that it does not wake up and become runnable if it receives a signal. This is used in situations where the process must wait without interruption or when the event is expected to occur quite quickly. Because the task does not respond to signals in this state, TASK_UNINTERRUPTIBLE is less often used than TASK_INTERRUPTIBLE.
This is why you have those dreaded unkillable processes with state D in ps(1). Because the task will not respond to signals, you cannot send it a SIGKILL signal. Further, even if you could terminate the task, it would not be wise because the task is supposedly in the middle of an important operation and may hold a semaphore.
在linux/sched.h 中set_task_state函数 定义为 set_mb