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: Mats Weber Subject: Re: Tasks and C/C++ code. Date: 1998/11/09 Message-ID: <3647052F.30852169@elca-matrix.ch>#1/1 X-Deja-AN: 409955184 Content-Transfer-Encoding: 7bit References: <364702E5.F6987321@hiwaay.net> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: ELCA Matrix SA Mime-Version: 1.0 Reply-To: Mats.Weber@elca-matrix.ch Newsgroups: comp.lang.ada Date: 1998-11-09T00:00:00+00:00 List-Id: "Barry L. Dorough" 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. Doing it either way won't change anything, the result will be exactly the same: there will be only one copy of the C function, possibly being called concurrently by more than one Ada task. What you have to make sure is that your C function is task-safe, or thread-safe in the pthreads terminology. Look at its use of global variables and non thread-safe system calls, among others (e.g. gethostbyname is generally not thread-safe).