是否有人知道线程在系统内部具体的实现!!!(高手请进)(100分)

H

Henaldo

Unregistered / Unconfirmed
GUEST, unregistred user!
我知道在Linux中线程是使用一个进程结构,然后复制了父进程的进程数据结构,其中包括
系统的内存页目录、文件指针等。然后改变stack的位置,并把IP指针指向线程所要运行的
函数开始处。在Window内部的实现呢?是否跟Linux一样?不一样的话,有哪些不同。
谢谢。
 
据我所知是一样的。除了内存地址是属于父进程(本质上是描述符相同),其他
方面与一个单独的任务没什么区别。
 
《Windows核心编程》里对这方面说得比较详细。
 
To 左轻侯:
吓我一跳,还以为是又进了同一个问题。
 
好像根本就没有说清楚。呵呵。
能否说的具体点?
内存地址应该是公共的。然后线程有不同的堆栈。
假如Window中线程的实现和Linux相同的话,为什么说Linux不能实现Window的
线程功能呢?
 
>>假如Window中线程的实现和Linux相同的话,为什么说Linux不能实现Window的
>>线程功能呢?
什么功能?
 
说实话,这是我的疑问之一。以前在书上看到Linux评价这样说。
 
这个问题好像是比较高深啊,我也像知道!!!
 
似乎是windows的线程支持抢先,并且调度方法更多一点。可能是因为windows的线程描述
更复杂一点。感觉上,线程切换时,windows比linux复杂。
 
1:CreateThread creates a user-mode stack for the thread in the process's
address space.
2:CreateThread initializes the thread's hardware context
(CPU architecture-specific). (For further information on the thread
context block, see the Win32 API referencedo
cumentation on the CONTEXT
structure.)
3:NtCreateThread is called to create the executive thread object in the
suspended state. The following steps execute in kernel mode inside the
Windows 2000 executive and kernel
4:CreateThread notifies the Win32 subsystem about the new thread, and the
subsystemdo
es some setup work for the new thread.
5:The thread handle and the thread ID (generated during step 3) are
returned to the caller.
6:Unless the caller created the thread with the CREATE_SUSPENDED flag set,
the thread is now resumed so that it can be scheduled for execution. When
the thread starts running, it executes the following additional steps (in
the context of the new thread) before calling the actual user's specified
start address.
 
这个问题好象还没有人能给我满意的答案.
 
>> 说实话,这是我的疑问之一。以前在书上看到Linux评价这样说。
and did u give us the answer?
 
我不是给了吗?
 
和LINUX一样,看WINDOWS核心编程就行。从进程线程和内存管理的原理上,WINDOWS和LINUX
区别并不大。我不知道为什么LINUX鼓吹得象是一场技术革命。
 
http://202.120.85.61/delphibbs/rules.asp
 
接受答案了.
 
顶部