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,37ba7a408adb23df,start X-Google-Attributes: gid103376,public From: csampson@cod.nosc.mil (Charles H. Sampson) Subject: Confused About Task Priorities (Ada 83) Date: 1998/02/25 Message-ID: <1998Feb25.230411.14969@nosc.mil>#1/1 X-Deja-AN: 328665757 Sender: news@nosc.mil Organization: Computer Sciences Corporation Newsgroups: comp.lang.ada Date: 1998-02-25T00:00:00+00:00 List-Id: I'm very confused in an area of Ada 83 that I thought I knew pret- ty well: Task priorities. I'm working on an old, poorly-documented program that is compiled with an obsolete compiler. The project has dropped its compiler maintenance contract because there's nobody left at the company who can answer questions about it anymore. There are indi- cations in the source code that preemptive task scheduling is not the default. These indications are non-standard calls to the real-time ex- ecutive that explicitly turn preemption on. (I'm talking true preemp- tion here, tasks of different priorities, not time-slicing.) I wrote a little program to see if preemption is the default or not. I have three compilers available and I'm getting my expected re- sults for only one of them. Here's the program, with a lot of what I think is extraneous mate- rial cut out. That material can be supplied if anyone thinks it's needed. WITH Calendar; USE Calendar; PROCEDURE New_test IS -- Declarations for storing the time information are here PROCEDURE Busy_wait (Length : IN Duration) IS ... -- Busy_wait loops until it chews up approximately the number of -- CPU seconds given by Length TASK Low IS ENTRY Start; ENTRY Finish; PRAGMA Priority (6); END Low; TASK Medium IS ENTRY Start; ENTRY Finish; PRAGMA Priority (7); END Medium; TASK High IS ENTRY Start; ENTRY Finish; PRAGMA Priority (8); END High; TASK BODY Low IS BEGIN ACCEPT Start DO Low_start := Clock; END Start; Low_start_busy := Clock; Busy_wait (4.0); Low_end_busy := Clock; ACCEPT Finish; END Low; TASK BODY Medium IS BEGIN ACCEPT Start DO Medium_start := Clock; END Start; Medium_start_low := Clock; Low.Start; Medium_start_busy_1 := Clock; Busy_wait (5.0); Medium_start_high := Clock; High.Start; Medium_start_busy_2 := Clock; Busy_wait (6.0); Medium_end_busy_2 := Clock; ACCEPT Finish; END Medium; TASK BODY High IS BEGIN ACCEPT Start DO High_start := Clock; END Start; High_start_busy := Clock; Busy_wait (7.0); High_end_busy := Clock; ACCEPT Finish; END High; BEGIN Medium.Start; Low.Finish; Medium.Finish; High.Finish; -- Code to print out the time snapshots appears here END New_test; Here's the behavior I expect: Medium starts and snapshots its starting time. Medium snapshots the time and starts Low. Low starts and snapshots its starting time while the rendezvous executes at priority 7. After the rendezvous, Low and Medium are ready to run, so Medium snapshots the time and begins executing its first busy wait. After Medium executes its busy wait it snapshots the time and starts High. High starts and snapshots its starting time while the rendezvous executes at priority 8. After the rendezvous, Low, Medium, and High are ready to run, so High snapshots the time and starts its busy wait. After High finishes its busy wait it snapshots the time and sus- pends at its accept statement for Finish. Medium and Low are now ready to run, so Medium snapshots the time, executes its second busy wait, snapshots the time, and suspends at its accept statement for Finish. Now Low is the only task ready to run, so it snapshots the time, executes its busy wait, and suspends at its accept statement for Finish. Am I right or wrong? For the two compilers that don't show the expected behavior, the indications are that Low and Medium are timeslic- ing while Medium is executing its first busy wait. (Low finishes its busy wait before Medium finishes its.) When we get to the point of Med- ium starting High, Low is already finished and High takes priority over Medium, as I expect. Charlie -- ****** If my user name appears as "csampson", remove the 'c' to get my correct e-mail address.