操作系统线程行为 [英] OS Threads behavior

查看:56
本文介绍了操作系统线程行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想知道.NET中的线程行为。

当一个应用程序创建4个线程时,例如启动所有这些线程,操作系统

任务管理器将以确定性顺序执行所有4个线程,

OS执行(所有具有相同优先级)

线程#1

可能是其他线程,

线程#2

可能是其他线程,

线程#3

可能是其他线程,

线程#4

可能是其他线程,

线程#1

可能是其他线程线程,

线程#2

可能是其他线程,

线程#3

可能是其他线程,

线程#4

.......

我说对了吗?如果是的话,有没有办法要求运行所有这些线程

同时没有订单?或者我必须通过暂停/

简历来管理任务?

解决方案




我不认为你是对的,甚至更多我不认为你应该关心它,它是操作系统的一个谁决定执行哪个线程。比如

例如,当在双核处理器上执行时会发生什么,或者在HT上执行
处理器时,操作系统可以在

这个场景。


想要做什么?

欢呼,


-

Ignacio Machin,

ignacio.machin at dot.state.fl.us

佛罗里达州交通局


" [Yosi]" <哟** @ discussions.microsoft.com>在消息中写道

新闻:0D ********************************** @ microsof t.com ...


我想知道.NET中的线程行为。
当一个应用程序创建4个线程时,例如启动所有这些线程,操作系统<任务管理器将执行确定性顺序鬃毛中的所有4个线程,OS执行(所有具有相同的优先级)
线程#1
可能是其他线程,
线程#2
可能是其他线程,
线程#3可能是其他线程,
线程#4
可能是其他线程,
线程#1 线程#2可能是其他线程,
线程#3可能是其他线程,
线程#4
......
我是对的?如果有,有没有办法要求运行所有这些线程
同时没有订单?或者我必须通过
暂停/
简历来管理任务?



我关心它,因为我需要它,这个答案在微软中是如此之大......

响应,而我认为不应该这样:-(" ;.

我需要它因为我试图构建一个管理并发性的应用程序,所以这些测试将通过LPC访问连接到PC的外部硬件。

我关心,因为我想确定测试将以100%的同时性运行

,以便能够验证硬件模块是否按预期运行。每个测试

在不同的线程中运行,如果线程是按顺序运行这将不会

模拟所有验证情况可能导致HW失败,我们将无法获得
来捕获所有BUGS。

BYE我在公司努力工作的方式,试图将C#和

..Net集成到我们的测试工程中,我已经做了更多的工作这个语言中有4个很棒的b / b $ b重工具,这个语言不支持硬件访问

和(半导体边界)作为C / C ++,这就是我合并两者的原因

我的工具语言,所有高级和用户界面由C#(As

经理工具)和低级别(如HW访问/ IO / MEM?USB。 ...)C / C ++。

感谢您的回复。

Ignacio Machin(.NET / C#MVP)"写道:



我不认为你是对的,甚至更多我不认为你应该
关心它,操作系统是决定执行哪个线程的操作系统。比如
例如,当在双核处理器或具有HT的处理器上执行时会发生什么,操作系统可以在这个场景下同时执行两个线程。

想要做什么?

欢呼,

- Ignacio Machin,
ignacio.machin at dot.state.fl .us
佛罗里达州交通局

[Yosi]" <哟** @ discussions.microsoft.com>在消息中写道
新闻:0D ********************************** @ microsof t.com。 ..


我想知道.NET中的线程行为。
当一个应用程序创建4个线程时,例如启动所有这些线程,操作系统
任务管理器将以确定性顺序执行所有4个线程,
OS执行(所有具有相同优先级)
线程#1
可能是其他线程,
线程#2
可能是其他线程,
线程#3可能是其他线程,
线程#4可能是其他线程,
线程#1
可能是其他线程,
线程#2
可能是其他线程,
线程#3
可能是其他线程,
线程#4
.... ..
我说得对吗?如果有,有没有办法要求运行所有这些线程
同时没有订单?或者我必须通过
暂停/
简历来管理任务?






" [Yosi]" <哟** @ discussions.microsoft.com>在消息中写道

新闻:C0 ********************************** @ microsof t.com ...

我关心它,因为我需要它,这个答案在微软的声明如此响应,我认为它不应该是方式:-(" ;.


首先,我认为,我与MSFT毫无关系,


接下来会执行什么线程,或者IMO无法按什么顺序进行预测,它确实取决于调度程序:
http://msdn.microsoft.com/library/de。 ..ingThreads.asp


IT确实依赖于操作系统,例如你不能保证相同的结果

XP / 2K / 2K3甚至在XP home / pro。


我需要它,因为我试图构建一个管理并发性测试的应用程序,那些测试将访问外部h由LPC连接到PC的ardware。
我关心,因为我想确保测试将以100%同时运行
以便能够验证硬件模块是否按预期运行。每个
测试运行在不同的线程中,如果线程按顺序运行,这将不会模拟所有验证情况可能导致HW失败,我们不会
能够抓住所有的BUGS。




线程不会同时运行,无论你做什么,或者是什么

你使用的环境。每个

处理器或核心只有一个线程会在给定时刻运行。


欢呼,


-

Ignacio Machin,

ignacio.machin AT dot.state.fl.us

佛罗里达州交通部



I would like to know how threads behavior in .NET .
When an application create 4 threads for example start all of them, the OS
task manager will execute all 4 thread in deterministic order manes,
OS execute (All have same priority)
Thread#1
may be other threads,
Thread#2
may be other threads,
Thread#3
may be other threads,
Thread#4
may be other threads,
Thread#1
may be other threads,
Thread#2
may be other threads,
Thread#3
may be other threads,
Thread#4
.......
I''m right ? if yes , is there any way to ask for run all those threads
simultaneity with no order ? or I will have to managed the tasks by suspend /
resume for example ?

解决方案

Hi,

I don''t think you are right, and even more I don''t think that you should
care about it, it''s the OS the one who decide which thread to execute. Like
for example, what happens when executed on a dual core processor, or a
processor with HT, the OS can execute two threads at the same time under
this escenario.

What r u trying to do?
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"[Yosi]" <Yo**@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.com...


I would like to know how threads behavior in .NET .
When an application create 4 threads for example start all of them, the OS
task manager will execute all 4 thread in deterministic order manes,
OS execute (All have same priority)
Thread#1
may be other threads,
Thread#2
may be other threads,
Thread#3
may be other threads,
Thread#4
may be other threads,
Thread#1
may be other threads,
Thread#2
may be other threads,
Thread#3
may be other threads,
Thread#4
......
I''m right ? if yes , is there any way to ask for run all those threads
simultaneity with no order ? or I will have to managed the tasks by
suspend /
resume for example ?



I care about it, since I need it, "This answer is so famelies in Microsoft
responds , and I don''t think it should be the way :-( ".
I need it since I trying to built an application which manage concurrency
tests, those test will access an external hardware connected to PC by LPC.
I care since I would like to be sure the tests will run in 100% simultaneity
to be able to verify the HW modules are acting as will as expected. Each test
run in deferent thread and if the threads are running in order this will not
simulate all the validation cases may cause HW to fail and we will not able
to catch all BUGS.
BYE the way I was working so hard in my company trying to integrate C# and
..Net to our testing engineering , and I already made more than 4 great and
heavy tools in this language, the language does not support Hardware access
and (Semiconductors boundary )as C/C++, this is the reason I merge both
languages for my tools, All high level and user interface made by C# (As
manager tool) and the low level (like HW access /IO/MEM?USB....) by C/C++.
Thanks for your respond .
"Ignacio Machin ( .NET/ C# MVP )" wrote:

Hi,

I don''t think you are right, and even more I don''t think that you should
care about it, it''s the OS the one who decide which thread to execute. Like
for example, what happens when executed on a dual core processor, or a
processor with HT, the OS can execute two threads at the same time under
this escenario.

What r u trying to do?
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"[Yosi]" <Yo**@discussions.microsoft.com> wrote in message
news:0D**********************************@microsof t.com...


I would like to know how threads behavior in .NET .
When an application create 4 threads for example start all of them, the OS
task manager will execute all 4 thread in deterministic order manes,
OS execute (All have same priority)
Thread#1
may be other threads,
Thread#2
may be other threads,
Thread#3
may be other threads,
Thread#4
may be other threads,
Thread#1
may be other threads,
Thread#2
may be other threads,
Thread#3
may be other threads,
Thread#4
......
I''m right ? if yes , is there any way to ask for run all those threads
simultaneity with no order ? or I will have to managed the tasks by
suspend /
resume for example ?




Hi,
"[Yosi]" <Yo**@discussions.microsoft.com> wrote in message
news:C0**********************************@microsof t.com...

I care about it, since I need it, "This answer is so famelies in Microsoft
responds , and I don''t think it should be the way :-( ".
First of all, it''s my opinion, I had no relation at all with MSFT,

What thread will be executed next, or in what order is IMO impossible to
predict, it does depend of the scheduler :
http://msdn.microsoft.com/library/de...ingThreads.asp

IT does depend of the OS , for example you cannot assure the same results in
XP/2K/2K3 or even in XP home/pro.

I need it since I trying to built an application which manage concurrency
tests, those test will access an external hardware connected to PC by LPC.
I care since I would like to be sure the tests will run in 100%
simultaneity
to be able to verify the HW modules are acting as will as expected. Each
test
run in deferent thread and if the threads are running in order this will
not
simulate all the validation cases may cause HW to fail and we will not
able
to catch all BUGS.



The threads will NOT run at the same time, no matter what you do , or what
environment you use. only one thread will be running at a given moment per
processor or core.


cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


这篇关于操作系统线程行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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