任务与流程,真的有什么区别吗?

发布于 2024-08-27 08:43:17 字数 231 浏览 4 评论 0原文

我正在准备计算机科学专业的期末考试,主题是分布式系统和操作系统。

我需要对术语任务、进程和线程有一个好的定义。到目前为止,我确信进程是运行(或挂起,但已启动)程序的表示,具有自己的内存、程序计数器、寄存器、堆栈等(进程控制块)。进程可以运行共享内存的线程,因此与必须通过 IPC 通信的进程相比,可以通过共享内存进行通信。

但任务和流程有什么区别呢?我经常读到它们是可以互换的,并且不再使用术语“任务”。这是真的吗?

I'm studying for my final exams in my CS major on the subject distributed systems and operating systems.

I'm in the need for a good definition for the terms task, process and threads. So far I'm confident that a process is the representation of running (or suspended, but initiated) program with its own memory, program counter, registers, stack, etc (process control block). Processes can run threads which share memory, so that communication via shared memory is possible in contrast to processes which have to communicate via IPC.

But what's the difference between tasks and process. I often read that they're interchangable and that the term task isn't used anymore. Is that really true?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

我的黑色迷你裙 2024-09-03 08:43:18

我认为这取决于使用哪个术语的底层操作系统。

您还可以将任务视为一段正在运行的代码。那么线程的一部分或进程的一部分就可以是任务。

I think it's dependant of the underlying operating system which term is used.

You could also think of task as a running piece of code. Then a part of a thread or a part of a process could be a task.

一花一树开 2024-09-03 08:43:18

过程
流程是自然发生或设计的操作或事件序列,可能占用时间、空间、专业知识或其他资源,从而产生一些结果。 可以通过它在其影响下的一个或多个对象的属性中创建的更改来识别进程

进程
线程与进程类似,两者都表示通过时间切片或多处理与其他序列并行执行的单个指令序列。线程是程序将自身分成两个或多个同时运行的任务的一种

方式
一组程序指令被加载到内存中

Process
Process is a naturally occurring or designed sequence of operations or events, possibly taking up time, space, expertise or other resource, which produces some outcome. A process may be identified by the changes it creates in the properties of one or more objects under its influence

Thread
Threads are similar to processes, in that both represent a single sequence of instructions executed in parallel with other sequences, either by time slicing or multiprocessing. Threads are a way for a program to split itself into two or more simultaneously running tasks

Task
a set of program instructions is loaded in memory

总攻大人 2024-09-03 08:43:18

在操作系统方面使用时,任务进程通常是相似的:它们都是加载到内存中由处理器执行的一组指令。由于所有现代处理器都使用分时和上下文切换来执行进程,因此区别在于处理器的数量,即如果一个处理器正在执行多个进程,则它是一个多任务系统,如果有多个处理器正在执行,则它是一个多任务系统多个进程(或进程的不同部分),它是一个多处理操作系统

A task and a process are usually similar when used in terms of OS : they are both a set of instructions loaded into memory to be executed by the processor. As all modern processors uses Time sharing and context switching for process execution, the difference lies in the number of processors , i.e if one processor is executing multiple processes, it's a multitasking system and if there are multiple processors executing multiple processes(or different parts of a process), it's a multiprocessing os

放血 2024-09-03 08:43:17

术语“任务”主要用于调度*,当它可以引用线程或*进程***时,可以安排在处理器上运行。
从调度程序的角度来看,线程和进程之间可能几乎没有区别 - 两者都代表必须调度的任务

最近,术语“任务”得到了更广泛的使用,特别是在 .NET 开发人员中,这要归功于例如 任务并行库。在其中,任务是可以安排在来自 工作线程池

* 例如在内核编程中,尤其是。在 Linux 上
** 理论上,您可以组成可调度实体

The term "task" is mostly used in the context of scheduling*, when it can refer to either a thread or a *process***, that can be scheduled to run on a processor.
From the scheduler's point of view there might be little-to-no difference between a thread and a process - both represent a task that must be scheduled.

Recently, the term "task" is gaining more-widespread usage, especially among .NET developers, thanks to e.g. the Task Parallel Library. Within it, tasks are units of work that can be scheduled to run on threads from a pool of worker threads.

* e.g in kernel programming, esp. on Linux
** theoretically, you could make up your schedulable entities

冰魂雪魄 2024-09-03 08:43:17

进程和线程是机制,任务更具概念性。您可以将一大堆工作排队以异步运行,例如在使用 .NET 的 Windows 上,这在线程池中的线程上运行。使用 OpenMP,任务将成为在一个内核上运行的 for 循环的一部分。

相关小注释:在 Windows 上,还有用于机制的作业、线程池和纤程。此外,如果没有至少一个线程运行,进程就毫无意义。

Processes and threads are the mechanics, task is more conceptual. You can queue a chuck of work to run asynchronously, on windows with .NET for example, this gets run on a thread from the thread pool. With OpenMP, a task would be part of your for loop running on one core.

Minor related notes: on windows, there are also jobs, thread pools, and fibers for mechanics. Also, a process is nothing without at least one thread running.

乱了心跳 2024-09-03 08:43:17

我是老派。严格来说,“处理”是在内存中执行的不涉及输入/输出操作的工作。 “任务”是包含 I/O 操作的进程。因此,多任务系统可以运行并发I/O流,而多处理系统必须任务切换其I/O。个人电脑只有一个鼠标、键盘等,所以对我来说它们不是多任务系统。我认为大型机是一个多任务系统。

线程是一种切换处理上下文的技术。允许物理处理器驱动多个进程。与任务没有直接关系。

I'm old-school. Strictly speaking, "processing" is work performed in memory that does not involve input/output operations. A "task" is a process that includes I/O operations. Accordingly, a multi-tasking system can run concurrent I/O streams, whereas a multi-processing system must task switch its I/O. PC's have only one mouse, keyboard, etcetera, so they are not multi-tasking systems to me. I consider a mainframe to be a multi-tasking system.

Threading is a technique for switching processing context. Allows a physical processor to drive multiple processes. No direct relationship to tasks.

若水般的淡然安静女子 2024-09-03 08:43:17

这取决于你的背景。

在 Ada 中,任务是编程语言中用于实现并发性的构造。

没有指定应该使用什么操作系统构造来实现它,但它允许任务之间共享内存,因此线程将是更自然的实现。

It depends on your context.

In Ada, a task is a construct in the programming language to enable concurrency.

It isn't specified what operating system construct should be used to implement it, but it allows shared-memory between tasks, so a thread would be a more natural implementation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文