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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,136c120daac2a1 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.maxwell.syr.edu!nntp.abs.net!news.abs.net!not-for-mail Newsgroups: comp.lang.ada Subject: Re: tasksing and TCP sockets References: <1138659171.491931.322480@g49g2000cwa.googlegroups.com> <1138747969.510279.15280@g49g2000cwa.googlegroups.com> From: Stephen Leake Message-ID: User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (windows-nt) Cancel-Lock: sha1:krf+adfO70kY5dPj5Y+tKQNkVQ4= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 31 Jan 2006 20:23:53 -0500 NNTP-Posting-Host: 66.159.65.1 X-Complaints-To: abuse@toad.net X-Trace: news.abs.net 1138757034 66.159.65.1 (Tue, 31 Jan 2006 20:23:54 EST) NNTP-Posting-Date: Tue, 31 Jan 2006 20:23:54 EST Xref: g2news1.google.com comp.lang.ada:2730 Date: 2006-01-31T20:23:53-05:00 List-Id: "Rolf" writes: > Stephen Leake wrote: >> "Rolf" writes: >> >> > In a stripped down version I can succesfully connect to the server >> > (using GNAT.Sockets) and either read the sensor data *or* write actor >> > data. The program is currently split in two tasks. One tasks contains >> > the application code and the actor communication (using >> > type_id'output(channel)). The second tasks gets started during program >> > initialisation. It reads the data from the socket via >> > type_id'input(channel) and provides the data to the application through >> > a protected object. >> > >> > The problem that I face is that the second task seems to starve the >> > first one. As soon as it is active, the application does not generate >> > debug output anymore. >> >> You need to set the priorities correctly, > > Does that mean e.g. to set the main task to 10 and the second task to > 5? Well, I don't know, since I don't know the details of your project. But it is likely that one should have a higher priority than the other. The default is for all tasks to have the same priority. >> and you need to ensure that >> there are no busy waits; the second task should be _suspended_ waiting >> on socket completions, not polling for them. > > How would I do that? I have no explicit busy wait, I use > > Var := Sensor_Cmd_T'Input (Channel); > > If possible, I'd like to keep that easy way of data input and avoid > explicit conversion and read commands. Hmm. I don't know how this maps to Read_Socket commands. I would guess that it waits for the number of Stream_Elements in Sensor_Cmd_T to be available. But it might wait longer than that, especially if Sensor_Cmd_T is unconstrained. You could do a Read_Socket into a Stream_Array, and then do 'Input from that. That would make it clearer when the task is suspended. >> > Some background info: gcc-3.4.4 on Windows XP. >> >> That may be a problem. I find the commercially supported GNAT to be >> less broken. > > This is a hobby project. Ok. >> > - how can I interrupt the waiting read task to force activity in the >> > main task? >> >> Depends on how it is waiting. If is in a GNAT.Sockets.Receive_Socket, >> you can't (short of shutting down the socket). So periodic polling >> might be better. > > I suppose it waits in the Sensor_Cmd_T'Input (Channel) routine, but I > am not sure. There is an option that expands tasking constructs into lower-level Ada code, and outputs the source. That may help here, to show what is going on. -- -- Stephe