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 ? 10 1658
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
Yes I know since we have one CPU,
But my question was Is the threads schedule randomly or there is an
order,the one create first run first the the seconed ....
"how to schedule threads randomly on Windows OS"
"Ignacio Machin ( .NET/ C# MVP )" wrote: 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
Hi Yosi,
I advise you to read a little more about how an OS schedule jobs, ITOH you
contradice yourself, you want to run ALL the thread concurrently but also
randomly ?
I think it's safe to consider that the threads will be run randomly without
doing nothing else, if you want to include a little more randomness you
could play with ThreadPriority when you create your threads.
Othen than that, there is nothing much else you can do
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"[Yosi]" <Yo**@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com... Yes I know since we have one CPU, But my question was Is the threads schedule randomly or there is an order,the one create first run first the the seconed ....
"how to schedule threads randomly on Windows OS" "Ignacio Machin ( .NET/ C# MVP )" wrote:
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
Unless you have a quad CPU machine (or a dual HT box), there is no chance to
run 4 threads simultaneously( that is exactly at the same time). Even if you
have 4 CPU's there is NO guarantee YOUR 4 threads will ever run in parallel,
there are other threads in the system that are scheduled as well and these
might run at higher priorities than your threads. For instance, one of these
threads is your UI thread which runs with a higher priority than your
auxiliary threads, just move your mouse and it will get a CPU.
Willy.
"[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 :-( ". 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 ?
I know everything your write, maybe my question was not clear enough, so here
is my question again :
When I make more than one thread , Does OS run them in order one by one
means x commands from thread1 x commands from thread2... or the OS run them
simultaneity (with no order)?
From my old knowledge if I have xx thread/tasks with same priority OS run
them by order the task has been created firs run firs the second run after
and so ....
But I trying to be sure is this the same in XP/2K OS (.Net) , or not ?
If this is the same , is there anything to do with this order except to play
with the thread suspend/resume or abort/run deferent order each time?
"Willy Denoyette [MVP]" wrote: Unless you have a quad CPU machine (or a dual HT box), there is no chance to run 4 threads simultaneously( that is exactly at the same time). Even if you have 4 CPU's there is NO guarantee YOUR 4 threads will ever run in parallel, there are other threads in the system that are scheduled as well and these might run at higher priorities than your threads. For instance, one of these threads is your UI thread which runs with a higher priority than your auxiliary threads, just move your mouse and it will get a CPU.
Willy.
"[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 :-( ". 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 ?
The scheduler tries to schedule threads in all fairness, that is it will try
to give each thread in the system a fair chance to run even in the presence
of higher priority threads.
The result of this might be that when your threads (the 4 threads) are
executing the exact same code at the same priority that they might always be
scheduled in the same order.
Say you have started the threads in order 1, 2, 3 and 4 with the same
priority.
The will be scheduled as 1...2...3...4...1...2...3...4 (this supposes none
of them get blocked waiting for an external event).
Note ... is the time other threads in the system are being scheduled.
If you change the priority of one of the threads you might break this
relative order, because higher privileged threads are scheduled more often
than the lower priority ones, but the order in which they are scheduled will
again be the same.
Say you set above thread 2 priority to above normal.
You might see something like:
1...2...3...2...4...2...1...2...3...4...2...1...2. ..3...2...4...2
You see 2 gets more cpu time but the order of the others remains the same,
but again all depends on what the threads are doing.
Willy.
"[Yosi]" <Yo**@discussions.microsoft.com> wrote in message
news:4D**********************************@microsof t.com... Yes I know since we have one CPU, But my question was Is the threads schedule randomly or there is an order,the one create first run first the the seconed ....
"how to schedule threads randomly on Windows OS" "Ignacio Machin ( .NET/ C# MVP )" wrote:
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
If you need to run your threads in a kind of 'random' order, you need to
'schedule' your threads yourself, but don't do this using Thread.Suspend ...
Resume, these API's are broken and are removed from the next version of the
framework.
Instead you should use synchronization event primitives like
ManualResetEvent to coordinate logical tasks. Note that I'm not saying
threads, as you can't effectively schedule threads from user code, but at
least you can select a thread or a number of threads to be scheduled while
you keep others are waiting for an event to arive.
Willy.
"[Yosi]" <Yo**@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com... I know everything your write, maybe my question was not clear enough, so here is my question again : When I make more than one thread , Does OS run them in order one by one means x commands from thread1 x commands from thread2... or the OS run them simultaneity (with no order)? From my old knowledge if I have xx thread/tasks with same priority OS run them by order the task has been created firs run firs the second run after and so .... But I trying to be sure is this the same in XP/2K OS (.Net) , or not ? If this is the same , is there anything to do with this order except to play with the thread suspend/resume or abort/run deferent order each time?
"Willy Denoyette [MVP]" wrote:
Unless you have a quad CPU machine (or a dual HT box), there is no chance to run 4 threads simultaneously( that is exactly at the same time). Even if you have 4 CPU's there is NO guarantee YOUR 4 threads will ever run in parallel, there are other threads in the system that are scheduled as well and these might run at higher priorities than your threads. For instance, one of these threads is your UI thread which runs with a higher priority than your auxiliary threads, just move your mouse and it will get a CPU.
Willy.
"[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 :-( ". > 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 ? >> >> >>
I guess what the other posters are saying is that you cannot depend on
the order. It is dependent on a lot of factors like what each thread is
doing, the number of processors, the operating system etc. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sebastian Meyer |
last post by:
Hi Newsgroup,
i have some problems with using threads and signals in one program.
In my program i have three threads running, one for checking a directory
at a specified interval to see if new...
|
by: Russell Warren |
last post by:
Does anyone know the scope of the socket.setdefaulttimeout call? Is it
a cross-process/system setting or does it stay local in the application
in which it is called?
I've been testing this and...
|
by: Mark Hoffman |
last post by:
All,
From what I've read, the CLR gives each App Domain a thread pool of 25
threads, and once this pool is exhausted then any new threads created with
BeginInvoke will block until the pool frees...
|
by: Cool Guy |
last post by:
Consider:
void Start()
{
if (!TryToDoSomething())
ShowErrorMessage();
}
|
by: David Rushby |
last post by:
Consider the following program (underscores are used to force
indentation):
------------------------------------------------
import atexit, threading, time
def atExitFunc():
____print...
| |
by: Michael |
last post by:
I'm writing an application that decodes a file containing binary
records. Each record is a particular event type. Each record is
translated into ASCII and then written to a file. Each file contains...
|
by: koschwitz |
last post by:
Hi,
I hope you guys can help me make this simple application work. I'm
trying to create a form displaying 3 circles, which independently
change colors 3 times after a random time period has...
|
by: tdahsu |
last post by:
All,
I'd appreciate any help. I've got a list of files in a directory, and
I'd like to iterate through that list and process each one. Rather
than do that serially, I was thinking I should...
|
by: darren |
last post by:
Hi
I have to write a multi-threaded program. I decided to take an OO
approach to it. I had the idea to wrap up all of the thread functions
in a mix-in class called Threadable. Then when an...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |