comp.lang.ada
 help / color / mirror / Atom feed
* Multitasking
@ 2002-12-07 12:16 arvids lemchens
  2002-12-07 14:09 ` Multitasking SteveD
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: arvids lemchens @ 2002-12-07 12:16 UTC (permalink / raw)


Hi,

playing around with tasks, i have following:

-----
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Long_Long_Integer_Text_IO; use Ada.Long_Long_Integer_Text_IO;

Procedure tt is

task type TC is
   entry S(D : Positive);
   entry T(U : Positive);
end TC;
task body TC is
begin
   loop
      select
         Accept S(D : In Positive) do
         delay Standard.duration(D);
	 Put("Task S finished at ");
	 Put(Long_Long_Integer(Seconds(Clock)));
	 New_Line;
         end S;
      or
         Accept T(U : In Positive) do
         delay Standard.duration(U);
	 Put("Task T finished at ");
	 Put(Long_Long_Integer(Seconds(Clock)));
	 New_Line;
         end T;
      or
         terminate;
      end select;
   end loop;
end TC;

type TCPtr is access TC;
type TList is array (Positive range <>) of TCPtr;
CList : TList(1..10000);

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 ");
   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?

Am i missing something fundamental about ada-tasks?

If yes, what and how do i get them running independent?

If it matters, i am using the linuxversion of gnat 3.14p.


MvfG,

Arvids







^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Multitasking
  2002-12-07 12:16 Multitasking arvids lemchens
@ 2002-12-07 14:09 ` SteveD
  2002-12-09  7:43   ` Multitasking arvids lemchens
  2002-12-07 14:10 ` Multitasking Michal Nowak
  2002-12-07 21:33 ` Multitasking Dennis Lee Bieber
  2 siblings, 1 reply; 12+ messages in thread
From: SteveD @ 2002-12-07 14:09 UTC (permalink / raw)


"arvids lemchens" <lemchens@lemmies.lb.bawue.de> wrote in message
news:8bRwOT7FACB@lemmies.lb.bawue.de...
[snip]
>
> 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?
>
While I'm not certain what you're expecting, the output is exactly what I
expect (and get on Gnat 3.15p on W2K).

During the rendevous, the part between "accept S" and "end S" in your task,
the environment task and Tc do not proceed independently.  If you want them
to do so change the code to look something like:

         select
            accept S (
                  D : in     Positive ) do
               Local_D := D;
            end S;
            delay Standard.Duration(Local_D);
            Put("Task S finished at ");
            Put(Long_Long_Integer(Seconds(Clock)));
            New_Line;
         or

where Local_D is defined as a Positive that is local to the task.

If you're wondering why the program doesn't terminate immediately, the
environment task will not terminate until the dependent tasks terminate,
which happens when your task finishes the delay.

SteveD

> Am i missing something fundamental about ada-tasks?
>
> If yes, what and how do i get them running independent?
>
> If it matters, i am using the linuxversion of gnat 3.14p.
>
>
> MvfG,
>
> Arvids
>
>
>
>





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Multitasking
  2002-12-07 12:16 Multitasking arvids lemchens
  2002-12-07 14:09 ` Multitasking SteveD
@ 2002-12-07 14:10 ` Michal Nowak
  2002-12-09  9:57   ` Multitasking arvids lemchens
  2002-12-07 21:33 ` Multitasking Dennis Lee Bieber
  2 siblings, 1 reply; 12+ messages in thread
From: Michal Nowak @ 2002-12-07 14:10 UTC (permalink / raw)


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




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Multitasking
  2002-12-07 12:16 Multitasking arvids lemchens
  2002-12-07 14:09 ` Multitasking SteveD
  2002-12-07 14:10 ` Multitasking Michal Nowak
@ 2002-12-07 21:33 ` Dennis Lee Bieber
  2002-12-08  0:17   ` Multitasking Dennis Lee Bieber
  2 siblings, 1 reply; 12+ messages in thread
From: Dennis Lee Bieber @ 2002-12-07 21:33 UTC (permalink / raw)


arvids lemchens fed this fish to the penguins on Saturday 07 December 
2002 04:16 am:

> type TCPtr is access TC;
> type TList is array (Positive range <>) of TCPtr;
> CList : TList(1..10000);
>
        Let's see, you create an array of pointers capable of accessing 10_000 
copies of the task...
 
> begin
>    CList(1) := new TC;

        But you only create ONE task in the main body

>    Put("Start Task S at: ");
>    Put(Long_Long_Integer(Seconds(Clock)));
>    New_Line;
>    CList(1).S(60);

        You then call a rendezvous entry, which means main body holds here 
until the task exits the accept block -- but the accept block contains 
a delay statement so both the main body and the task basically do 
nothing for a while, then the task does its output and finishes the 
accept block, at which point the main body continues (and the task goes 
back to waiting for another entry call to be made).

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

        And now you make a second rendezvous with the SAME task.

>    Put("End Task U ");
>    Put(Long_Long_Integer(Seconds(Clock)));
>    New_Line;
> end tt;


        Looks like it's doing just what you asked for (which may not be what 
you meant).

        The following hacked version of your code (and I see that if I do much 
Ada work in Mandrake I'm going to have to figure out how to set the 
default vim tab stops to 4)


with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Long_Long_Integer_Text_IO; use Ada.Long_Long_Integer_Text_IO;

Procedure tt is

        task type TC is
                entry S(D : Positive);
        end TC;

        task body TC is
                delayID : Positive;
        begin
                Put("a TC task has initiated");
                New_Line;
                loop
                        select
                                Accept S(D : In Positive) do
                                        delayID := D;
                                end S;
                        or
                                terminate;
                        end select;
                        
                        delay Standard.duration(delayID);

                        Put("Task ");
                        Put(Long_Long_Integer(delayID));
                        Put(" has finished at ");
                        Put(Long_Long_Integer(Seconds(Clock)));
                        New_Line;
                end loop;
        end TC;

        TC_one, TC_two : TC;

begin
        Put("Start Task TC_one at: ");
        Put(Long_Long_Integer(Seconds(Clock)));
        New_Line;
        TC_one.S(120);
        
        Put("Start Task TC_two at: ");
        Put(Long_Long_Integer(Seconds(Clock)));
        New_Line;
        TC_two.S(60);
        
        Put("Both tasks should be running");
        New_Line;
end tt;


generates the following output:

[wulfraed@beastie wulfraed]$ ./tt
a TC task has initiated
Start Task TC_one at:                48526
Start Task TC_two at:                48526
a TC task has initiated
Both tasks should be running
Task                   60 has finished at                48586
Task                  120 has finished at                48646

        Note: I get lucky, and the I/O overlap managed to appear at the 
newlines, but with slightly different overhead, it is possible that the 
"a TC task has initiated" could appear between the "... at:     " and " 
    <clock>" output.

        Also note that I made TC_one run for the longer period of time <G>


-- 
 > ============================================================== <
 >   wlfraed@ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed@dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Multitasking
  2002-12-07 21:33 ` Multitasking Dennis Lee Bieber
@ 2002-12-08  0:17   ` Dennis Lee Bieber
  2002-12-09  9:54     ` Multitasking arvids lemchens
  0 siblings, 1 reply; 12+ messages in thread
From: Dennis Lee Bieber @ 2002-12-08  0:17 UTC (permalink / raw)


Dennis Lee Bieber fed this fish to the penguins on Saturday 07 December 
2002 01:33 pm:


> [wulfraed@beastie wulfraed]$ ./tt
> a TC task has initiated
> Start Task TC_one at:                48526
> Start Task TC_two at:                48526

        Hmmm, using whole seconds (and why Long_Long yet?) hides some of the 
timing granularity. Let's try again with a bit more detail, and a 
second invocation of the entry calls so you can see the effect of a 
rendezvous blocking action.

        Try this one, which overlaps a few invocations to each task. (My 
apologies for the clumsy myPutFloat definition -- no doubt there is a 
more efficient way of doing the same without coding the fore/aft/exp 
arguments on all calls -- while I've always liked the language [did a 
presentation on Ada in my senior year, before the it had even been 
finalized as a DOD standard] I've never really /used/ the language).


with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;

Procedure tt is

        procedure myPutFloat(F : Float) is
        begin
                Put(F, Fore=>6, Aft=>5, Exp=>0);
        end;
        
        task type TC is
                entry S(D : Positive);
        end TC;

        task body TC is
                delayID : Positive;
        begin
                Put("a TC task has initiated at: ");
                myPutFloat(Float(Seconds(Clock)));
                New_Line;
                loop
                        select
                                Accept S(D : In Positive) do
                                        myPutFloat(Float(D));
                                        Put(" Accepted at: ");
                                        myPutFloat(Float(Seconds(Clock)));
                                        New_Line;
                                        delayID := D;
                                end S;
                        or
                                terminate;
                        end select;
                        
                        delay Standard.duration(delayID);

                        Put("Task ");
                        myPutFloat(Float(delayID));
                        Put(" has finished at ");
                        myPutFloat(Float(Seconds(Clock)));
                        New_Line;
                end loop;
        end TC;

        TC_one, TC_two : TC;

begin
        Put("Rendezvous Task TC_one at: ");
        myPutFloat(Float(Seconds(Clock)));
        New_Line;
        TC_one.S(120);
        
        Put("Rendezvous Task TC_two at: ");
        myPutFloat(Float(Seconds(Clock)));
        New_Line;
        TC_two.S(60);
        
        Put("Both tasks should be running");
        New_Line;

        Put("Rendezvous Task TC_two at: ");
        myPutFloat(Float(Seconds(Clock)));
        New_Line;
        TC_two.S(10);

        Put("Rendezvous Task TC_one at: ");
        myPutFloat(Float(Seconds(Clock)));
        New_Line;
        TC_one.S(20);

        Put("Rendezvous Task TC_two at: ");
        myPutFloat(Float(Seconds(Clock)));
        New_Line;
        TC_two.S(15);
        
        Put("Waiting for last task to finish");
        New_Line;
end tt;

        The results on my machine are:

[wulfraed@beastie ada]$ ./tt
a TC task has initiated at:  58287.18750
Rendezvous Task TC_one at:  58287.18750
   120.00000 Accepted at:  58287.18750
Rendezvous Task TC_two at:  58287.19141
a TC task has initiated at:  58287.19141
    60.00000 Accepted at:  58287.19141
Both tasks should be running
Rendezvous Task TC_two at:  58287.19141
Task     60.00000 has finished at  58347.19141
    10.00000 Accepted at:  58347.19141
Rendezvous Task TC_one at:  58347.19141
Task     10.00000 has finished at  58357.20313
Task    120.00000 has finished at  58407.19141
    20.00000 Accepted at:  58407.19141
Rendezvous Task TC_two at:  58407.19141
    15.00000 Accepted at:  58407.19141
Waiting for last task to finish
Task     15.00000 has finished at  58422.20313
Task     20.00000 has finished at  58427.20703


-- 
 > ============================================================== <
 >   wlfraed@ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed@dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Multitasking
  2002-12-07 14:09 ` Multitasking SteveD
@ 2002-12-09  7:43   ` arvids lemchens
  0 siblings, 0 replies; 12+ messages in thread
From: arvids lemchens @ 2002-12-09  7:43 UTC (permalink / raw)


Hello Steve,

nospam_steved94@attbi.com am 07.12.02 um 14:09 in comp.lang.ada:
>> 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
>> -----
> While I'm not certain what you're expecting, the output is exactly what I
> expect (and get on Gnat 3.15p on W2K).

I were expecting something like.

Start S     46831
End   S     46831
Start U     46831
End   U     46831
Task S Fin  46891
Task U Fin  47011

> During the rendevous, the part between "accept S" and "end S" in your  
task,
> the environment task and Tc do not proceed independently.  If you want them
> to do so change the code to look something like:

>          select
>            ...
>          or

Thanks, now i am starting to understand.

MvfG,

Arvids




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Multitasking
  2002-12-08  0:17   ` Multitasking Dennis Lee Bieber
@ 2002-12-09  9:54     ` arvids lemchens
  2002-12-09 20:48       ` Multitasking Dennis Lee Bieber
  0 siblings, 1 reply; 12+ messages in thread
From: arvids lemchens @ 2002-12-09  9:54 UTC (permalink / raw)


Hello Dennis,

wlfraed@ix.netcom.com am 07.12.02 um 16:17 in comp.lang.ada:
>> [wulfraed@beastie wulfraed]$ ./tt
>> a TC task has initiated
>> Start Task TC_one at:                48526
>> Start Task TC_two at:                48526
>         Hmmm, using whole seconds (and why Long_Long yet?) hides some of the
> timing granularity.

Thought first i will receive seconds from somewhere of the 1970's and
was not sure if int or long would be enough, so i decided for long_long.

And stayed with them.

>         Try this one, which overlaps a few invocations to each task.

Thanks, fine demonstration of the "problem".


MvfG,

Arvids




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Multitasking
  2002-12-07 14:10 ` Multitasking Michal Nowak
@ 2002-12-09  9:57   ` arvids lemchens
  2002-12-09 22:27     ` Multitasking Michal Nowak
  0 siblings, 1 reply; 12+ messages in thread
From: arvids lemchens @ 2002-12-09  9:57 UTC (permalink / raw)


Hello Micha,

vinnie@inetia.pl am 07.12.02 um 15:10 in comp.lang.ada:
>> 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.

Ok, know i am understanding.

>> Am i missing something fundamental about ada-tasks?
> It looks that you do (don't take this as offence :-))

I know, but now it's better. ... i hope so

>> If yes, what and how do i get them running independent?
> You did it. But what do you want to achieve with your code?

I was thinking about a monitoring application, where the
monitored items would be monitored by different tasks and
the main task only runs in a loop, triggering the tasks
and getting the results. So i stumbled on this issue.

Seems to be a better approach, to split the triggering/
monitoring and the resultholding in two different tasks.

MvfG,

Arvids




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Multitasking
  2002-12-09  9:54     ` Multitasking arvids lemchens
@ 2002-12-09 20:48       ` Dennis Lee Bieber
  2002-12-11 12:45         ` Multitasking John English
  0 siblings, 1 reply; 12+ messages in thread
From: Dennis Lee Bieber @ 2002-12-09 20:48 UTC (permalink / raw)


arvids lemchens fed this fish to the penguins on Monday 09 December 
2002 01:54 am:

> 
> Thought first i will receive seconds from somewhere of the 1970's and
> was not sure if int or long would be enough, so i decided for
> long_long.
> 
        From Ada.Calendar:

   subtype Day_Duration is Duration range 0.0 .. 86_400.0;

   function Clock return Time;

   function Year    (Date : Time) return Year_Number;
   function Month   (Date : Time) return Month_Number;
   function Day     (Date : Time) return Day_Number;
   function Seconds (Date : Time) return Day_Duration;


        Seconds() returns seconds (floating point) since midnight (which also 
means your program could show odd results if run during a midnight 
cross-over. To avoid that (and apologies to those seeing the code yet 
again) try:



with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;

Procedure tasktiming is

        runEpoch : Time := Clock;       -- initialize program start time

        procedure myPutFloat(F :Float) is
        begin
                Put(F, Fore=>6, Aft=>5, Exp=>0);
        end;
        
        task type TC is
                entry S(D : Positive);
        end TC;

        task body TC is
                delayID : Positive;
        begin
                Put("A TC task has initiated at:    ");
                myPutFloat(Float(Clock - runEpoch));
                New_Line;
                loop
                        select
                                Accept S(D : In Positive) do
                                        Put("Task ");
                                        myPutFloat(Float(D));
                                        Put(" Accepted at: ");
                                        myPutFloat(FLoat(Clock - runEpoch));
                                        -- yes, ugly use of a global
                                        New_Line;
                                        delayID := D;
                                end S;
                        or
                                terminate;
                        end select;
                        
                        delay Standard.duration(delayID);

                        Put("Task ");
                        myPutFloat(Float(delayID));
                        Put(" finished at: ");
                        myPutFloat(Float(Clock - runEpoch));
                        New_Line;
                end loop;
        end TC;

        TC_one, TC_two : TC;

begin
        Put("Rendezvous Task TC_one at:     ");
        myPutFloat(Float(Clock - runEpoch));
        New_Line;
        TC_one.S(120);
        
        Put("Rendezvous Task TC_two at:     ");
        myPutFloat(Float(Clock - runEpoch));
        New_Line;
        TC_two.S(60);
        
        Put("Both tasks should be running   ");
        New_Line;

        Put("Rendezvous Task TC_two at:     ");
        myPutFloat(Float(Clock - runEpoch));
        New_Line;
        TC_two.S(10);

        Put("Rendezvous Task TC_one at:     ");
        myPutFloat(Float(Clock - runEpoch));
        New_Line;
        TC_one.S(20);

        Put("Rendezvous Task TC_two at:     ");
        myPutFloat(Float(Clock - runEpoch));
        New_Line;
        TC_two.S(15);
        
        Put("Waiting for last task to finish");
        New_Line;
end TaskTiming;

which gives the output relative to the start of the program itself.

[wulfraed@beastie ada]$ ./tasktiming
A TC task has initiated at:         0.00055
Rendezvous Task TC_one at:          0.00095
Task    120.00000 Accepted at:      0.00136
Rendezvous Task TC_two at:          0.00163
A TC task has initiated at:         0.00192
Task     60.00000 Accepted at:      0.00229
Both tasks should be running
Rendezvous Task TC_two at:          0.00274
Task     60.00000 finished at:     60.00841
Task     10.00000 Accepted at:     60.00845
Rendezvous Task TC_one at:         60.00851
Task     10.00000 finished at:     70.01839
Task    120.00000 finished at:    120.00839
Task     20.00000 Accepted at:    120.00843
Rendezvous Task TC_two at:        120.00849
Task     15.00000 Accepted at:    120.00855
Waiting for last task to finish
Task     15.00000 finished at:    135.01839
Task     20.00000 finished at:    140.01839

-- 
 > ============================================================== <
 >   wlfraed@ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed@dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Multitasking
  2002-12-09  9:57   ` Multitasking arvids lemchens
@ 2002-12-09 22:27     ` Michal Nowak
  0 siblings, 0 replies; 12+ messages in thread
From: Michal Nowak @ 2002-12-09 22:27 UTC (permalink / raw)


On 2002-12-09 at 10:57 lemchens@lemmies.lb.bawue.de wrote:

>>> If yes, what and how do i get them running independent?
>> You did it. But what do you want to achieve with your code?
>
>I was thinking about a monitoring application, where the
>monitored items would be monitored by different tasks and
>the main task only runs in a loop, triggering the tasks
>and getting the results. So i stumbled on this issue.
>
>Seems to be a better approach, to split the triggering/
>monitoring and the resultholding in two different tasks.

It looks like a problem from real-time systems domain.
You may have some monitoring tasks running in an infinite
loop which read values from some device at constant time
intervals. Next, they may place the values in a buffer 
(think of using protected objects for that purpose). 
These tasks should not be blocked by accepting entries
or performing time-consuming operations (like console
I/O). Create also a task which will read the values 
from buffer and do something with them (for example
visualize them on the screen).

Happy tasking,
   - Michal


-- -----------------------------------------------------------------
--   ___        _
--  / _ \      | |                      I Choose Ada:
-- | |_| |  ___| |   _____   The Most Trusted Name in Software (TM)
-- |  _  | | __  |  | __  | 
-- |_| |_| |_____|_ |_____|_ http://www.adaic.org/whyada/choose.html
--
-- -----------------------------------------------------------------




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Multitasking
  2002-12-09 20:48       ` Multitasking Dennis Lee Bieber
@ 2002-12-11 12:45         ` John English
  2002-12-11 19:34           ` Multitasking Dennis Lee Bieber
  0 siblings, 1 reply; 12+ messages in thread
From: John English @ 2002-12-11 12:45 UTC (permalink / raw)


Dennis Lee Bieber wrote:
> Seconds() returns seconds (floating point) since midnight...
                             ^^^^^^^^^^^^^^
Fixed point, actually; Day_Duration is a subtype of Duration, the
only standard fixed-point type.

-----------------------------------------------------------------
 John English              | mailto:je@brighton.ac.uk
 Senior Lecturer           | http://www.it.bton.ac.uk/staff/je
 Dept. of Computing        | ** NON-PROFIT CD FOR CS STUDENTS **
 University of Brighton    |    -- see http://burks.bton.ac.uk
-----------------------------------------------------------------



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Multitasking
  2002-12-11 12:45         ` Multitasking John English
@ 2002-12-11 19:34           ` Dennis Lee Bieber
  0 siblings, 0 replies; 12+ messages in thread
From: Dennis Lee Bieber @ 2002-12-11 19:34 UTC (permalink / raw)


John English fed this fish to the penguins on Wednesday 11 December 
2002 04:45 am:

> Dennis Lee Bieber wrote:
>> Seconds() returns seconds (floating point) since midnight...
>                              ^^^^^^^^^^^^^^
> Fixed point, actually; Day_Duration is a subtype of Duration, the
> only standard fixed-point type.
>
        Blame it on my 20+ years of FORTRAN... I'd probably have been safer to 
refer to it as a "real".

-- 
 > ============================================================== <
 >   wlfraed@ix.netcom.com  | Wulfraed  Dennis Lee Bieber  KD6MOG <
 >      wulfraed@dm.net     |       Bestiaria Support Staff       <
 > ============================================================== <
 >        Bestiaria Home Page: http://www.beastie.dm.net/         <
 >            Home Page: http://www.dm.net/~wulfraed/             <




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2002-12-11 19:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` Multitasking Michal Nowak
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

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