ravenpl's answer is correct and very informative. However, I would like to expound on the threading topic.
As ravenpl said, in Assembly, and to the CPU in general, there is no concept of threads or processes; each core executes a single instruction at a time, and it is up to the software (e.g. the operating system) to divide and group the instructions on each tasks and feed them to each individual core or processor.
There are some very specific algorithms and techniques to do this, and all of them are fairly complex. However, some processor manufacturers provide libraries or compilers that aid in making the various decisions required at the lowest levels of execution.
If you are using an Intel multi-core processor, you may want to look into the Intel TBB (Threading Building Blocks) library:
http://en.wikipedia.org/wi
-dZ.
Main Topics
Browse All Topics





by: ravenplPosted on 2008-11-16 at 03:30:15ID: 22970306
> What's the main difference between a normal processor and a dual or quad, when it comes down to assembler programming?
Nothing. Assembler has no idea about threads. You are coding single thread.
After all, C/C++ is the same - You are coding single thread - but if You know the code is to be thread safe, You have to code it that way.
Same with asm, if You want to make sure that the code is thread safe, You have to use bus/memory locking or atomic instructions.
Look at this case from CPU side - one core always runs single thread. It's the operating system who creates(on process request) new threads and processes and manages them.
> P.S. I am playing around with this "make your own OS" tutorials
So basically what You need is to create threads scheduler. Initialize every available cpu/core with some OS thread(probably same entry point), which will then run the scheduler to assign userland threads/processes.