Hi,
By default is an app written using MASM single-threaded? In other words, I'd have to deliberately code it to be multi-threaded?
This is important as my software MUST be single-threaded.
Thanks!! :bg
Yes! To be be multi-threaded you would have to invoke another thread.
normally, an app is single threaded
if you have a multi-core computer, things may be different
newer pentiums allow for "out-of-order" execution of instructions - this can result in a process using another core
i am not certain if this actually falls in the catagory of "another thread", per se
but, i have experienced problems while timing code due to the program reading time stamp counter values from two different cores
you can use GetProcessAffinityMask and SetProcessAffinityMask to read/control which/how many of the cores are used
this is a simple program that limits execution to a single core, then switches back to the initial setting prior to exit
while the program is running, you may verify the core selection by using the Task Manager
INCLUDE \masm32\include\masm32rt.inc
;--------------------------------------------------------------------------
.DATA?
hProc dd ? ;process handle
AffSyst dd ? ;system affinity mask
AffProc dd ? ;process affinity mask
;--------------------------------------------------------------------------
.CODE
_main PROC
;get and store the process handle
INVOKE GetCurrentProcess
mov hProc,eax
;get the original affinity masks
INVOKE GetProcessAffinityMask,
eax,
ADDR AffProc,
ADDR AffSyst
;select only "core 0"
INVOKE SetProcessAffinityMask,
hProc,
1
;wait for a keypress
inkey
;set affinity to original condition
INVOKE SetProcessAffinityMask,
hProc,
AffProc
;terminate
exit
_main ENDP
;--------------------------------------------------------------------------
END _main
Excellent. Thank you.
Quotethen switches back to the initial setting prior to exit
Is this required? What is the effect of not doing this?
no - not a requirement, as the process only controls it's own affinity and is terminated
i put that in there as example code, is all
you may have parts of the program that you want to run with all cores and parts that are limited to one core
It is not actually multithreading. According to microsoft:-
The scheduler maintains a queue of executable threads for each priority level. These are known as ready threads. When a processor becomes available, the system performs a context switch. The steps in a context switch are:
1. Save the context of the thread that just finished executing.
2. Place the thread that just finished executing at the end of the queue for its priority.
3. Find the highest priority queue that contains ready threads.
4. Remove the thread at the head of the queue, load its context, and execute it.
So your 1 thread will run on whichever processor/core becomes availble first, leastways that's how I read it.
from experience, i can tell you that a single thread can run on more than one core
it is still considered a single thread
this is all it takes to confine it to a single core, however
INVOKE GetCurrentProcess
mov hProc,eax
INVOKE SetProcessAffinityMask,
hProc,
1
Quote from: dedndave on July 14, 2009, 10:40:14 PM
from experience, i can tell you that a single thread can run on more than one core
it is still considered a single thread
What I said.
OK - so I start my app, and even though it is
single threaded, could run on any processor/core when it's turn to execute next comes up?
Interesting.
I don't think it will affect my app - it only states that it is single threaded, it doesn't say it must run on the same processor/core as another thread.
This is what I'm working on currently: http://msdn.microsoft.com/en-us/library/aa375198(VS.85).aspx#stub
EDIT: Hmmmmm....... actually.....
QuoteAll calls between a GINA and Winlogon must be within a single thread.
Does this mean my app could actually be MULTI threaded, so long as the CALLS are not split across threads?
Something is nagging in the back of my mind about concurrency and the fact that it is possible to have threads execute out of order, thus meaning a thread requiring the result of another thread could execute first (out of order). Sometimes the system can detect this and queue them accordingly, other times it won't, and can cause a ?race condition?. I'm not sure of this could generate a threading exception error (sorry if I just made that up - it's late!). :dazzled:
That would be bad in my case. If it was single threaded however, if it is splitting across processors, could this affect the result??? It's not going to leave my app hanging mid-routine is it?
My head is going to explode... :eek
Back tomorrow! hehe!
no - a sequence of instructions may be performed out of order if they are not dependant
if an instruction is dependant on a previous instruction to be completed,
the processor waits for the first one to be completed (or looks for something else to do)
all that seems a bit silly to me, as the overhead for keeping track would seem worse than the penalty to begin with
but, they seem to have found ways to do it that improve overall performance, because they keep doing it - lol
for what you want to do, running on multiple cores may not be an issue
i mentioned the affinity functions because i have had troubles with it
they are fairly simple, although ms has found a way to over-complicate them for Win7 - lol
Don't confuse multi-threading and multi-cpu's. Even a 386 can multi-thread with a single CPU - it's all how the OS does it.
Regardless of which CPU your single-thread app runs on, the environment is the same (memory, next instruction etc.) with a few exceptions (rdtsc for example).
Hi,
QuoteDon't confuse multi-threading and multi-cpu's.
My impression was that a single threaded app started executing on "a" processor/core, then continued to execute exclusively on that processor/core until it was terminated.
Quotefor what you want to do, running on multiple cores may not be an issue
It will be interesting to see. I also want to write a driver. One thing at a time though! :dazzled:
Quotei mentioned the affinity functions because i have had troubles with it
they are fairly simple, although ms has found a way to over-complicate them for Win7 - lol
Good ol' MS! ::)
To avoid confusions people seem to be injecting...
Unless you create extra threads, your program is singe-threaded.
That single thread will run on ONE single processor core at a time.
If the machine contains multiple cores/processors, your program will still only run on ONE at any instance in time.
It may migrate between cores during context switches, but this should be transparent to the running of your program, unless you specifically check which core you're running on.
You can fix your thread to run only on a specific core by setting its affinity to that core. However, this may limit the running of your thread since that core will also be used by other threads, even while the other cores are free and ready to run.
Hi Tedd,
Regarding one thread running on one core, that is what I thought (only I thought the entire program ran on the same core/processor all the time). Thanks for clarifying. :U
that directly contradicts what i was saying
only one of us can be right - lol
a single-threaded process may use more than one core
you may verify this by writing a little test program
use the CPUID instruction to get the core number
read it several times
you will see it change
i have a dual-core "prescott" processor
give me a few minutes and i will write it and post results.....
There's no contradiction.
Quote from: Tedd on July 15, 2009, 11:48:25 AM
Unless you create extra threads, your program is singe-threaded.
That single thread will run on ONE single processor core at a time.
If the machine contains multiple cores/processors, your program will still only run on ONE at any instance in time.
It may migrate between cores during context switches, but this should be transparent to the running of your program, unless you specifically check which core you're running on.
You can fix your thread to run only on a specific core by setting its affinity to that core. However, this may limit the running of your thread since that core will also be used by other threads, even while the other cores are free and ready to run.
A single-threaded process will only use one core at a time, not many at once. However, through the lifetime of execution, it may execute time slices on different cores (which is what you can measure.)
ApicID (core ID) = CPUID (function eax=1) ebx register, bits 24-31
source and program attached
Code:
;--------------------------------------------
include c:\masm32\include\masm32rt.inc
.586
;--------------------------------------------
.code
;--------------------------------------------
_main PROC
mov ecx,10000
test00: push ecx
mov eax,1
cpuid
rol ebx,8
and ebx,0FFh
print str$(ebx)
pop ecx
loop test00
inkey
exit
_main ENDP
;--------------------------------------------
END _main
Result (P4 Prescott):
00000000000000000000000000000000000011111111111111111111111111111111111111111000
00000000000000000000000000000000000000111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111100000000000000000000000000000
00000000000000000000000000000000000000000000000000000001111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111000000000000000000
00000000000000000000000000000000000000000000000000000000000000000111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111100000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000111111111111111111111111111111111111111
11111111111111111111111111111111111011111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111000000000011111111111
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111111111111111111111111111111111111111111111111111110000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000111111
01111111111111111111111111111111111111111111111111111111111111111111111111111100
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000011111111111111111111111111111111111111111111111111
01111111111110000000011111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111110000000000
10000000000000000000000000000000000000000000000000000111111111111111111111111111
01111111111111111111111111111111111101111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01110000000000000000000000000000000000000000000000000000000000000000000000000000
01111111111111111111111111111111111111111111111111111111111111111111111100000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000001111111111111111111111111111111111111111
01111111111111111111111000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000011111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111000000000000000000000000000000000000000
10000000000000000000000010111000011110111011101110111011101111111011100111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
00000000000000000000000000000000000000000000000000000000000000000000000000000000
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111100000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
01111111111111111111111111111110000000000111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111000000001111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111100000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000111
01111111111111111110000000000000000000000000000000000000000000000000000000000000
10011111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111100000000000000000000000000
10000000000000000000000000000000000001000000000000000000000000000000000000000000
10000000000000000000111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000001111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111100000000000000000000000
10000000000000000000000000000000000000000011111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111110000000000000001111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
01111111111111111111111111111111111111111111111111111111111111111110000000000111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000001111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
00000000000000000000000000000000000000000000000000000000000000000111111111111111
01111111111111111111111111111111111111111111111100000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000011111111111111111111111111111111111111111111111111111111111111111111111
01111100000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000011111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111100000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10011111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000001111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111110000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000001
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111110000000000000000000000000000000000
00000000011111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111000000000000000000000000000
01111111111111111111111111111111111111111111111111111111111111111111111111111111
[attachment deleted by admin]
I thought a thread was the little bit of my program that was actually being executed at any moment?
no - threads are essentially "mini-processes"
one process (i.e. program) may create several threads
the test above tests cores
unless your program specifically creates more than one thread, it is a single thread that may run on multiple cores
Out of interest...
Intel Core2 Duo E6700.
If I use the command line:
cpuid.exe > cpuid.txt
the core is consistently 0 or 1. No change.
00000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000110000111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111100010000001000000000000000011111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111110010010001111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000100100011111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111110000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000000000000000000
10000000000000000000000000000000000000000000000000000000000000000110000000000000
00000000000000000000000000011111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
01111111111111111111111111111111111111111111111111111111111111111111111111111111
Quote from: dedndave on July 15, 2009, 03:18:45 PM
no - threads are essentially "mini-processes"
one process (i.e. program) may create several threads
the test above tests cores
unless your program specifically creates more than one thread, it is a single thread that may run on multiple cores
OK - thanks. :thumbu
Curious behavior... Each line has the general pattern:
100000........
100000........
011111........
011111........
lol
that is curious
that would seem to indicate that each time the program scrolls, the core switches
probably waiting for the scroll to complete - so switches to the other core to process other instructions (guessing)
i am running XP MCE2005 (Pro) +SP2
yours appears to stay with one core longer
that is a bit misleading, as we have no time-marker - only instruction cycles
i like yours better - it seems more "settled"
more than likely, yours is executing more instructions in a given time period than mine is
well - i know it is - core duo's are smokin cpu's in terms of clock cycles
I wondered the same.
If I output to a text file, it runs on one core the whole time (either 0 or 1).
mine does that too
Forgot to add - Win XP Pro SP3. I'll try it on Vista 64-bit and see what it does.
When you output text to the console, your thread is blocked until the console updates - so you waste half your slice doing nothing. When you output to a file, it's buffered, so the delay is minimal.
Yes - it's something I noticed with Windows apps too - if it has to update the display it is 1/10th the speed of when it doesn't...
I am new to this forum having just switched over from FASM/NASM. I switched back to MASM32 because I used to use MASM/TASM back in the CPM/DOS days and am more comfortable with it's structure and overall capabilities.
Anyway, speaking of multi-core processors, does anyone know where I can find code that would detect whether or not my program is running on a multi-core processor?
Logman
Hi,
A quick Google found this: http://www.developers.net/intelmcshowcase/view/2093
Intel API for detecting processor/core capabilities etc.. http://software.intel.com/en-us/articles/api-detects-ia-32-and-x64-platform-cpu-characteristics/
Thanks Astro:
I was on the Intel website and couldn't find what I needed. Your link got me close and one more click got me what I needed.
I am attempting to use a cpu core for my main user interface while I use a second and subsequent cores to conduct parallel (additional threads) web and database searches, and file read/writes in real time in order to present the user with preemptive data to their inputs.
Logman
;get and store the process handle
INVOKE GetCurrentProcess
mov hProc,eax
;get the original affinity masks
INVOKE GetProcessAffinityMask,
eax,
ADDR AffProc,
ADDR AffSyst
Why is that you have eax in GetProcessAffinityMask? It is empty since you moved data (pseudo process handle) out of the register.
The MOV instruction moves the value of the source operand into the destination operand. Like most 2-operand instructions, it does not alter the source operand.
just a little extra info. i've forgotten what this is called but for example if you have a loop with 2 opcodes and both opcodes have no dependency on each other then they can each be executed on one core. so in this instance a single thread would have 2 cores working on it at the same time. i've forgotten the name of this though for the time being..
I always thought of registers somewhat as the stack. You use mov--it moves data out of the source into the destination.
mov would be better named as cpy really because that is what it does. copy the contents from the source operand to destination operand
there is a huge difference between stack + registers. stack is just a block of memory whereas registers are special fast-access hardware on the CPU chip
Do registers have a maximum size?
mov eax, FFFFFFFFh
mov eax, FFFFFFFFh
mov eax, FFFFFFFFh
mov eax, FFFFFFFFh
mov eax, FFFFFFFFh
Or does it overwrite?
Quote from: 2-Bit Chip on August 14, 2009, 09:19:09 AM
Do registers have a maximum size?
mov eax, FFFFFFFFh
mov eax, FFFFFFFFh
mov eax, FFFFFFFFh
mov eax, FFFFFFFFh
mov eax, FFFFFFFFh
Or does it overwrite?
Yes it had. Eax size is 32-bit.
It had? I don't understand what you are trying to say.
a register is a piece of hardware with a fixed size. the extended registers : eax, ebx, ecx, edx, esi, edi, ebp, esp, eip are all 32 bits. which means they can only hold that much. it's not like the stack where it's extendable. so if you put something in the register and then something else then the first one gets overwritten unless you specifically only write to part of that register. eg. writing to only al/ah/ax in eax, etc. then you might get 3/3/2 bytes preserved respectively
Quote;get and store the process handle
INVOKE GetCurrentProcess
mov hProc,eax
;get the original affinity masks
INVOKE GetProcessAffinityMask,
eax,
ADDR AffProc,
ADDR AffSyst
"mov hProc,eax" copies the contents of eax to the memory labeled "hProc" for later use
the value is still in the eax register
mov destination,source
with most instructions, the source operand remains unaltered - only the destination changes
Thank you, thank you, thank you! Thank you very much!
btw, Chip
Quotemov eax, FFFFFFFFh
hexidecimal constants that begin with a letter must be preceeded by a 0
otherwise, the assembler thinks it is a label
labels, on the other hand, cannot begin with a numeric character
mov eax,0FFFFFFFFh