|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Problem with pthread_delay_np
I am geeting the follwoing error,thoug i included pthread.h ,
undefined reference to `pthread_delay_np' hav any ideas. |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
All <pthread.h> tells the code is what functions take what parameters. To get the actual library code when compiled, you need to link with -lpthread. Certain libraries, like <stdio.h> get linked by default, but this is not normal behavior for most anything else.
|
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
I did that too..,
My code, Code:
#include<stdio.h>
#include<pthread.h>
#include<time.h>
#include<sched.h>
struct timespec ob={0,0};
void *f1()
{
// struct timespec ob={0,0};
printf("Thread 1 started\n");
ob.tv_sec=5;
ob.tv_nsec=5000000000;
printf("i will be waiting\n");
pthread_delay_np(&ob);
return NULL;
}
void *f2()
{
printf("Thread 2 started\n");
printf("I am exiting\n");
return NULL;
}
int main()
{
pthread_t t1,t2;
pthread_create(&t1,NULL,f1,NULL);
pthread_create(&t2,NULL,f2,NULL);
pthread_join(t1,NULL);
pthread_join(t2,NULL);
}
vchanda@cg7:~/assess6$ cc -lpthread demo.c
/tmp/ccuEthUa.o: In function `f1':
demo.c:(.text+0x42): undefined reference to `pthread_delay_np'
collect2: ld returned 1 exit statusLast edited by Scott; 07-01-2010 at 05:46 AM.. Reason: Code tags, please... |
|
#4
|
|||
|
|||
|
I think offhand pthread_delay_np() is AIX only?
You need to look at sleep() and/or nanosleep(). |
| Sponsored Links | |
|
|
#5
|
||||
|
||||
|
It is also available on HP-UX, VMS and Tru64 UNIX.
pthread_delay_np() originated in the D4 draft of the POSIX.1c standard. The main implementer of POSIX.1c D4 was OSF for Distributed Computing Environment (DCE). The suffix _np denotes that the API is non-portable and cannot be relied on to be available on another platform. Generally nanosleep() is what you want to use as a replacement. |
| Sponsored Links | |
|
|
#6
|
|||
|
|||
|
The pthread_delay_np function exists on Tru64 UNIX, but not on HP-UX. This function will be available on a temporary basis in the Tru64 UNIX Migration Environment for HP-UX.
The pthread_delay_np function is a nonportable equivalent to the POSIX standard function nanosleep. Both accept a time interval using a standard POSIX struct timespec structure, which defines the interval in seconds and nanoseconds, and suspend the calling thread for at least as long as the specified interval. The major functional difference is that pthread_delay_np is based on a timed condition variable wait: it computes an absolute target time by adding the interval to the current system time, and waits until that target time arrives, disregarding any signals delivered to the thread. Changes to the system time will affect the actual interval waited. The nanosleep function waits for the specified interval regardless of system time changes; however, if a signal is delivered to the thread, and dismissed normally, nanosleep will return to the caller and can optionally return the remaining interval. The Migration Environment contains Tru64 UNIX APIs, development tools, and commands and utilities to assist customers in migrating their applications from Tru64 UNIX to HP-UX. _______________________________________________________________ apartamentos amueblados panama |
| Sponsored Links | |
|
|
#7
|
||||
|
||||
|
Quote:
|
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| DHCP problem and eth1 problem | sllinux | UNIX for Dummies Questions & Answers | 0 | 10-23-2009 02:45 AM |
| user login problem & Files listing problem. | pernasivam | AIX | 1 | 06-18-2009 09:09 AM |
| Loop problem with one more problem | aliahsan81 | Shell Programming and Scripting | 3 | 01-07-2009 01:02 AM |
| problem in finding a hardware problem | girish.batra | Solaris | 8 | 09-09-2008 10:10 AM |
| ssh script problem problem | pcjandyala | Shell Programming and Scripting | 2 | 07-31-2008 03:27 PM |
|
|