什么是进程和线程? [英] What is process and thread?

查看:139
本文介绍了什么是进程和线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我已经阅读了许多与操作系统相关的资料。我还在读书。但是,似乎所有的人都以抽象的方式描述过程和线程,这使得他们对行为和逻辑结构进行了很多高层次的阐述。 我想知道他们在物理上是什么?在我看来,它们只是一些内存中的数据结构,它们由内核代码维护和使用,以方便执行的程序。例如,操作系统使用一些过程数据结构(PCB)来描述分配给特定程序的过程的方面,例如其优先级,其地址空间等。这是正确的吗?

Yes, I have read many materials related to operating system. And I am still reading. But it seems all of them are describing the process and thread in a "abstract" way, which makes a lot of high level elabration on their behavior and logic orgnization. I am wondering what are they physically? In my opinion, they are just some in-memory "data structures" which are maintained and used by the kernel codes to facilitate the execution of program. For example, operating system use some process data structure (PCB) to describe the aspects of the process assigned for a certain program, such as its priority, its address space and so on. Is this all right?

推荐答案

通常当你运行一个可执行文件,如notepad.exe,这些进程可以产生其他进程,但在大多数情况下,您运行的每个可执行文件都有一个进程。在这个过程中,可以有很多线程。通常首先有一个线程,通常在程序入口点开始,它通常是 main 函数。指令按顺序逐一执行,像一个只有一只手的人,线程只能在它移动到下一个之前一次做一件事。

Normally when you run an executable like notepad.exe, this creates a single process. These process could spawn other processes, but in most cases there is a single process for each executable that you run. Within the process, there can be many threads. Usually at first there is one thread, which usually starts at the programs "entry point" which is the main function usually. Instructions are executed one by one in order, like a person who only has one hand, a thread can only do one thing at a time before it moves on to the next.

第一个线程可以创建额外的线程。每个附加线程都有自己的入口点,通常用一个函数定义。这个过程就像一个容器,用于在其中产生的所有线程。

That first thread can create additional threads. Each additional thread has it's own entry point, which is usually defined with a function. The process is like a container for all the threads that have been spawned within it.

这是一个很简单的解释。我可以进入更多的细节,但可能会与你在你的教科书中会发现的重叠。

That is a pretty simplistic explanation. I could go into more detail but probably would overlap with what you will find in your textbooks.

编辑:你会注意到有很多的通常我的解释,因为有偶尔罕见的程序,做事情完全不同。

You'll notice there are lot's of "usually"'s in my explanation, as there are occasionally rare programs that do things drastically different.

这篇关于什么是进程和线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆