我们可以在线程和相同 parent 的 child 之间使用 Pthread_cond_signal() 吗?
Can we use Pthread_cond_signal() between between a thread and a child of same parent?
我有一个 parent 进程,我使用 pthread_create()
从 parent 进程创建了一个新线程。我还使用 fork()
从 parent 进程创建了一个 child 进程 'C' 并退出了 parent 进程。现在 child 是 运行 作为守护进程。
我可以在 child 进程和线程之间使用 pthread_cond_signal
吗?或者 pthread_cond_signal
只能在同一进程的线程之间使用吗?
如果使用配置了 pthread_condattr_setpshared
function and a value of PTHREAD_PROCESS_SHARED
. You will also have to make the associated mutex process-shared, using a mutex attribute configured with pthread_mutexattr_setpshared.
的条件变量属性,使条件变量为进程共享,则可以跨进程使用条件变量
默认情况下,条件变量和互斥量不能跨进程共享。
我有一个 parent 进程,我使用 pthread_create()
从 parent 进程创建了一个新线程。我还使用 fork()
从 parent 进程创建了一个 child 进程 'C' 并退出了 parent 进程。现在 child 是 运行 作为守护进程。
我可以在 child 进程和线程之间使用 pthread_cond_signal
吗?或者 pthread_cond_signal
只能在同一进程的线程之间使用吗?
如果使用配置了 pthread_condattr_setpshared
function and a value of PTHREAD_PROCESS_SHARED
. You will also have to make the associated mutex process-shared, using a mutex attribute configured with pthread_mutexattr_setpshared.
默认情况下,条件变量和互斥量不能跨进程共享。