Process, program, thread 的区别
来源:互联网 发布:淘宝主图视频内存大小 编辑:程序博客网 时间:2024/05/17 23:20
What is a Program? 存在二级储存器里的、断电不会丢失的、像个文件一样的可以被执行的东西。
A program is an executable file residing on the disk (secondary storage) in a directory. It is also termed as a set of instructions stored in the secondary storage device that are intended to carry out a specific job. It is read into the primary memory and executed by the kernel.
Therefore, a program is termed as a ‘passive entity’ which exists in the secondary storage persistently even if the machine reboots.
Few examples:
- On a Microsoft Windows® system: The ‘Calculator’ program is stored at “:\windows\system32\calc.exe”.
- On a Linux system: The ‘ls’ program is available at: “/bin/ls”.
What is a process? 当program被执行后,就变成了进程。一个program为母体可以创建出很多个进程,关机会死掉。
An executing instance of a program is called a process. Some operating systems use the term ‘task‘ to refer to a program that is being executed.
A process is termed as an ‘active entity’ since it is always stored in the main memory and disappears if the machine is power cycled. Several process may be associated with a same program.
On a multiprocessor system, multiple processes can be executed in parallel. On a uni-processor system, though true parallelism is not achieved, a process scheduling algorithm is applied and the processor is scheduled to execute each process one at a time producing an illusion of concurrency.
Example: Executing multiple instances of the ‘Calculator’ program. Each of the instances are termed as a process.
What is a thread? 一个进程可以有多个线程,它们共享一片内存。
A thread is called a ‘lightweight process’. It is similar to a real process but executes within the context of a process and shares the same resources allotted to the process by the kernel.
A process has only one thread of control – one set of machine instructions executing at a time. A process may also be made up of multiple threads of execution that execute instructions concurrently. Multiple threads of control can exploit the true parallelism possible on multiprocessor systems. On a uni-processor system, a thread scheduling algorithm is applied and the processor is scheduled to run each thread one at a time.
All the threads running within a process share the same address space, file descriptor, stack and other process related attributes. Since the threads of a process share the same memory, synchronizing the access to the shared data within the process gains unprecedented importance.
What is the relationship of a thread, a process and a program?
The below image portrays the relationship between a process and threads. A process can be composed of several threads executing in parallel.
The image below depicts the relationship between a program and processes. A program can be subdivided into multiple processes executing in parallel.
Consider an example: Microsoft Word is a massive program that when loaded into the primary memory in-turn loads several processes which in-turn create several threads.
- Process, program, thread 的区别
- thread和process的区别
- Process 和 thread 的区别
- 线程 thread 与 进程 process 的区别
- Program v/s Process v/s Thread
- linux中process, kernel thread, user thread的区别
- linux 程序(program)和进程(process)的区别
- 进程和程序的区别 The relationship between process and program
- process与thread的关系
- Program Name、Process ID、Window Handle、Process Handle 的轉換函式
- process thread
- 进程(Process)和线程(Thread)的关系和区别(Difference)
- 进程与线程的区别 What is the difference between process and thread
- 进程(Process)和线程(Thread)的关系和区别
- 进程(Process)和线程(Thread)的关系和区别
- 与process&thread相关的一些函数
- Android process与Thread 的问题
- Android process与Thread 的问题
- JAVA基础知识IO流(文本文件读取方式一)
- Android开发中adb启动失败adb连接异常的解决办法
- Spring JDBCの紹介
- 牛腩新闻发布系统——静态方法使用问题(Static)
- 338. Counting Bits
- Process, program, thread 的区别
- Vector 线程安全与不安全
- poj-3050-Hopscotch
- 【办公采购系统】系统中遇到的问题汇总(一)——模板页使用
- oj数据结构题谜之输出格式
- 华为老总推荐的文章
- googletest mock设置 编译器选项 vs下
- 搜索算法11之1016
- Shiro入门