comp.lang.ada
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
Subject: I/O dispatching, or custom interrupt handling
Date: Sat, 17 Apr 2004 23:11:46 +0200
Date: 2004-04-17T23:11:46+02:00	[thread overview]
Message-ID: <877jwe71il.fsf@deneb.enyo.de> (raw)

I'm looking for a way to use I/O dispatching (provided by poll(2) or
WaitForMultipleObjects()) and task entries together.  In some way,
this resembles a custom interrupt facility.

For example, a gateway which passes data back and forth between a
client and a server (over full-duplex connections) could be structured
like this:

   task type Server is
      entry Client_Activity (Socket : File_Descriptor);
      entry Server_Activity (Socket : File_Descriptor);
      entry Statistics (Requests, Clients : out Natural);
   end Server;

   task body Server is
   begin
      loop
         select
            accept Client_Activity (Socket : File_Descriptor) do
               --  Do something when data from the client arrives.
               null;
            end;
         or
            accept Server_Activity (Socket : File_Descriptor) do
               --  Do something when data from the server arrives.
               null;
            end;
         or
            accept Statistics (Requests, Clients : out Natural) do
               Requests := 0;
               Clients :=0;
            end;
         end select;
      end loop;
   end Server;

This example does not include the attach/detach operations which
control which file descriptory activity is signaled on which entry.
I use a task (and not a protected object) because more than one
gateway should run in the same process.

If Server only had to wait for file descriptor activity, it would be
easy.  I'd just call the appropriate system call (probably poll(2)).
However, I can't do that if I want to have other entries, too.

I wonder how I could implement this efficiently.  Obviously, I need
some dispatcher task which performs the actual call to poll(2), and
protected objects that record pending file descriptor activity (Server
might not be able to accept the entry call at once, but the dispatcher
task must not block).  And I need hand-written wrapper procedures for
the Client_Activity and Server_Activity entries because there is no
way to refer to these entries directly, using access values or
generics.

-- 
Current mail filters: many dial-up/DSL/cable modem hosts, and the
following domains: atlas.cz, bigpond.com, postino.it, tiscali.co.uk,
tiscali.cz, tiscali.it, voila.fr.



                 reply	other threads:[~2004-04-17 21:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox