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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,126ce244c524526b X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 11 Aug 2007 17:30:32 -0500 From: "Steve" Newsgroups: comp.lang.ada References: <1186851804.567302.223160@q4g2000prc.googlegroups.com> Subject: Re: Tasking issues Date: Sat, 11 Aug 2007 15:31:40 -0700 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 X-RFC2646: Format=Flowed; Original Message-ID: X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 24.20.111.206 X-Trace: sv3-lKtJrit8UA/xET/x0MnLRy/l/271AnTgRd4PLuWsMCK2LxxV+MM8Mk30XUeMGk2DL18TlAAOsY0jaIl!oy3VmoV1WW211qmISZ5LWiTEF2mOtg/YaIYdbyKalE1IllsDFnUZ6SYwIoI1Skh0hTB4pkL8Q18M!kvLzye3dH9th7aoqHABt9+HLb/pFtQ== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.35 Xref: g2news2.google.com comp.lang.ada:1404 Date: 2007-08-11T15:31:40-07:00 List-Id: 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) 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 >