Hi,
I have troubles with the pth_usleep. I pin pointed down the problem to
the program below.
Running it (pth-1.3.7 on FreeBSD 4.1) result in:
ibc usleep
Time elapsed: 2.018674 sec
Time elapsed: 2.019807 sec
pth_usleep
Time elapsed: 2.009818 sec
**Pth** SCHEDULER INTERNAL ERROR: no more thread(s) available to
schedule!?!?
Abort(core dumped)
Why?
Shouldn't pth_usleep behave as usleep? usleep sleeps for a maximum of
2^32-1 usec (~71 minutes) while pth_usleep breaks at 2000080 usecs. Why
2000080?
Running pth_usleep in a thread in doesn't break the scheduler but it
returns almost immediately (I have not measured) regardless of what
value is sent to pth_usleep.
I use the following workaround:
ptt = pth_time(sleep_time / 1000000, sleep_time % 1000000);
pth_nap(ptt)
if I want the program to sleep sleep_time usecs. As I explained above
the following doesn't work if sleep_time >= 2000080:
ptt = pth_time(0, sleep_time);
pth_nap(ptt)
Any comments?
/*--------------cut here---------------------*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <pth.h>
#define TIME(stm) {struct timeval t1, t2; gettimeofday(&t1, NULL); stm;
gettimeofday(&t2, NULL); printf("Time elapsed: %f sec\n", (t2.tv_sec -
t1.tv_sec) + (t2.tv_usec - t1.tv_usec)/1000000.0); }
int
main(void)
{
pth_init();
printf("libc usleep\n");
TIME(usleep(2000079)) ;
TIME(usleep(2000080)) ;
printf("pth_usleep\n");
TIME(pth_usleep(2000079)) ;
TIME(pth_usleep(2000080)) ;
return 0;
}
/*-----------------cut here----------------------*/
______________________________________________________________________
GNU Portable Threads (Pth) http://www.gnu.org/software/pth/
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager (Majordomo) [EMAIL PROTECTED]