|
@@ -10,6 +10,7 @@
|
|
|
*/
|
|
|
|
|
|
#define _GNU_SOURCE
|
|
|
+#include <errno.h>
|
|
|
#include <sched.h>
|
|
|
#include <string.h>
|
|
|
#include <stdio.h>
|
|
@@ -75,6 +76,7 @@ static void touch(void)
|
|
|
|
|
|
static void start_thread_on(void *(*fn)(void *), void *arg, unsigned long cpu)
|
|
|
{
|
|
|
+ int rc;
|
|
|
pthread_t tid;
|
|
|
cpu_set_t cpuset;
|
|
|
pthread_attr_t attr;
|
|
@@ -82,14 +84,23 @@ static void start_thread_on(void *(*fn)(void *), void *arg, unsigned long cpu)
|
|
|
CPU_ZERO(&cpuset);
|
|
|
CPU_SET(cpu, &cpuset);
|
|
|
|
|
|
- pthread_attr_init(&attr);
|
|
|
+ rc = pthread_attr_init(&attr);
|
|
|
+ if (rc) {
|
|
|
+ errno = rc;
|
|
|
+ perror("pthread_attr_init");
|
|
|
+ exit(1);
|
|
|
+ }
|
|
|
|
|
|
- if (pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset)) {
|
|
|
+ rc = pthread_attr_setaffinity_np(&attr, sizeof(cpu_set_t), &cpuset);
|
|
|
+ if (rc) {
|
|
|
+ errno = rc;
|
|
|
perror("pthread_attr_setaffinity_np");
|
|
|
exit(1);
|
|
|
}
|
|
|
|
|
|
- if (pthread_create(&tid, &attr, fn, arg)) {
|
|
|
+ rc = pthread_create(&tid, &attr, fn, arg);
|
|
|
+ if (rc) {
|
|
|
+ errno = rc;
|
|
|
perror("pthread_create");
|
|
|
exit(1);
|
|
|
}
|