Solved

Inter process communication

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sum67 challenge 35 97
fizzArray  challenge 1 81
changeXy challenge 13 81
firstChar challenge 13 114
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 …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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 gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

786 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