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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!k17g2000yqh.googlegroups.com!not-for-mail From: singo Newsgroups: comp.lang.ada Subject: Re: Task Priorities on Ubuntu Linux Date: Thu, 10 Dec 2009 00:27:47 -0800 (PST) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 130.237.215.68 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1260433667 31363 127.0.0.1 (10 Dec 2009 08:27:47 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 10 Dec 2009 08:27:47 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k17g2000yqh.googlegroups.com; posting-host=130.237.215.68; posting-account=YaFpXwoAAABFpcqmE2M-zOfwgB6wr6kC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091109 Ubuntu/9.10 (karmic) Firefox/3.5.5,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:8362 Date: 2009-12-10T00:27:47-08:00 List-Id: On Dec 9, 10:20=A0pm, sjw wrote: > On Dec 9, 2:34=A0pm, singo wrote: > > > > > Hi, > > > Another question on the real-time annex and its implementation in > > gnat-4.3 (Ubuntu Linux). > > > 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. > > > Best regards > > > Ingo > > > P.S: Here comes my example program: > > > 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 > > > =A0 =A0task type T(Id: Integer) is > > =A0 =A0 =A0 pragma Priority(Id); > > =A0 =A0end; > > > =A0 =A0task body T is > > =A0 =A0begin > > =A0 =A0 =A0 loop > > =A0 =A0 =A0 =A0 =A0Put(Integer'Image(Id)); > > =A0 =A0 =A0 end loop; > > =A0 =A0end T; > > > =A0 =A0Task10 : T(11); > > =A0 =A0Task9 =A0: T(12); > > =A0 =A0Task8 =A0: T(13); > > =A0 =A0Task7 =A0: T(14); > > =A0 =A0Task6 =A0: T(15); > > =A0 =A0Task5 =A0: T(16); > > =A0 =A0Task4 =A0: T(17); > > =A0 =A0Task3 =A0: T(18); > > =A0 =A0Task2 =A0: T(19); > > =A0 =A0Task1 =A0: T(20); > > > begin > > =A0 =A0null; > > end TaskPriorities; > > It used to be that on Linux you would have to run as root for > specified priorities to be respected. > > FWIW, on Mac OS X Dmitry's program behaves much the same as an > ordinary user and as root: variously, > > $ ./taskpriorities > =A011 13 12 15 14 18 17 20 19^C > $ ./taskpriorities > =A019 20 18 16 14^C > $ ./taskpriorities > =A019 20 18 17^C > $ sudo ./taskpriorities > Password: > =A019 20 18 16 14^C Thanks a lot for the information! Yes, you are right! In order to get a correct behavior I have to run the program as root (which I was not aware of). I made a small change of Dimitri's program (I moved the 'Put' statement after the loop), i.e. task body T is I : Integer; begin for Index in Integer'Range loop I :=3D Index; end loop; Put (Integer'Image (Id)); end T; and then I get the following expected output: On a machine with four cores: > sudo ./taskpriorities 17 18 20 19 16 15 14 13 12 11 On a machine with one core: > sudo ./taskpriorities 20 19 18 17 16 15 14 13 12 11 Best regards Ingo