|
![](/i/fill.gif) |
Am 03.11.2012 13:31, schrieb Warp:
> Normally you don't have to worry about this when writing a program because
> the operating system takes care of it. You simply make a system call to
> the OS to tell it "start a new process/thread and run this code in it".
> The OS takes care of the ugly details.
>
> However, how does the OS do it? How does it run code in different
> processors/cores? What exactly is the mechanism for this? What are the
> machine opcodes required to do this?
From what I gather from Intel's System Programmer Guide, there are no
specific opcodes involved.
In essence, one of the processors (the Bootstrap Processor, BSP) starts
executing with a certain flag set (BSP in IA32_APIC_BASE MSR), while the
others (the Application Processors, APs) enter a certain waiting state
with that flag cleared. The BSP then does some OS initialization,
including the creation of the task list; after that, it wakes up the
APs, and grabs itself a task to work on. The APs, by means of testing
for the BSP flag, take a different path through the code to bypass the
initialization stuff, and grab themselves tasks straight away.
Starting a new process or thread is done in the very same way as on a
single-processor machine: The parent process simply calls into the OS
code, which then sets up the data structures for a new process or
thread, and adds the new entry to the process and/or task list. From
that on, the new job may be picked up by any processor that has nothing
better to do.
(http://download.intel.com/products/processor/manual/325462.pdf might
provide more detail.)
Post a reply to this message
|
![](/i/fill.gif) |