???????????????????

//??????????????????????????????
//???????????sec??????????
//?????????????????????????ID?????????
bool ManagePthread_TimeReadSignal(PTHREAD_BUF *rbuf?? PTHREAD_ID thread_num?? int sec)
{
    bool b_valid = false;
    struct timespec to;
    int err;
    to.tv_sec = time(NULL) + sec;
    to.tv_nsec = 0;
 
 //????
    pthread_mutex_lock(&managePthread.g_pthread_mutex[thread_num]);
 //???sec???????????????select
    err = pthread_cond_timedwait(&managePthread.g_pthread_cond[thread_num]?? &managePthread.g_pthread_mutex[thread_num]?? &to);
    if(err == ETIMEDOUT)
    {
        pthread_mutex_unlock(&managePthread.g_pthread_mutex[thread_num]);
        return false;
    }
 
 //?????????
    if(managePthread.g_pthread_info[thread_num] == WRITE_FLAG)
    {
        managePthread.g_pthread_info[thread_num] = READ_FLAG;
        memcpy((PTHREAD_BUF *)rbuf?? (PTHREAD_BUF *)&managePthread.g_pthread_buf[thread_num]?? sizeof(PTHREAD_BUF));
        b_valid = true;
    }
 
 //????
    pthread_mutex_unlock(&managePthread.g_pthread_mutex[thread_num]);
    return b_valid;
}

//?????????????
bool ManagePthread_ReadSignal(PTHREAD_BUF *rbuf?? PTHREAD_ID thread_num?? bool wait)
{
    bool b_valid = false;

    pthread_mutex_lock(&managePthread.g_pthread_mutex[thread_num]);
    if(wait == true)
        pthread_cond_wait(&managePthread.g_pthread_cond[thread_num]?? &managePthread.g_pthread_mutex[thread_num]);

    if(managePthread.g_pthread_info[thread_num] == WRITE_FLAG)
    {
        managePthread.g_pthread_info[thread_num] = READ_FLAG;
        memcpy((PTHREAD_BUF *)rbuf?? (PTHREAD_BUF *)&managePthread.g_pthread_buf[thread_num]?? sizeof(PTHREAD_BUF));
        b_valid = true;
    }
    pthread_mutex_unlock(&managePthread.g_pthread_mutex[thread_num]);
    return b_valid;
}

//????/??????????
bool ManagePthread_SendSignal(PTHREAD_BUF *sbuf?? PTHREAD_ID thread_num)
{
    bool b_valid = false;

    pthread_mutex_lock(&managePthread.g_pthread_mutex[thread_num]);
    managePthread.g_pthread_info[thread_num] = WRITE_FLAG;
    if(sbuf)
    {
        memcpy((PTHREAD_BUF *)&managePthread.g_pthread_buf[thread_num]?? (PTHREAD_BUF *)sbuf?? sizeof(PTHREAD_BUF));
    }
    pthread_mutex_unlock(&managePthread.g_pthread_mutex[thread_num]);
    pthread_cond_signal(&managePthread.g_pthread_cond[thread_num]);
    b_valid = true;
    return b_valid;
}

//??
bool ManagePthread_BroadcastSignal(PTHREAD_BUF *sbuf?? PTHREAD_ID thread_num)
{
    bool b_valid = false;

    pthread_mutex_lock(&managePthread.g_pthread_mutex[thread_num]);
    managePthread.g_pthread_info[thread_num] = WRITE_FLAG;
    memcpy((PTHREAD_BUF *)&managePthread.g_pthread_buf[thread_num]?? (PTHREAD_BUF *)sbuf?? sizeof(PTHREAD_BUF));
    pthread_mutex_unlock(&managePthread.g_pthread_mutex[thread_num]);
    pthread_cond_broadcast(&managePthread.g_pthread_cond[thread_num]);
    b_valid = true;
    return b_valid;
}