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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,CP1252 X-Google-Thread: 103376,693aa3845ca32c66 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-07-23 15:19:40 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!arclight.uoregon.edu!wn13feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi_feed4!attbi.com!rwcrnsc51.ops.asp.att.net.POSTED!not-for-mail Message-ID: <3F1F09FA.8070309@attbi.com> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Priority Ceiling References: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 66.31.71.243 X-Complaints-To: abuse@comcast.net X-Trace: rwcrnsc51.ops.asp.att.net 1058998779 66.31.71.243 (Wed, 23 Jul 2003 22:19:39 GMT) NNTP-Posting-Date: Wed, 23 Jul 2003 22:19:39 GMT Organization: Comcast Online Date: Wed, 23 Jul 2003 22:19:39 GMT Xref: archiver1.google.com comp.lang.ada:40733 Date: 2003-07-23T22:19:39+00:00 List-Id: Stephan Heinemann wrote: > Now the questions: > (1) > If I understood correctly then the task priority should be raised to the > ceiling priority of the protected object (immediate ceiling priority > protocol). However, I cannot obtain this new active priority using > "Get_Priority(Current_Task)"; the base priority is returned instead. Why? Because that is the way Get_Priority is defined: D.5(8): "The function Get_Priority returns T's current base priority." If you think about it any other definition would be unfriendly. > (2) > The procedure "Priorities" would run with default priority (15) if > pragma Priority(0) was not given. But this change seems to affect the > defined tasks as well, eventhough they have their own base priorities > assigned to them. Do they inherit their priorities from the > "Priorities"-executing task, if they are assigned lower base priorities > than the latter? That is actually about a dozen questions... First, the procedure "Priorities" will only run with a priority other than the default if it is the main program, the main program contains a pragma Priority, or Priorities is called by a task with a non-default priorty. To turn that around in a way that makes sense, a pragma Priority in the main program can set the priority of the environment task. At any other point, the priority of a subprogram is the (current) priority of the task it is executing in. Next D.1(21): "During activation, a task being activated inherits the active priority that its activator (see 9.2) had at the time the activation was initiated." In other words, during task creation the task runs with the priority of its creator. This allows a high-priority task to create a lower-priority task without having to wait for that process to complete. After that a task will run with its own priority, except when it inherits a higher priority during a rendezvous, or runs at the priority ceiling of a protected object, or when its priority is changed (or set) by a call to Ada.Dynamic_Priorities.Set_Priority. Note that with pragma Locking_Policy(Ceiling_Locking) the ceiling priority of a protected object is, by default, Priority'Last, but it can be set as high as Interrupt_Priority'Last. (And is not less than Interrupt_Priority'First if a pragma Interrupt_Handler or Attach_Handler appears in the protected object.) A task that attempts to call an entry, procedure, or function of a protected object whose ceiling is less than the current priority of the task, Program_Error will be raised. So if you try to play with this stuff without design tool support it gets hard fast. The tools can tell you the base priority of each task, the highest priority it will inherit, and any case where it might violate a priority ceiling. Of course, you can use Set_Priority with run time computed values to confuse the best of priority inheritance design tools. Of course, tasking design tools is not my area of experitise, so maybe some other posters will recommend some. -- Robert I. Eachus �In an ally, considerations of house, clan, planet, race are insignificant beside two prime questions, which are: 1. Can he shoot? 2. Will he aim at your enemy?� -- from the Laiden novels by Sharon Lee and Steve Miller.