What's process--什么是进程?

The UNIX standards, specifically IEEE Std 1003.1, 2004 Edition, defines a process as “an address space with one or more threads (线程) executing within that address space, and the required system resources for those threads.”

Linux允许多个用户同时登陆系统,同时运行相同的程序:

As a multiuser system, Linux allows many users to access the system at the same time. Each user can run many programs, or even many instances of the same program, at the same time. The system itself runs other programs to manage system resources and control user access.

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

Process Structures:

If two users, neil and rick, both run the grep program at the same time to look for different strings in different files :


如果在搜索结束前,运行ps -ef 命令来查看进程,输出的结果中可能会包含下两项:

操作系统为每一个进程分配一个process identifier(PID). PID的值通常会在2--32768之间,1通常分配给init 进程,该进程的作用是维护其他进程。

进程的共享东东:

grep这个软件对应的可执行code,被加载到内存中的只读区域,然后被两个进程共享!

另外,系统的libraries也可以被共享!例如printf函数,它的可执行代码应该只需要被加载到内存中的一个地方,然后其他用到该函数的所有进程共享这块read-only内存!--这种机制跟windows系统中的dll类似,但是更加复杂!

另一个好处是,可执行程序中如果有printf等库函数,这些库函数不被保存在可执行程序中,可以是可执行程序的占用的磁盘控件变小!---- 意思是最后的可执行文件对应的那些二进制代码中 不包括prinf库函数的二进制代码?


进程的独自的东东:

  • 每一个进程都有自己的stack space ,used for local variables in functions and for controlling function call and returns.
  • 每一个进程都有自己的environment space, containing environment variables that may be established solely for this process to use, as you saw with putenv and getenv in Chapter 4.-----???
  • 每一个进程都有自己的 program counter, a record of where it has gotten to in its execution, which is the execution thread. In the next chapter you will see that when you use threads, processes canhave more than one thread of execution.

/proc 文件的作用:On many Linux systems, and some UNIX systems, there is a special set of “files” in a directory called /proc. These are special in that rather than being true files they allow you to “look inside” processes while they are running as if they were files in directories. We took a brief look at the /proc file system back in Chapter 3. -----------???????

虚拟内存的好处:Finally, because Linux, like UNIX, has a virtual memory system that pages(映射) code and data out to an area of the hard disk, many more processes can be managed than would fit into the physical memory.

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

现在,一个系统可以同时运行的线程数量取决于内存空间的大小。

--------------------------------------------------------------------

View Processes:

PS命令是基本的进程查看命令:https://www.cnblogs.com/wxgblogs/p/6591980.html

PS命令的一些参数: 

-A :所有的进程均显示出来,与 -e 具有同样的效用;

-f :做一个更为完整的输出。--??

By default, the ps program shows only processes that maintain a connection with a terminal, a console,
a serial line, or a pseudo terminal. Other processes run without needing to communicate with a user on a terminal. These are typically system processes that Linux uses to manage shared resources. You can use ps to see all such processes using the -e option and to get “full” information with -f

PS命令的输出:

TTY 列:shows which terminal the process was started from. tty1-tty6 是本机上面的登入者程序,若为 pts/0 等等的,则表示为由网络连接到主机的程序

TIME :gives the CPU time used so far--??

CMD: shows the command used to start the process.

用PS命令查看进程的状态:

STAT:进程目前的状态,主要的状态有:

R :Running,on the run queue either executing or about to run.
S :Usually waiting for an event to occur, such as a signal or input to become available.
T :Usually stopped by shell job control (?) or the process is under the control of a debugger.
Z :该程序应该已经终止,但是其父程序却无法正常的终止他,造成 zombie (疆尸) 程序的状态.--??
D:   Uninterruptible Sleep (Waiting). Usually waiting for input or output to complete.
N:  Low priority task, “nice"
s (小写) : Process is a session leader.---------??
+:  Process is in the foreground process group.---------??
l :  Process is multi-threaded.

<:  High priority task

父子进程:

In general, each process is started by another process known as its parent process. A process so started
is known as a child process. When Linux starts, it runs a single program, the prime ancestor and process number 1, init. This is, if you like, the operating system process manager and the grandparent of all processes. Other system processes you’ll meet soon are started by init or by other processes started by init.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Process Scheduling (进程调度):


Beginning Linux Programming 学习--chapter 11 Processes and Signals的更多相关文章

  1. Beginning Linux Programming 学习--chapter 17 Programming KDE using QT

    KDE: KDE,K桌面环境(K Desktop Environment)的缩写.一种著名的运行于 Linux.Unix 以及FreeBSD 等操作系统上的自由图形桌面环境,整个系统采用的都是 Tro ...

  2. Beginning Linux Programming 学习--chapter 1 Getting start--What's linux,GNU,HeaderFiles, Libraries

    "文明的建立的不是机器而是思想" -- 托尔斯泰 Linux truly become a viable operating system, especially in the s ...

  3. Beginning Linux Programming 学习-chapter2-Shell programming-Pipes and Redirection

    "为了从事创造性工作,人类需要孤独,可是在孤独中,广义的人类仍存在于内心."--(德国)奥铿                                             ...

  4. Linux基础学习(11)--Shell编程

    第十一章——Shell编程 一.基础正则表达式 1.正则表达式与通配符(*,?,[ ]): 2.基础正则表达式: 二.字符截取命令 1.cut字段提取命令: 空格分割时,不知道空格有多少个,无法分割行 ...

  5. linux命令学习笔记(11):nl命令

    nl命令在linux系统中用来计算文件中行号.nl 可以将输出的文件内容自动的加上行号!其默认的结果与 等等的功能. .命令格式: nl [选项]... [文件]... .命令参数: -b :指定行号 ...

  6. Linux命令学习笔记目录

    Linux命令学习笔记目录 最近正在使用,linux,顺便将用到的命令整理了一下. 一. 文件目录操作命令: 0.linux命令学习笔记(0):man 命令 1.linux命令学习笔记(1):ls命令 ...

  7. Linux 内核学习的经典书籍及途径

    from:http://www.zhihu.com/question/19606660 知乎 Linux 内核学习的经典书籍及途径?修改 修改 写补充说明 举报   添加评论 分享 • 邀请回答   ...

  8. 关于Linux内核学习的误区以及相关书籍介绍

    http://www.hzlitai.com.cn/article/ARM9-article/system/1605.html 写给Linux内核新手-关于Linux内核学习的误区 先说句正经的:其实 ...

  9. Linux 内核学习经验总结

    Linux 内核学习经验总结 学习内核,每个人都有自己的学习方法,仁者见仁智者见智.以下是我在学习过程中总结出来的东西,对自身来说,我认为比较有效率,拿出来跟大家交流一下. 内核学习,一偏之见:疏漏难 ...

随机推荐

  1. [java][JEECG] Maven settings.xml JEECG项目初始化 RouYi settings.xml配置

    好吧一下是经验之谈,原本这些坑不应该躺的,从头看手册完全可以避免这些. 懒得整理了,看懂了就看,看不懂自己琢磨JEECG的帮助文档去,不过嘛我喜欢用Intelij IDEA,他里面都是别的IDE,不喜 ...

  2. (3)Go运算符

    运算符 Go 语言内置的运算符有: 算术运算符 关系运算符 逻辑运算符 位运算符 赋值运算符 算数运算符 运算符 描述 + 相加 - 相减 * 相乘 / 相除 % 求余 注意: ++(自增)和--(自 ...

  3. Selenium向iframe富文本框输入内容

    目录 前言 只输入纯文本 通过JS注入HTML代码 前言 在使用Selenium测试一些CMS后台系统时,有时会遇到一些富文本框,如下图所示: 整个富文本编辑器是通过iframe嵌入到网页中的,手动尝 ...

  4. Pytest权威教程24-Pytest导入机制及系统路径

    目录 Pytest导入机制和sys.path/PYTHONPATH 包中的测试脚本及conftest.py文件 独立测试模块及conftest.py文件 调用通过python -m pytest调用p ...

  5. 读取中文文件到CString

      CString strFileName = _T("D:\\ai\\100.json"); CFile file; file.Open(strFileName, CFile:: ...

  6. Cayley-Hamilton定理与矩阵快速幂优化、常系数线性递推优化

    原文链接www.cnblogs.com/zhouzhendong/p/Cayley-Hamilton.html Cayley-Hamilton定理与矩阵快速幂优化.常系数线性递推优化 引入 在开始本文 ...

  7. ubuntu之路——day10.4 什么是人的表现

    结合吴恩达老师前面的讲解,可以得出一个结论: 在机器学习的早期阶段,传统的机器学习算法在没有赶超人类能力的时候,很难比较这些经典算法的好坏.也许在不同的数据场景下,不同的ML算法有着不同的表现. 但是 ...

  8. Assignment5: 使用Visual Studio 进行可编码的UI测试

    一.实验目的: 使用Visual Studio 可编码的UI测试功能创作自动化测试 二.实验原理:黑盒测试 三.实验需求:win8 app.Visual Studio Ultimate 2012/20 ...

  9. [电脑]拆解DELL 2007FPb液晶显示器

    最近修了不少三星214T显示器,拆卸很方便,多数更换电容就OK了.但有一台出现了花屏,怀疑是数码板出问题了.单位有台显示屏破碎的DELL2007FPb,拆了看看能否借用数码板. 图片:IMG_2063 ...

  10. 笔记 - DBSherlock: A Performance Diagnostic Tool for Transactional Databases

    OLTP系统的问题很难排查和定位,这就是为什么要花那么多钱去请DBA 因为TP系统的请求很多都是毫秒级别,而且同时有大量的并发,所以由于资源,或随机的原因导致的问题,很难去定位根因 哪怕数据库系统尤其 ...