comp.lang.ada
 help / color / mirror / Atom feed
* I/O dispatching, or custom interrupt handling
@ 2004-04-17 21:11 Florian Weimer
  0 siblings, 0 replies; only message in thread
From: Florian Weimer @ 2004-04-17 21:11 UTC (permalink / 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.



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-04-17 21:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-17 21:11 I/O dispatching, or custom interrupt handling Florian Weimer

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