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=unavailable autolearn_force=no version=3.4.4 Path: border2.nntp.dca1.giganews.com!nntp.giganews.com!news.glorb.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!fx09.iad.POSTED!not-for-mail From: Brad Moore User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Structure of the multitasking server References: <8b4d1170-22e6-40d3-8ed1-096dc0163491@m36g2000hse.googlegroups.com> <71b51c8e-6bed-4156-9f52-31bef57b8575@googlegroups.com> <871tktuc9i.fsf@adaheads.sparre-andersen.dk> <87egoqmxa8.fsf@adaheads.sparre-andersen.dk> In-Reply-To: <87egoqmxa8.fsf@adaheads.sparre-andersen.dk> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 68.145.219.148 X-Complaints-To: internet.abuse@sjrb.ca X-Trace: 1426435445 68.145.219.148 (Sun, 15 Mar 2015 16:04:05 UTC) NNTP-Posting-Date: Sun, 15 Mar 2015 16:04:05 UTC Date: Sun, 15 Mar 2015 10:04:12 -0600 X-Received-Bytes: 2483 X-Received-Body-CRC: 509592203 Xref: number.nntp.giganews.com comp.lang.ada:192484 Date: 2015-03-15T10:04:12-06:00 List-Id: On 15-03-15 03:21 AM, Jacob Sparre Andersen wrote: > J-P. Rosen wrote: > >> If you give the producer a lower priority than the workers, it will be >> activated only when workers are done, and busy waiting is no more a >> problem. I use this approach in the Ravenscar Paraffin libraries. Note though, that this approach only works on real-time systems, which implement the priority model. Linux (and Windows) for example by default doesn't do this, so the spinning of the lower priority task can interfere with the higher priority tasks running on the same core. If you are using a flavor of Linux that has been configured for real-time then you should be able to rely on this behaviour. See https://rt.wiki.kernel.org/index.php/RT_PREEMPT_HOWTO#About_the_RT-Preempt_Patch Otherwise, this approach doesn't really work (it works but inefficient because CPU is wasted on spinning), so you should use blocking instead of spin waiting. In Paraffin, I provide two versions of Ravenscar libraries (one blocking, and one spinning), so that you can use whichever version best suits your OS. Brad > > Nice solution. :-) > > Greetings, > > Jacob >