How to place global variable for each CPU in SMP system?
I currently let each CPU map a certain location to different physical memory:
CPU0 0xC0007000 - > 0x400000
CPU1 0xC0007000 - > 0x401000
and I read/write these variable from 0xC0007000
How to place global variable in SMP system?
How to place global variable in SMP system?
Last edited by nbdd0121 on Thu Aug 22, 2013 8:32 pm, edited 1 time in total.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: How to place global variable in SMP system?
int variable_name;
Seriously, if you have to ask this question in this fashion you will probably need to learn a lot about mutual exclusion first.
Seriously, if you have to ask this question in this fashion you will probably need to learn a lot about mutual exclusion first.
Re: How to place global variable in SMP system?
As Combuster I also think that you could specify your question.
There can be examples which way answer may go:
1. Variable which is shared between processes in SMP system (but in one CPU)
2. Variable which is shared between CPU
-- Problem: need locks for writing/reading
3. etc.
There can be examples which way answer may go:
1. Variable which is shared between processes in SMP system (but in one CPU)
2. Variable which is shared between CPU
-- Problem: need locks for writing/reading
3. etc.
Hobby stuff (suckless libs, compilators, game engines, kernels): github. Work @ zabbix: arseniuss@zabbix
Re: How to place global variable in SMP system?
Hi,
One (extremely common) solution would be to have one or more physical pages that are mapped at the same virtual address for all CPUs. For example, for most OSs, all of "kernel space" is the same for all CPUs.
Cheers,
Brendan
By mapping physical memory this way, no CPU can access the same RAM which makes it impossible for different CPUs to access the same global variable/s.nbdd0121 wrote:How to place global variable for each CPU in SMP system?
I currently let each CPU map a certain location to different physical memory:
CPU0 0xC0007000 - > 0x400000
CPU1 0xC0007000 - > 0x401000
and I read/write these variable from 0xC0007000
One (extremely common) solution would be to have one or more physical pages that are mapped at the same virtual address for all CPUs. For example, for most OSs, all of "kernel space" is the same for all CPUs.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: How to place global variable in SMP system?
nopeCombuster wrote:int variable_name;
volatile long variable_name;
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html
http://users.atw.hu/gerigeri/DawnOS/download.html
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: How to place global variable in SMP system?
It was the correct answer to the original (ridiculous) form of the question, and it could still be depending on the solution.Geri wrote:nopeCombuster wrote:int variable_name;
volatile long variable_name;