comp.lang.ada
 help / color / mirror / Atom feed
From: Jean-Pierre Rosen <rosen@adalog.fr>
Subject: Re: Structure of the multitasking server
Date: Fri, 19 Sep 2008 15:34:00 +0200
Date: 2008-09-19T15:34:00+02:00	[thread overview]
Message-ID: <ho90bg.gnt.ln@hunter.axlog.fr> (raw)
In-Reply-To: <8b4d1170-22e6-40d3-8ed1-096dc0163491@m36g2000hse.googlegroups.com>

Maciej Sobczak a �crit :
> Hi all,
> 
> Imagine a server with fixed number of worker tasks. There is no queue
> of jobs and jobs are immediately passed to one of the tasks that is
> currently idle. There is a separate task (or just the main one) that
> provides jobs for worker tasks.
[...]

Why not simply use a rendezvous?
Each worker has an entry Get_Job:

     task body Worker_Task is
        Job : Job_Type;
     begin
        loop
           Get_Job (Job);

           --  do the job ...

        end loop;
     end Worker_Task;

and the server is simply (assuming Servers is an array of Worker_Task):

     loop
        Job := ...

        Found_Worker := False;
        for I in Servers'Range loop
           select
              Server (I).Get_Job (Job);
              Found_Worker := True;
              exit;
           else
              -- This server is busy
              null;
           end select;
        end loop;

        if not Found_Worker then
           --  all pipelines are busy,
           --  but the overflow handling is not shown...
        end if;
     end loop;
-- 
---------------------------------------------------------
            J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



  reply	other threads:[~2008-09-19 13:34 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-19 12:21 Structure of the multitasking server Maciej Sobczak
2008-09-19 13:34 ` Jean-Pierre Rosen [this message]
2008-09-19 17:02   ` Dmitry A. Kazakov
2008-09-21 17:30     ` Maciej Sobczak
2008-09-21 19:24       ` Dmitry A. Kazakov
2008-09-21 21:27         ` Maciej Sobczak
2008-09-22  8:12           ` Dmitry A. Kazakov
2008-09-22 12:47             ` Maciej Sobczak
2008-09-22 14:11               ` Dmitry A. Kazakov
2008-09-23  8:07                 ` Maciej Sobczak
2008-09-23  9:37                   ` Dmitry A. Kazakov
2008-09-23 10:47                   ` Jean-Pierre Rosen
2008-09-21 17:23   ` Maciej Sobczak
2008-09-22  8:23     ` Jean-Pierre Rosen
2015-03-12 16:07   ` gautier_niouzes
2015-03-12 21:38     ` Jacob Sparre Andersen
2015-03-12 22:39       ` gautier_niouzes
2015-03-13  8:15         ` Dmitry A. Kazakov
2015-03-13 20:16           ` gautier_niouzes
2015-03-13 20:47             ` Dmitry A. Kazakov
2015-03-15  7:43               ` gautier_niouzes
2015-03-15  8:35                 ` Simon Wright
2015-03-15  8:52                 ` J-P. Rosen
2015-03-15  9:21                   ` Jacob Sparre Andersen
2015-03-15 16:04                     ` Brad Moore
2015-03-13 23:04             ` Randy Brukardt
2015-03-14  8:22               ` Simon Wright
2008-09-19 23:01 ` anon
2008-09-21 17:37   ` Maciej Sobczak
2008-09-22  2:32     ` anon
2008-09-22 13:05       ` Maciej Sobczak
2008-09-23  9:25         ` anon
replies disabled

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