Questions tagged [smp]

Symmetric multiprocessing

"Symmetric multiprocessing (SMP) involves a multiprocessor computer hardware architecture where two or more identical processors are connected to a single shared main memory and are controlled by a single OS instance. Most common multiprocessor systems today use an SMP architecture." [Source: Wikipedia.]

144 questions
258
votes
10 answers

What does multicore assembly language look like?

Once upon a time, to write x86 assembler, for example, you would have instructions stating "load the EDX register with the value 5", "increment the EDX" register, etc. With modern CPUs that have 4 cores (or even more), at the machine code level does…
Paul Hollingsworth
  • 11,954
  • 12
  • 48
  • 66
81
votes
3 answers

multi-CPU, multi-core and hyper-thread

Could anyone recommend some documents to me to illustrate the differences between multi-CPU, multi-core, and hyper-thread? I am always confused about these differences, and about the pros/cons of each architecture in different scenarios. EDIT: here…
George2
  • 42,353
  • 103
  • 307
  • 447
75
votes
3 answers

What is TLB shootdown?

What is a TLB shootdown in SMPs? I am unable to find much information regarding this concept. Any good example would be very much appreciated.
mousey
  • 10,655
  • 15
  • 47
  • 54
73
votes
5 answers

Is there a simple process-based parallel map for python?

I'm looking for a simple process-based parallel map for python, that is, a function parmap(function,[data]) that would run function on each element of [data] on a different process (well, on a different core, but AFAIK, the only way to run stuff on…
static_rtti
  • 46,349
  • 44
  • 123
  • 180
45
votes
4 answers

How are atomic operations implemented at a hardware level?

I get that at the assembly language level instruction set architectures provide compare and swap and similar operations. However, I don't understand how the chip is able to provide these guarantees. As I imagine it, the execution of the instruction…
Alexander Duchene
  • 877
  • 1
  • 9
  • 14
37
votes
6 answers

How to set CPU affinity for a process from C or C++ in Linux?

Is there a programmatic method to set CPU affinity for a process in c/c++ for the Linux operating system?
jcodeninja
  • 1,835
  • 3
  • 16
  • 14
20
votes
6 answers

Linux find out Hyper-threaded core id

I spent this morning trying to find out how to determine which processor id is the hyper-threaded core, but without luck. I wish to find out this information and use set_affinity() to bind a process to hyper-threaded thread or non-hyper-threaded…
Patrick
  • 3,854
  • 9
  • 29
  • 42
18
votes
4 answers

How can I get the CPU core number from within a user-space app (Linux, C)?

Presumably there is a library or simple asm blob that can get me the number of the current CPU that I am executing on.
efunneko
  • 381
  • 1
  • 3
  • 11
17
votes
1 answer

How are percpu pointers implemented in the Linux kernel?

On multiprocessor, each core can have its own variables. I thought they are different variables in different addresses, although they are in same process and have the same name. But I am wondering, how does the kernel implement this? Does it…
dspjm
  • 4,432
  • 4
  • 32
  • 52
15
votes
5 answers

What happens if two process in different processors try to acquire the lock at EXACTLY same time

Ok, so I am reading about synchronization, and I read through various algorithms such as spinlocks, semaphores, and mutex to avoid race condition. However, these algorithms can't prevent race condition in SMP when multiple proceses access the data…
SHH
  • 2,690
  • 1
  • 20
  • 39
14
votes
3 answers

Looking for cause of unexpected preemption in linux kernel module

I have a small linux kernel module that is a prototype for a device driver for hardware that doesn't exist yet. The code needs to do a short bit of computation as fast as possible from beginning to end with a duration that is a few microseconds. I…
Evan
  • 1,857
  • 11
  • 18
12
votes
3 answers

Assembly: does xadd instruction need lock?

I'm reading smphello.s code by allan cruse code in the following part he's trying to setup stack segment for each processor. the point is that he used xadd without using lock prefix while in the description of xadd as in here . there may be a lock…
becks
  • 2,468
  • 7
  • 29
  • 62
11
votes
2 answers

Linux Kernel: Spinlock SMP: Why there is a preempt_disable() in spin_lock_irq SMP version?

The original code in Linux kernel is: static inline void __raw_spin_lock_irq(raw_spinlock_t *lock) { local_irq_disable(); preempt_disable(); spin_acquire(&lock->dep_map, 0, 0, _RET_IP_); LOCK_CONTENDED(lock, do_raw_spin_trylock,…
Zhi Wang
  • 111
  • 1
  • 3
11
votes
1 answer

C and C++ compilers with "aggressive" volatile semantics

Are there any C or C++ compilers out there that implement "aggressive" memory consistency model for volatile variables? By "aggressive" consistency model I mean accompanying all writes to volatile variables with memory barriers in generated…
AnT
  • 291,388
  • 39
  • 487
  • 734
10
votes
1 answer

Running code on different processor (x86 assembly)

In real mode on x86, what instructions would need to be used to run the code on a different processor, in a multiprocessor system? (I'm writing some pre-boot code in assembler that needs to set certain CPU registers, and do this on every CPU in the…
Rhys Bradshaw
  • 103
  • 1
  • 4
1
2 3
9 10