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 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: =?iso-8859-1?Q?GNAT=A0and?= Tasklets Date: Thu, 18 Dec 2014 10:36:48 +0100 Organization: cbb software GmbH Message-ID: References: <455d0987-734a-4505-bb39-37bfd1a2cc6b@googlegroups.com> <8277a521-7317-4839-b0b6-97f8155be1a4@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: YGNMlxhiQ90vAyH0QA4qPw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:24104 Date: 2014-12-18T10:36:48+01:00 List-Id: On Thu, 18 Dec 2014 00:56:30 -0800 (PST), vincent.diemunsch@gmail.com wrote: > Le jeudi 18 décembre 2014 09:41:53 UTC+1, Dmitry A. Kazakov a écrit : >> On Wed, 17 Dec 2014 22:31:57 +0200, Niklas Holsti wrote: >> >>> As Brad said, another purpose is to separate logical threads >>> of control, and I would add a third purpose, which is to prioritize >>> tasks of different urgencies, for real-time systems. >> >> This is a very important point. >> >> In my branch of work (data/event driven architectures) a great deal of >> things could be designed much easily and safely if state machines were >> replaced by a logical chain of control ("task"). It would not mean a >> separate physical task behind. Actually in most cases it is just few >> physical tasks and thousands of logical tasks scheduled by events. >> >> If Ada supported this (co-routines) it would greatly simplify I/O, GUI, Web >> designs. >> > What is a "physical task" and a "logical task" ? > For me : > - a task is a "logical task", because it is a concept of the Ada langage. > - a thread is what you call a "physical task", because it is an OS feature. RM mingles task and thread: "The execution of an Ada program consists of the execution of one or more tasks. Each task represents a separate thread of control that proceeds independently and concurrently between the points where it interacts with other tasks." RM 9(1) Your "thread" is an implementation of a task. > And if there should be a clear rule inside the Ada langage I would argue for > a simple rule like : > - tasks (and task types) declared at Library level are mapped to kernel threads Why? One is about visibility, scope, elaboration another is about scheduling. Scheduling by OS is IMO not related to the scope. > - tasks (and task types) declared localy are mapped to simple jobs spawned to a > pool of tasks. > > And add the use of pragma, or aspects, for special cases (GPU...) I don't think pragma would be enough. It is all about scheduling. Physical tasks are scheduled by timer interrupts or other steady event sources, which makes task interactions, such as rendezvous, more or less reliable. The case of co-routines scheduling is different because the driving events (new data are here, GUI event signaled, HTTP multipart chunk received) are no more *independent*. If scheduling is not independent then tasks are not. Note, the RM's definition, which mentions independence. It is not only things like task-owned objects and state. It is also the concept that a task can be preempted without behavior change. This is less true for co-routines which are less "task" in this sense. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de