Your message dated Tue, 16 Dec 2014 12:06:29 +0100
with message-id <[email protected]>
and subject line the BTS is not a user support forum
has caused the Debian Bug report #763907,
regarding Thread never continues after wait
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
763907: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=763907
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: base

Severity: important

 

Dear Maintainer,

*** Please consider answering these questions, where appropriate ***

 

   * What led up to the situation?

Migrated an existing running application to Debian.

 

   * What exactly did you do (or not do) that was effective (or

     ineffective)?

Attempted to use all techniques recommended (via web search) to delay a
thread for specified period of time.

None were successful.

The code runs correctly without problem on Angstrom.

 

   * What was the outcome of this action?

Thread never returns after calling wait function (nanosleep,
pthread_cond_timedwait, etc.).

 

   * What outcome did you expect instead?

Thread would delay for specified time, then continue execution.

 

 

 

-- System Information:

Debian Release: 7.5

  APT prefers stable-updates

  APT policy: (500, 'stable-updates'), (500, 'stable')

Architecture: armhf (armv7l)

Foreign Architectures: armel

 

Kernel: Linux 3.8.13-bone50 (SMP w/1 CPU core)

Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Shell: /bin/sh linked to /bin/dash

 

 

Additional info - sample code:

 

// NOTE: for linux, any executables that link with WebApi must also

//       link with librt.so, this can be done by adding the "pthread"
library dependency

//       or adding the "-lpthread" linker option

 

#   include <pthread.h>

#   include <time.h>

#   include <unistd.h>

#   include <sys/select.h>

#   include <signal.h>

 

Thread::Thread(THREAD_FN threadFn, PVOID param/*=NULL*/)

: m_thread(threadFn)

, m_param(param)

, m_id(-1)

{

    m_mtxWait = PTHREAD_MUTEX_INITIALIZER;

    m_condWait = PTHREAD_COND_INITIALIZER;

    pthread_mutex_init(&m_mtxWait, NULL);

    pthread_cond_init(&m_condWait, NULL);

}

 

Thread::~Thread()

{

    cancel();

    pthread_mutex_destroy(&m_mtxWait);

    pthread_cond_destroy(&m_condWait);

}

 

bool Thread::start(PVOID param/*= NULL*/)

{

    bool rc(false);

 

    if (NULL != m_thread && -1 == m_id) {

        rc = (0 == pthread_create(&m_id, NULL, m_thread, param != NULL ?
param : m_param));

    }

#if defined(DEBUG)

    else {

        printf("Thread::start thread already running\n");

    }

#endif

 

    return(rc);

}

 

bool Thread::cancel(PVOID* retval/*=NULL*/)

{

    bool rc(false);

 

    if (-1 != m_id) {

        pthread_cancel(m_id);

        rc = pthread_join(m_id, retval);

        m_id = -1;

    }

#if defined(DEBUG)

    else {

        printf("Thread::cancel thread not running\n");

    }

#endif

 

    return(rc);

}

 

void Thread::wait(WAITTIME delay)

{

#   define nS_PER_S     1000000000

#   define mS_PER_S     1000

#   define nS_PER_mS    (nS_PER_S/mS_PER_S)

 

#   if 0

    // BUGBUGBUG : This doesn't work on Debian

    nanosleep(&delay);

#   else

    // BUGBUGBUG : This also doesn't work on Debian

    struct timespec abs;

    u_int64_t totNs;

    int retval;

 

    clock_gettime(CLOCK_REALTIME, &abs);

    totNs = abs.tv_nsec + delay.tv_nsec;

    abs.tv_nsec = totNs % nS_PER_S;

    totNs /= nS_PER_S;

    abs.tv_sec += delay.tv_sec + (long)totNs;    // add 1 so timer goes
off first

 

    pthread_mutex_lock(&m_mtxWait);

    retval = /**/ pthread_cond_timedwait(&m_condWait, &m_mtxWait, &abs);
//*/ nanosleep(reltime, NULL);

    pthread_mutex_unlock(&m_mtxWait);

}

 

 

Calling code:

 

void* syncThread(void* param);

Thread threadObject(syncThread);

 

syncThread.start();

 

void* syncThread(void* param);

{

    struct timespec delay = {1, 0};

 

    threadObject.wait(delay);

    // NEVER GETS HERE

}

 


--- End Message ---
--- Begin Message ---
Hi,

the BTS is not a user support forum, please try 
http://lists.debian.org/debian-user/ instead.


cheers,
        Holger

Attachment: signature.asc
Description: This is a digitally signed message part.


--- End Message ---

Reply via email to