Solved

Inter process communication

Posted on 1999-01-06
3
173 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

914 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now