Linux APIs: Difference between revisions
| Line 16: | Line 16: | ||
===Execution resources=== | ===Execution resources=== | ||
General details of cpu partitioning and affinity can be found on the [[cpuset]] page. | General details of cpu partitioning and affinity can be found on the [[cpuset]] page. | ||
* <tt>getcpu(2)</tt> was added in 2.6.19, with [[libc|glibc]] support in 2.6. It identifies the current CPU and NUMA node of the thread (this might be immediately invalidated). Only one CPU and NUMA id can be reported, which might not make sense for all process models (especially the NUMA part). <tt>sched_getcpu(2)</tt> is equivalent to calling <tt>getcpu(&aid,NULL,NULL)</tt>. | * <tt>getcpu(2)</tt> was added in 2.6.19, with [[libc|glibc]] support in 2.6. It identifies the current CPU and [[NUMA]] node of the thread (this might be immediately invalidated). Only one CPU and NUMA id can be reported, which might not make sense for all process models (especially the NUMA part). <tt>sched_getcpu(2)</tt> is equivalent to calling <tt>getcpu(&aid,NULL,NULL)</tt>. | ||
* Since 2.5.8, <tt>sched_getaffinity(2)</tt> and <tt>sched_setaffinity(2)</tt> have provided affinity mask management within the process's cpuset. [[libc|Glibc]] support was added in 2.3. In [[libc|glibc]] 2.3.4's [[pthreads]] implementation, <tt>pthread_getaffinity_np(3)</tt> and <tt>pthread_setaffinity_np(3)</tt> were added as wrappers around these system calls. | * Since 2.5.8, <tt>sched_getaffinity(2)</tt> and <tt>sched_setaffinity(2)</tt> have provided affinity mask management within the process's cpuset. [[libc|Glibc]] support was added in 2.3. In [[libc|glibc]] 2.3.4's [[pthreads]] implementation, <tt>pthread_getaffinity_np(3)</tt> and <tt>pthread_setaffinity_np(3)</tt> were added as wrappers around these system calls. | ||
* Since 2.6.26, <tt>getrusage(2)</tt> with a <tt>RUSAGE_THREAD</tt> parameter retrieves statistics for the calling thread only. | * Since 2.6.26, <tt>getrusage(2)</tt> with a <tt>RUSAGE_THREAD</tt> parameter retrieves statistics for the calling thread only. | ||
=== clone(2) === | === clone(2) === | ||
* <tt>clone(2)</tt> is far more granular with regards to what's copied and shared that <tt>fork(2)</tt>. | * <tt>clone(2)</tt> is far more granular with regards to what's copied and shared that <tt>fork(2)</tt>. | ||