Solved

Inter process communication

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
windows 10 how make picture as desktop background 2 72
sameEnds challenge 3 195
EvenOdd challenge 10 160
ERP and the other system process verification 5 25
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

732 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