Linux 进程创建
作者:李智敏,华清远见嵌入式学院上海分中心讲师。
在 Linux 内核内,进程是由相当大的一个称为 task_struct 的结构表示的。此结构包含所有表示此进程所必需的数据,此外,还包含了大量的其他数据用来统计(accounting)和维护与其他进程的关系(父和子)。下面给出了 task_struct 的一小部分。task_struct 位于 ./linux/include/linux/sched.h。
struct task_struct {
volatile long state;
void *stack;
unsigned int flags;
int prio, static_prio;
struct list_head tasks;
struct mm_struct *mm, *active_mm;
pid_t pid;
pid_t tgid;
struct task_struct *real_parent;
char comm[TASK_COMM_LEN];
struct thread_struct thread;
struct files_struct *files;
...
};
在task_struct中,可以看到几个预料之中的项,比如执行的状态、堆栈、一组标志、父进程、执行的线程(可以有很多)以及开放文件。对其做简单声明如下
<1> state 变量是一些表明任务状态的比特位。最常见的状态有:
1.TASK_RUNNING 表示进程正在运行,或是排在运行队列中正要运行
2.TASK_INTERRUPTIBLE 表示进程正在休眠
3.TASK_UNINTERRUPTIBLE 表示进程正在休眠但不能叫醒
4.TASK_STOPPED 表示进程停止
注:这
相关文档:
/***************************************************************************** 程序说明:示例程序演示了2440平台下linux串口应用开发,可实现2440串口2与串口3的通讯*** 硬件设置:将2440板子上的串口2、3TXD、RXD交叉短接*** 编译运行:在宿主机上编译程序源码,打开超级终端(可与2440进行命令交互),*** &nb ......
功能说明:.bz2文件的压缩程序。
语 法:bzip2 [-cdfhkLstvVz][--repetitive-best][--repetitive-fast][- 压缩等级][要压缩的文件]
补充说明:bzip2采用新的压缩演算法,压缩效果比传统的LZ77/LZ78压缩演算法来得好。若没有加上任何参数,bzip2压缩完文件后会产生.bz2的压缩文件,并删除原始的文件。
参 数:
- ......
Q. How can I add a user to a group under Linux operating system?
A. You can use useradd or usermod commands to add a user to a group. useradd command creates a new user or update default new user information. usermod command modifies a user account i.e. it is useful to add user to existin ......
安装与使用MySQL
一 、下载MySQL的安装文件
安装MySQL需要下面两个文件:
MySQL-server-4.0.16-0.i386.rpm
MySQL-client-4.0.16-0.i386.rpm
下载地址为:http://www.mysql.com/downloads/mysql-4.0.html, 打开此网页,下拉网页找到“Linux x86 RPM downloads”项,找到“Server&rdquo ......