nV News Forums

 
 

nV News Forums (http://www.nvnews.net/vbulletin/index.php)
-   General Linux (http://www.nvnews.net/vbulletin/forumdisplay.php?f=27)
-   -   linux library needed for pthread_setaffinity_np (http://www.nvnews.net/vbulletin/showthread.php?t=107171)

tanmay.anjaria 01-31-08 12:36 AM

linux library needed for pthread_setaffinity_np
 
Hello,

I'm using a quad processor system. I want a program running on my PC having four threads and each of them running on different processors.

I'm using function "pthread_setaffinity_np" for that. while compiling, it gives an error saying "undefined reference to : pthread_setaffinity_np"

Can anyone tell me which library should be included for "pthread_setaffinity_np" ?

Thanks in advance... :)

Tanmay

mlauss 01-31-08 02:10 AM

Re: linux library needed for pthread_setaffinity_np
 
Did you add "-lpthread" (a.k.a tell gcc to use the libpthread library) to the compiler commandline?

tanmay.anjaria 01-31-08 03:02 AM

Re: linux library needed for pthread_setaffinity_np
 
yes, I'm using -lpthread currently...

command line goes like this...

gcc -lm -lpthread test.c

mlauss 01-31-08 05:35 AM

Re: linux library needed for pthread_setaffinity_np
 
Your libc appears to be missing NPTL bits

This is from glibc-2.7 (which is NPTL only):
# nm /lib/libpthread-2.7.so | grep setaffinity
0000e0c0 t __pthread_attr_setaffinity_new
0000e1c0 t __pthread_attr_setaffinity_old
0000ded0 t __pthread_setaffinity_new
0000df80 t __pthread_setaffinity_old
0000e0c0 T pthread_attr_setaffinity_np@@GLIBC_2.3.4
0000e1c0 T pthread_attr_setaffinity_np@GLIBC_2.3.3
0000ded0 T pthread_setaffinity_np@@GLIBC_2.3.4
0000df80 T pthread_setaffinity_np@GLIBC_2.3.3

Also, maybe it works with
#include<nptl/pthread.h>
since I'm told pthread_setaffinity_np() is a wrapper around
the sched_setaffinity() call (you know the "static inline" kind of wrapper ;-) )


All times are GMT -5. The time now is 08:21 PM.

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1998 - 2014, nV News.