• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Using MIG RPC between 2 threads inside a process
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using MIG RPC between 2 threads inside a process


  • Subject: Re: Using MIG RPC between 2 threads inside a process
  • From: Dario <email@hidden>
  • Date: Thu, 16 Sep 2004 10:11:16 +0200

Il giorno 16/set/04, alle 09:56, Stéphane Letz ha scritto:


Moreover how can I tranfers messages between the 2 involved threads using condition variables? I though that it would need to use an intermediate queue of fifo? Using the Mac IPC allows directly to do that...

Do it in the process' memory? You have a pthread mutex, it can protect a private queue in addition to the condition variable.

Do you mean using "pthread_mutex" and "pthread_cond_signal/wait" API? How can this be done?



#include <pthread.h>

pthread_mutex_t lock;
pthread_cond_t cond;

pthread_cond_init( &cond, NULL );
pthread_mutex_init( &lock, NULL );


server: create client thread pthread_mutex_lock( &lock ); while(true) { pthread_cond_wait( &cond, &lock ); do something what you need }

	client:
while( true ) {
	pthread_mutex_lock( &lock );
	Put some data in a global varibale or so.
	pthread_cond_signal( &cond );
}

or can be resolved by using a queue structure with synchronized access and verification, I have an example if you need it. with this code as you can see you can send only one job and the client will block until the end of the previous



In fact, the condition variable is only interesting when the queue runs dry. This is always more efficient than trying to queue the memory in the kernel. Besides, you are limited to a queue depth of 16 (default 5) when you use Mach message queues. Not really much of a queue to store things in, when you think about it.

OK... Thanks

Stephane

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden


_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Using MIG RPC between 2 threads inside a process (From: Stéphane Letz <email@hidden>)
 >Re: Using MIG RPC between 2 threads inside a process (From: Jim Magee <email@hidden>)
 >Re: Using MIG RPC between 2 threads inside a process (From: Stéphane Letz <email@hidden>)

  • Prev by Date: Re: Using MIG RPC between 2 threads inside a process
  • Next by Date: Using MIG RPC between 2 threads inside a process
  • Previous by thread: Re: Using MIG RPC between 2 threads inside a process
  • Next by thread: Re: Using MIG RPC between 2 threads inside a process
  • Index(es):
    • Date
    • Thread