Thanks, fixed in trunk in r27605.
--dave
Danny Munera <dannymun...@gmail.com> wrote on 04/03/2014 01:37:04 PM:
> From: Danny Munera <dannymun...@gmail.com>
> To: Mailing list for users of the X10 programming language <x10-
> us...@lists.sourceforge.net>,
> Date: 04/03/2014 01:37 PM
> Subject: Re: [X10-users] Sleep Function
>
> Thanks for the fast answers!
>
> I debugged the Thread:sleep function in the file Thread.cc with the
> printfs, as you suggest me. I found that the function
> pthread_cond_timedwait is returning an error code EINVAL (The
> value specified by cond, mutex, or abstime is invalid). So, I
> checked the argument passed to the function and I found an error.
> The abstime argument cannot had a tv_nsec value of less than 0 or
> greater than 1,000,000,000 but in the function is possible that your
> tout.tv_nsec get a value greater than 1,000,000,000. So I changed
> the function fixing this invalid argument and It works, the problem
> is solved!!!.
>
> This is the change that I made in the sleep function:
>
> void
> Thread::sleep(x10_long millis, x10_int nanos)
> {
> Thread* th = currentThread();
> cond_mutex_t *cmp = &(th->__thread_cmp);
> x10_boolean done = false;
> struct timeval tval;
> struct timespec tout;
> long sleep_usec;
> int rc;
> __xrxDPrStart();
> rc= pthread_mutex_lock(&(cmp->mutex));
> pthread_cleanup_push(thread_sleep_cleanup, (void *)cmp);
> gettimeofday(&tval, NULL);
> tout.tv_sec = tval.tv_sec + (millis/1000);
> tout.tv_nsec = ((tval.tv_usec + ((millis%1000) * 1000)) * 1000) +
nanos;
> tout.tv_sec += tout.tv_nsec / 1000000000UL;
> tout.tv_nsec %= 1000000000UL;
> while (!done) {
> rc = pthread_cond_timedwait(&(cmp->cond), &(cmp->mutex), &tout);
> if (rc == ETIMEDOUT) {
> done = true;
> } else {
> break;
> }
> }
> pthread_cleanup_pop(1);
> if (!done) throwException<InterruptedException>();
> __xrxDPrEnd();
> }
>
> Danny Múnera
>
> On Thu, Apr 3, 2014 at 2:14 PM, David P Grove <gro...@us.ibm.com> wrote:
> Danny Munera <dannymun...@gmail.com> wrote on 04/03/2014 05:40:10 AM:
>
> >
> > I'm using the function System.sleep() to activate some functionality
> > in my project to be executed each X ms. However, I have some strange
> > behavior in this function, because frequently it is returning with
> > false (interrupted), and the functionality is not correctly
> > executed. I'm getting lots of messages "cannot execute sleep".
> >
> > I've read the documentation of the sleep function, but i didn't find
> > any clue to fix this problem. I also implemented a simple example
> > using only the sleep function and It works well, but when I use the
> > sleep in my code It doesn't work. I have no idea where I should
> > start to search the cause of the problem.
> >
> > Could you give me some suggestion about how to find the cause of
> this problem?
> >
> Looking at the implementation of sleep, this strongly suggests that
> some other part of your program is interrupting the sleeping thread.
> As Vijay suggested, you could program around this. This would give
> you the sleep behavior you want, but perhaps mask a real
> (performance) problem in the rest of your program you should be
> fixing. I'd try to get a debugger/logging printfs into the Java/C++
> implementations of Thread.sleep and see if there are hints as to
> where the interrupts are coming from.
>
> --dave
>
>
------------------------------------------------------------------------------
>
> _______________________________________________
> X10-users mailing list
> X10-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/x10-users
>
------------------------------------------------------------------------------
> _______________________________________________
> X10-users mailing list
> X10-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/x10-users
------------------------------------------------------------------------------
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users