comp.lang.ada
 help / color / mirror / Atom feed
From: Michal Nowak <vinnie@inetia.pl>
Subject: Re: Multitasking
Date: Sat, 07 Dec 2002 15:10:11 +0100
Date: 2002-12-07T15:10:11+01:00	[thread overview]
Message-ID: <mailman.1039269662.25846.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: <8bRwOT7FACB@lemmies.lb.bawue.de>

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
--
-- -----------------------------------------------------------------




  parent reply	other threads:[~2002-12-07 14:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-12-07 12:16 Multitasking arvids lemchens
2002-12-07 14:09 ` Multitasking SteveD
2002-12-09  7:43   ` Multitasking arvids lemchens
2002-12-07 14:10 ` Michal Nowak [this message]
2002-12-09  9:57   ` Multitasking arvids lemchens
2002-12-09 22:27     ` Multitasking Michal Nowak
2002-12-07 21:33 ` Multitasking Dennis Lee Bieber
2002-12-08  0:17   ` Multitasking Dennis Lee Bieber
2002-12-09  9:54     ` Multitasking arvids lemchens
2002-12-09 20:48       ` Multitasking Dennis Lee Bieber
2002-12-11 12:45         ` Multitasking John English
2002-12-11 19:34           ` Multitasking Dennis Lee Bieber
replies disabled

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