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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,8d7b1d8587f412a5 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!94.232.116.13.MISMATCH!feed.xsnews.nl!border-3.ams.xsnews.nl!weretis.net!feeder2.news.weretis.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Task Priorities on Ubuntu Linux Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Wed, 9 Dec 2009 16:10:40 +0100 Message-ID: NNTP-Posting-Date: 09 Dec 2009 16:10:30 CET NNTP-Posting-Host: 0cd966a9.newsspool2.arcor-online.net X-Trace: DXC=Lc799`hOZGZV;Ef1`Jk54\A9EHlD;3YcR4Fo<]lROoRQ8kF_[P]mB`6GMCS X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:8359 Date: 2009-12-09T16:10:30+01:00 List-Id: On Wed, 9 Dec 2009 06:34:45 -0800 (PST), singo wrote: > When I use different task priorities I get an - at least for me - > unexpected behavior... I have defined 10 tasks with different > priority. When I run my program, I expect only one task per processor > (this means four on my quad-core machine) to run. However, > unexpectedly all 10 tasks are run on my machine. > > Is this because the tasks are mapped on the underlying OS (here > Linux), which then instead schedules the tasks of different priority > with some kind of time-slicing (round-robin) approach? I would > appreciate some clarification in this matter. No, there could be a different reason from that. You perform I/O, which leads to task switching. Once I/O is initiated the OS completes it anyway (if the kernel is non-preemptive for your tasks). This is what you observed. I guess. Try this instead: pragma Task_Dispatching_Policy (FIFO_Within_Priorities); pragma Queuing_Policy (Priority_Queuing); with Ada.Text_IO; use Ada.Text_IO; with Ada.Real_Time; use Ada.Real_Time; procedure TaskPriorities is task type T (Id: Integer) is pragma Priority (Id); end; task body T is I : Integer; begin Put (Integer'Image (Id)); for Index in Integer'Range loop I := Index; end loop; end T; Task10 : T (11); Task9 : T (12); Task8 : T (13); Task7 : T (14); Task6 : T (15); Task5 : T (16); Task4 : T (17); Task3 : T (18); Task2 : T (19); Task1 : T (20); begin null; end TaskPriorities; It should print 20 19 (on two cores), then you would like to reset your computer, if under Windows, because there non-preemptive priorities are the real-time ones. They override pretty much everything, unless tasks end you will have to reboot. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de