comp.lang.ada
 help / color / mirror / Atom feed
From: "Steve" <nospam_steved94@comcast.net>
Subject: Re: Tasking issues
Date: Sat, 11 Aug 2007 15:31:40 -0700
Date: 2007-08-11T15:31:40-07:00	[thread overview]
Message-ID: <QNSdnSpI2NgVpSPbnZ2dnUVZ_o2vnZ2d@comcast.com> (raw)
In-Reply-To: 1186851804.567302.223160@q4g2000prc.googlegroups.com

Shaun,

Take a look at:  http://en.wikibooks.org/wiki/Ada_Programming/Tasking

There is an example of a Protected_Buffer that is along the lines of what 
you need.

I worked with several other systems using multi-tasking (multi-threading or 
whatever they decide to call it this year) before learning Ada.  At first I 
found Ada tasking difficult to understand.  It turns out Ada tasking is 
really very simple.  Simpler than any other tasking I've used, and I like it 
a lot more.

There are two basic objects assosciated with tasking: task types and 
protected objects.  There are a few constructs that go along with these 
types "entry", "accept", "select", "delay", "requeue", and "terminate" (I 
probably missed one or two).  Once you understand the basics of what they 
do, tasking is easy.

Regards,
Steve
(The Duck)


<shaunpatterson@gmail.com> wrote in message 
news:1186851804.567302.223160@q4g2000prc.googlegroups.com...
> I'm having trouble with tasking in Ada.  I'm used to working with
> pthreads
> in C/C++... and I'm finding tasks to be somewhat different/annoying.
>
> My basic problem is I want to have 2 threads in my program.
>
> One thread sits in the background and reads in messages,
> dispatches them, etc and the other thread reads off a queue
> and sends out messages when they are available.
>
> As an analogy, let's assume my background task just got
> input from the user (simulating the socket read) and the other
> task just printed out stuff.
>
> Something like
>
> procedure main is
> begin
>  task get_name;
>  task print_something;
>
>  task body get_name is
>      Name : String (1..25);
>      Last : Integer;
>  begin
>      loop
>          Get_Line (Name, Last);
>      end loop;
>  end get_name;
>
>  task body print_something is
>  begin
>      loop
>      Put_Line ("blah...");
>      end loop;
>   end print_something;
>
> begin --- main
>
>     loop;
>          null;
>     end loop;
> end main;
>
>
> Of course, this doesn't work as I'd expect.  Is there a way to
> "timeout" the
> first get_name thread... so the OS only waits on that thread for a
> short period
> of time to allow the other threads to do their business? and then go
> back to
> the thread?
>
> Thanks
> -- Shaun
> 





  parent reply	other threads:[~2007-08-11 22:31 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-11 17:03 Tasking issues shaunpatterson
2007-08-11 18:42 ` Dmitry A. Kazakov
2007-08-12 11:06   ` Simon Wright
2007-08-12 12:05     ` Dmitry A. Kazakov
2007-08-12 17:12       ` shaunpatterson
2007-08-12 18:03         ` Dmitry A. Kazakov
2007-08-12 22:10         ` Jeffrey R. Carter
2007-08-13 19:54         ` Simon Wright
2007-08-13 22:30           ` shaunpatterson
2007-08-14  7:10             ` Tasking issues => Book List anon
     [not found]     ` <13bulskfjvogv8e@corp.supernews.com>
2007-08-12 20:20       ` Tasking issues Simon Wright
2007-08-11 18:51 ` jimmaureenrogers
2007-08-11 19:08 ` Jeffrey R. Carter
2007-08-11 22:31 ` Steve [this message]
2007-08-12  9:00 ` anon
2007-08-12  9:43   ` Dmitry A. Kazakov
2007-08-12 21:39     ` anon
2007-08-12 22:15       ` Jeffrey R. Carter
2007-08-13  9:13         ` anon
2007-08-13 19:37           ` Simon Wright
2007-08-13 20:17             ` Markus E.L. 2
2007-08-14  0:40           ` Jeffrey R. Carter
2007-08-13  9:22       ` Dmitry A. Kazakov
2007-08-13 12:41         ` Larry Kilgallen
2007-08-13 13:22           ` Dmitry A. Kazakov
2007-08-12 21:03   ` Maciej Sobczak
2007-08-12 22:07   ` Jeffrey R. Carter
replies disabled

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