简体   繁体   中英

Access registers between/cross cores in multicore CPUs

This may sounds crazy but it seems unclear to me whether there is an interface to assembly programmers to write code to load one register on core 1 to a register on core 2. For example, load EAX on core 1 to EAX on core 2. Is it even possible?

More over what is the interface to assembly programmers to use two cores (run code on more than one core)?

No. To do this, one core has to store the value in memory and the other has to take it out. So the core one might look like this:

mov eax, [235]

And core 2 would do this:

mov [235], eax

The hardware doesn't directly offer this.

However, to build real tools (eg, debuggers), some facility like this must exist. This is implemented usually by kernal software for a system, that provides a facility for one CPU to "stop" another, to inspect its register state, to modify its register state, to single-step, to modify the memory map of the other CPU, etc. Such facilities are built on top of low level hardware primitives that allow one CPU to interrupt another, and code organized so that a CPU interrupt causes the interrupted CPU to make its state available to the the interrupting CPU. (This tends to be very tricky code, and extremely hardware dependent).

Windows offers these capabilities (at least the register access part) via the Win32 call, GetThreadContext(). I'm sure there's an equivalent for Win64, and something analogous for Linux, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM