How are the stack pointer and program status word maintained in multiprocessor architecture?

做~自己de王妃 提交于 2019-12-23 03:22:50

问题


In a multi-processor architecture, how are registers organized?

For example, in a 4 cores processor, a minimum of 4 processes can run at a time.
How are stack pointer, program status registers and program counter organized?

What about other general purpose registers?

My guess is, each core will have a separate set of registers.


回答1:


Imagine 4 completely separate computers, each with a single-core CPU. A 4-core computer is like that; except:

  • All CPUs share the same physical address space (and can all use the same RAM, PCI devices, etc)
  • Interrupt/IRQ controllers may be designed so the OS can tell it which CPU/s should be interrupted by the IRQ
  • CPUs are typically able to signal each other (e.g. "inter-processor interrupts")
  • Some CPUs may share some caches
  • Some CPUs may share some control registers (e.g. for things like power management, cache configuration, etc)
  • For modern CPUs, some CPUs may share some or all execution units (SMT, hyper-threading, etc)
  • For modern systems (where memory controller is built into the physical chip) some CPUs may share the same memory controller

Most of this is "invisible" to most software. Unless you're writing part of an OS that controls power management, you don't need to care if power management is shared between CPUs or not; unless you're writing an OSs/kernel's low level IRQ handling you don't need to care how IRQs reach device drivers, etc.

The same applies to how many CPUs actually exist. The OS/kernel normally ensures that applications only need to care about higher level abstractions (e.g. "threads"). How this higher level abstraction works depends on the OS - normally (for most OSs) the OS/kernel attempts to provide the illusion that all threads are running at the same time by switching between them "quickly enough" (where if there's only 4 CPUs a maximum of 4 threads actually do run at the exact same time), but it's usually far more complex than this (involving things like thread priorities, pre-emption rules, etc) and (even though it's relatively rare) it may be very different (e.g. for some systems the same thread may be run on multiple CPUs at the same time for fault tolerance/redundancy purposes; for some systems there might just be a queue of functions and their data, where multiple functions run at the same time; etc).




回答2:


Multiprocessor means that there are at least two discrete processors on the same platform -- usually on the same motherboard

  • A subset is distributed multiprocessing, where two PC's for example are programmed to appear as a single system with two processors

Multicore means that the most or all of the CPU is replicated many times on single chip. - this also means that stack, status, program counter and all generic purpose registers are replicated.

  • Hyperthreading is a technique, where each stage of the pipeline executes commands from different processes.

Multiprocessing means in OS level that everything a process consists of, is switched every now and then.

Multithreading is a lightweight variant of multiprocessing, where the threads e.g. share the same code segment and same data segment, same file descriptors etc. but have unique stacks (and of course unique status registers and program counters)

  • Also means multiprocessing in general (hardware architecture)


来源:https://stackoverflow.com/questions/13228773/how-are-the-stack-pointer-and-program-status-word-maintained-in-multiprocessor-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!