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,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5c11488f5a203885 X-Google-Attributes: gid103376,public From: dennison@telepath.com Subject: Re: Imported Monolitic Monitor Date: 1999/03/05 Message-ID: <7bpgb7$bmm$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 451668499 References: <36E014CD.55717933@unex.es> X-Http-Proxy: 1.0 x14.dejanews.com:80 (Squid/1.1.22) for client 204.48.27.130 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Fri Mar 05 20:55:07 1999 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.5 [en] (WinNT; I) Date: 1999-03-05T00:00:00+00:00 List-Id: In article <36E014CD.55717933@unex.es>, "Juan Carlos =?iso-8859-1?Q?D=EDaz=20Mart=EDn?=" wrote: > Let's be the C procedures in a module that share global data > > a > b > c > > and I make a C library with them. This library will be used by a > multitasked Ada95 application by the pragma Import > > Tasks T, Q and R may invoke a, b or c in a concurrent, uncontrolled way. > Isn't it? I'm interested in a, b and c to be executed in mutual > exclusion to preserve global data integrity. The question is: How do I > do it in Ada95? > I've thought in a protected object, such as: > > protected Monitor is > procedure a; > procedure b; > procedure c; > end Monitor; > Does this way guarantee mutual exclusion of a, b and c??? Any ideas?? Yup, as long as everyone goes through the Monitor protected object to call a, b, and c. You could make this more transparent to users by just putting procedure calls in the spec of a "C" package. Put Monitor in the body, and have the body of the procedures call the protected procedures in Monitor. That way it looks just like normal procedure calls to everyone else. Of course if you are going to do it that way, it would be just as easy to create a simple lock using a protected object, and have the bodies of all the procedures acquire the lock, then call the imported procedure, then release the lock. T.E.D. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own