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=-1.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID 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: dbotton@hotmail.com Subject: Re: Tasks and C/C++ code. Date: 1998/11/11 Message-ID: <72b35b$pll$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 410574913 References: <364702E5.F6987321@hiwaay.net> <729ndu$jfo$1@nnrp1.dejanews.com> X-Http-Proxy: 1.1 x6.dejanews.com:80 (Squid/1.1.22) for client 199.227.148.130 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Wed Nov 11 04:17:47 1998 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; MSN 2.5; Windows 98) Date: 1998-11-11T00:00:00+00:00 List-Id: 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