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.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5400c39557b9f344 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-07 06:01:13 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fr.clara.net!heighliner.fr.clara.net!teaser.fr!enst.fr!not-for-mail From: Michal Nowak Newsgroups: comp.lang.ada Subject: Re: Multitasking Date: Sat, 07 Dec 2002 15:10:11 +0100 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: <8bRwOT7FACB@lemmies.lb.bawue.de> Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7BIT X-Trace: avanie.enst.fr 1039269663 25220 137.194.161.2 (7 Dec 2002 14:01:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Sat, 7 Dec 2002 14:01:02 +0000 (UTC) Return-Path: In-reply-to: <8bRwOT7FACB@lemmies.lb.bawue.de> X-Mailer: Calypso Version 3.30.00.00 (3) Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.13 Precedence: bulk X-Reply-To: vinnie@inetia.pl List-Unsubscribe: , List-Id: comp.lang.ada mail<->news gateway List-Post: List-Help: List-Subscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:31527 Date: 2002-12-07T15:10:11+01:00 On 2002-12-07 at 13:16 lemchens@lemmies.lb.bawue.de wrote: >Hi, > >playing around with tasks, i have following: [task code removed] >begin > CList(1) := new TC; > Put("Start Task S at: "); > Put(Long_Long_Integer(Seconds(Clock))); > New_Line; > CList(1).S(60); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > Put("End Task S "); > Put(Long_Long_Integer(Seconds(Clock))); > New_Line; > Put("Start Task U "); > Put(Long_Long_Integer(Seconds(Clock))); > New_Line; > CList(1).S(120); > Put("End Task U "); -- <= You mean entry here not task? But look -- one line above, you called entry S there > Put(Long_Long_Integer(Seconds(Clock))); > New_Line; >end tt; >----- > >Output is: >----- >Start Task S at: 46831 >Task S finished at 46891 >End Task S 46891 >Start Task U 46891 >Task S finished at 47011 >End Task U 47011 >----- > >Now i am wondering why the maintask is waiting for the completion of >S and T and not going independent of them on? Entry is a synchronization mechanism. That means that it is used to synchronize two tasks with each other. The caller (in your code the main task) will not return until the entry is finished. So it looks like this: 1. the TC task is awaiting for one of its entries to be called 2. the main task reaches the line, which I marked and is blocked until the entry finishes 3. the TC task is executing its entry S 4. the TC task finshes executing its entry S and the control gets back to main task. >Am i missing something fundamental about ada-tasks? It looks that you do (don't take this as offence :-)) >If yes, what and how do i get them running independent? You did it. But what do you want to achieve with your code? One more note. You call I/O operations (Put) from the main task and the TC task to "write" on shared resource (screen). Because you sychronized the tasks, you got the I/O operations sequentially executed, but don't be astonished when you got mixed output from the tasks runing in parallel. You may use protected objects to lock the screen for the time of doing Put and unlock it after it. You will find more informations on tasks in Reference Manual, section 9. And also visit http://www.adapower.com/learn to get a list of on-line resources on Ada. Happy Ada programming, Michal -- ----------------------------------------------------------------- -- ___ _ -- / _ \ | | I Choose Ada: -- | |_| | ___| | _____ The Most Trusted Name in Software (TM) -- | _ | | __ | | __ | -- |_| |_| |_____|_ |_____|_ http://www.adaic.org/whyada/choose.html -- -- -----------------------------------------------------------------