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: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: confusion about message passing between the tasks Date: Sat, 25 Oct 2014 09:13:04 +0200 Organization: A noiseless patient Spider Message-ID: <87lho4ei67.fsf@ludovic-brenta.org> References: <87tx2te2hz.fsf@ludovic-brenta.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="f51eff624ce5a87c6ebf9332dd27f01f"; logging-data="31862"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+bAOwxoadDpG38GahrzDVj" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:Xa4r+oWUKN4jJDA10Mrn0OO27cc= sha1:+DjovPRqGvJKTVjpYs0P+Zrdwvc= Xref: news.eternal-september.org comp.lang.ada:22719 Date: 2014-10-25T09:13:04+02:00 List-Id: compguy45@gmail.com writes: > In those directories all example are graphics example. Which directory > is one that creates N tasks? The directories 1..5 all contain different versions of the same graphical program. Version 1: no tasks. Version 2: N tasks, race condition when multiple tasks want to draw using a shared graphics context. Version 3: race condition solved by placing the graphics context in a protected object. But the problem now, with 10_000 tasks, is excessive virtual memory consumption (8 MiB of stack per task), which luckily does not translate into physical memory usage, at least on Linux. Version 4: Introduce a task queue. Now the number of tasks is independent on the number of rectangles. But there is still a problem; a deadlock exists when one task A finds that there remains a rectangle in the queue but another task B gets to dequeue it first. Then A tries to dequeue the last rectangle but waits forever as the queue is now empty. As a consequence the master task waits forever for A to complete. Version 5: deadlock solved by a select statement. -- Ludovic Brenta.