Solved

Inter process communication

Posted on 1999-01-06
3
214 Views
Last Modified: 2013-12-26
I am working on project which require porting of Win-NT code on Mac. I am using Metrowoks CodeWarrior. It's pure C++ code.
The problem is that I need to perform Multithreading and the the two threads need to communicate with each other since they are sharing the same resource i.e. data buffer. Can anyone suggest me the way to perform this communication (something like Mutex objects in Windows)?
0
Comment
Question by:deep_blue
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
boonstra earned 50 total points
ID: 1291699
I don't know of a direct port for Mutex, but two things you want to look at are the Thread Manager and the Event Manager.  The Thread Manager handles thread creation, scheduling, and critical sections.  The SDK, including documentation, and sample code are provided at:
  <http://developer.apple.com/techpubs/macos8/OSSvcs/ThreadManager/threadmanager.html>

Interprocess communication is handled by the Apple Event Manager.  Documentation and sample code are at:
<http://developer.apple.com/techpubs/macos8/InterproCom/AppelEventManager/appleeventmanager.html>
Although most often used for interapplication communication, it can also be used to communicate between threads within an application.

If you don't want to use Apple Events, you can certainly use a shared memory area protected by a semaphore to do the interthread communications.
0
 

Author Comment

by:deep_blue
ID: 1291700
Thank you for answer can you find any sample code for using AppleEvents for InterProcess communication since the the URL suggested by you talks about InterApplication Communication
0
 
LVL 3

Expert Comment

by:boonstra
ID: 1291701
I didn't find any sample code using Apple Events for inter-thread communication.  I could probably write one, but not for 50 points.  :-)

However, the process for sending and processing Apple Events is largely the same for intraapplication communication; you simply specify yourself as the target.  See Inside Macintosh: Interapplication Communication, pg 5-10.  (IM:IAC is available at <http://developer.apple.com/techpubs/mac/IAC/IAC-2.html>

For sample code using shared memory and semaphores and/or critical sections to communicate between threads, see the examples in the Thread Manager SDK, including the Dining Philosophers example and the Single Intersection example.

Hope this helps.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question