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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e44790cdcea9da82 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!fu-berlin.de!uni-berlin.de!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Problem with -gnatt Date: Tue, 19 Oct 2004 09:36:43 +0200 Message-ID: <4174C40B.8070906@mailinator.com> References: <41651D37.4030805@mailinator.com> <2skt9qF1ljjdtU1@uni-berlin.de> <4165472D.2030704@mailinator.com> <416573FA.4010003@mailinator.com> <87k6u2mj08.fsf@insalien.org> <4166538E.6090907@mailinator.com> <41702af7$0$91003$39cecf19@news.twtelecom.net> <417377F7.7050506@mailinator.com> <4173f0ed$0$91003$39cecf19@news.twtelecom.net> <417409AB.8040702@mailinator.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de JNmHRwn8dZotkxI4oo9F6g010qVtkULfwD/LKZHSXfwcWXgz8= User-Agent: Mozilla Thunderbird 0.8 (X11/20040913) X-Accept-Language: en-us, en In-Reply-To: Xref: g2news1.google.com comp.lang.ada:5434 Date: 2004-10-19T09:36:43+02:00 List-Id: Matthew Heaney wrote: > "Alex R. Mosteo" writes: > >>I know the RM advice but, is there any special reason why it's better >>to wait for a semaphore instead of a protected object? I don't need >>timeouts nor abort semantics, I'll just wait what it is needed. > > > I think it has something to do with the overhead of acquiring the lock, > either by boosting the priority of the task executing the protected > action, or because spinlocks are used, etc. It isn't that contradictory? If locking is costly in a protected object, using it for very frequent, very short actions seems pointless. It indeed will suggest to use it for rare, longer occurrences. What's a spinlock? > You also have to make sure that you don't make any "potentially > blocking" calls during execution of the protected action. (I don't > think you do in your example, but I didn't study it enough to be sure.) Yep. I have violated this rule somewhere else, consciously. Does this have something to do with the original problem? >>I already have a class like this, but I simply don't like manually >>putting semaphores around except for a good reason. Please enlighten >>me :) > > What do you have against semaphores? As long as you arrange for the > semaphore to get released (which you can do using a controlled helper > type, as in my example), then there's no reason not to use a semaphore. > My advice is to follow the RM's advice... I'd follow it blindly if it stated too that /don't/ following the advice could lead to program errors. If my memory serves right, that is not the case? Since it is simply an advice, I prefer to use a protected where all the services but one are short. I don't want to leave the powerful protected abstraction only because a sporadic use of one of its procedures may be a bit longer (which, furthermore, is still something fuzzy). I'm re-reading the ARM and can not find now the advice we are talking about. There is, however, a compelling reason to not use long protected subprograms in 9.5.1(19) which is busy waiting. Ucks! Kind regards, A. Mosteo.