Re: Question about multi-processing, multi-threading...
Re: Question about multi-processing, multi-threading...
- Subject: Re: Question about multi-processing, multi-threading...
- From: Thierry Bucco <email@hidden>
- Date: Wed, 21 Jan 2004 18:33:35 +0100
On Jan 21, 2004, at 8:38 AM, Thierry Bucco wrote:
Hi,
I have written a little C program who execute an infinite loop.
When I launch process viewer, I can see that my 2 processors are busy.
(60%, 40%).
I was thinking that if an application was not multi threaded (like my
little exemple), the task was rans on only 1 procesor, it seems that
it's wrong.
But If I change my source code, to execute 2 infinite loops in a
forked
process, my processors are very busy (100%, 100%).
Is there a way to force a thread to run on the second processor ?
What are you trying to insure by attempting this?
It's just a question...
Could you give me some informations about scheduling on OS X ?
In the first case you have single process that is single threaded in
that it is only doing processing in a single thread (secondary threads
may exist in support of your application). The scheduler if free to
run your processes thread on any available CPU when it is ready to
run. So it may ping-pong between the CPUs and hence you see the load
somewhat shared by the CPUs (note it adds to near 100% on average,
100% of a single CPU).
I have the feeling that my single threaded application is running on
both processors, is it possible ?
Because the load of processors increases considerably.
Is it possible that in my loop, scheduler gives some work by turns, or
is my loop only executed on one processor ?
In fact I would like to know if my loop is running on one processor or
on both at the same time.
In the second case you have two separate processes with two separate
threads running your loop. Again the CPU is free to schedule the
threads as appropriate. In this case you have two so each CPU can be
given one to run at the same time.
I don't understand why the load is 100% for both processors, and not
when I don't use thread.
Remember countless other threads exist in the system and will get
scheduled as appropriate based on run-ability, priority and fairness.
I believe everything in Mac OS X, including the scheduler, can run on
either CPU.
-Shawn
thierry
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.