线程的相关定义 :: 风之谷
未识别博客 · jnn · 2004-05-21
线程的相关定义
时间:2004-05-21
与线程相关的定义
a)
什么是线程
–
无论是否是单线程程序
,
每一个程序都会有一个初始的线程
b)
线程中共享的对象
Static storage duration (static, extern) objects.
静态存储的对象(
static
,
extern
)关键词表示的
Dynamic storage duration (heap) objects . Thus each memory allocation will return a unique addresses, regardless of the thread making the allocation request.
动态存储的堆对象。虽然每次的分配内存都返回一个独立的地址,但是这些地址对同一进程中的线程时可见的。
Automatic storage duration (stack) objects accessed via pointer or reference from another thread.
自动存储对象(栈对象)也可以通过指针由其他的线程来进行访问。
Resources provided by the operating system. For example, files.
通过操作系统锁分配的资源,如
文
件
The program itself. In other words, each thread is executing some function of the same program, not a totally different program.
进程本身。换句话来说,每个线程执行这同一进程的某些函数,这些线程属于同一个进程。
c)
线程中的独享的对象
Registers and current execution sequence (program counter) .
寄存器以及当前执行计数器
Automatic storage duration (stack) objects .
自动存储对象(栈)对象
d)
线程安全
A program is thread-safe if it has no
race conditions
, does not
deadlock
, and has no
priority failures
.
对于一个线程安全的进程来说,塔应该时没有竞争,不会死锁,同时没有优先级错误的问题。
jnn
引用Trackback(0)
|
编辑
评论
进程vs.线程
• A process is the OS entity that provides the context for executing program instructions.
进程是一种OS实体,为执行程序指令提供环境。
进程保护:
• Each process manages certain resources, such as virtual memory, I/O handles, and signal handlers, and is protected from other OS processes via memory management unit(MMU) hardware.
1. 进程自身管理资源:虚拟内存、I/O句柄、信号处理器等
2. 内存管理单元(MMU)硬件,防止进程被其他OS进程破坏
• It’s hard to use single-threaded processes, however, to develop certain types of applications, particularly high-performance or real-time servers. It’s also hard to exert efficient, fine-grain control over scheduling and process priority using multiprocessing.
使用多进程,难以开发某些类型的应用程序,特别是高性能服务器或实时服务器,同时难以实施高效高精度的“调度”和“优先级”控制。
• A thread is a single sequence of instruction steps executed in the context of a process's protection domain.
线程是一组单独的指令序列,在进程环境中执行。
• a thread manages certain resources, such as a runtime stack of function activation records, a set of registers, signal masks, priorities, and thread-specific data.
线程管理资源:指令指针、栈、寄存器、信号屏蔽设备、优先级以及和线程有关的数据。
和进程相比,使用多线程有如下优点:
1. 线程维护的状态信息少,所以线程创建与环境切换开销小
2. 多处理器上,显著提高应用程序性能
缺点:
1. 高精度的锁定策略引起的高同步开销,带来性能损失
2. 线程之间接收到的“MMU保护”很少或没有,应用程序的健壮性降低
3. 缺乏高精度的访问控制
摘自C++NPV1及其中文版
jcylinder
(
http://www-900.ibm.com/developerWorks/cn/linux/kernel/l-thread/index.shtml
Linux 线程实现机制分析
jcylinder
(
发表评论
用户名:
Email:
主页:
最后更新
JAWS2 分析报告 IV
JAWS2 分析报告 III
JAWS2分析报告 II
JAWS2 分析报告 I
线程的相关定义
API 学习之我见
Service Config 动态加载
POA 学习笔记(二)
ACE同步策略实现(-)
开张一个月
原始快照:web.archive.org