Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can I get the processor ID of the current process in C in Linux? [duplicate]

Tags:

c

linux

I'm writing a program that needs to know what logical processor it's running on.

This question tells me how to do it in assembly, while this question tells me how to use this code in assembly without translating it to AT&T syntax.

Is there an easier way to do this using existing Linux system calls or library functions, or is it necessary for me to reinvent the wheel?

like image 688
Nathan Fellman Avatar asked Feb 20 '12 09:02

Nathan Fellman


1 Answers

There's the linux specific getcpu call.

like image 130
abyx Avatar answered Sep 28 '22 08:09

abyx