UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » Threads
  • » how to implement pthread_conditions using my own binary semaphore?

#1 2006-10-08 10:01 AM

thinking
Member
Registered: 2005-09-15
Posts: 103

Re: how to implement pthread_conditions using my own binary semaphore?

[email protected]

until now i used pthread_conditions within the same process
but now i have another scenario like a producer-consumer
what i want to do:
process 1 creates a shared memory and a binary semaphore for it (to make a mutex)
process 2 (the producer) writes in the shared memory
so my problem now is: how can i notify process 1 that process 2 wrote something in the memory?
i thought about signals and i'm sure it will work somehow
but since a mutex is a semaphore (afaik), a condition should be possible

Q: how can i use pthread_conditions using my own semaphore or how do conditions work? (sem_wait? sem_timedwait? does a condition use 2 semaphores? (the mutex and the condition?))

i know there are other possiblities (pipe's, message queues, signals(maybe i'll use it, but what if i have more than one producer? who signaled me?)) but since i have a semaphore i thought about using it for this

[email protected]

Offline

#2 2006-10-09 04:29 AM

mlampkin
Administrator
From: Sol 3
Registered: 2002-06-12
Posts: 911
Website

Re: how to implement pthread_conditions using my own binary semaphore?


"The only difference between me and a madman is that I'm not mad."

Salvador Dali (1904-1989)

Offline

  • Index
  • » Threads
  • » how to implement pthread_conditions using my own binary semaphore?

Board footer

Powered by FluxBB