Solved

Inter process communication

Posted on 1999-01-06
3
165 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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 …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 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

8 Experts available now in Live!

Get 1:1 Help Now