From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5d05ccde5cefb836 X-Google-Attributes: gid103376,public From: "Barry L. Dorough" Subject: Re: Tasks and C/C++ code. Date: 1998/11/11 Message-ID: <3649A4C4.4D3D22A2@hiwaay.net>#1/1 X-Deja-AN: 410716232 Content-Transfer-Encoding: 7bit References: <364702E5.F6987321@hiwaay.net> <729ndu$jfo$1@nnrp1.dejanews.com> <72b35b$pll$1@nnrp1.dejanews.com> Content-Type: text/plain; charset=us-ascii Organization: Renaissance Internet Services Mime-Version: 1.0 Reply-To: bdorough@phaseiv.com Newsgroups: comp.lang.ada Date: 1998-11-11T00:00:00+00:00 List-Id: So, if I understand correctly defining the pragma to C in the declaration part of the task body will give me multiple binding to the same function if there are multiple tasks? If this is correct what happens when you write an Ada procedure/function in a task? Does each task get it own copy? I hope the answer is yes or I have completely misunderstood the Ada tasking model! dbotton@hotmail.com wrote: > I think it would be practical to create a protected type that wrapped your C > function to insure that it is not be run concurrently (if it isn't safe). If > it's safe then just call it as you would any other Ada Procedure/Function. > > David Botton > > dennison@telepath.com wrote: > > In article <364702E5.F6987321@hiwaay.net>, > > bdorough@phaseiv.com wrote: > > > I am working on a project where we need to call the same C function > > > from multiple tasks. I am wondering how to do this safely. Can I make > > > a generic with my C pragma defined there are do I need to define the > > > prama in the task type so each task will have its own copy of the C > > > function. > > > > If the C function truly isn't safe to call from multiple threads (iaw: relies > > on global data, "static" local declarations, or calls other non-thread safe > > routines) then you have to ensure that calls to it happen from only one > > thread. The safest way to do it is to make *one* server task responsible for > > calling the routine and returning its results. Client tasks rendezvous with > > the server task to request a call to the unsafe C routine. This is the method > > used in at least one set of X/Motif Ada bindings. > > > > > > -- > > T.E.D. > > > > -----------== Posted via Deja News, The Discussion Network ==---------- > http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own