comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: multiple delay alternative
Date: Tue, 6 Mar 2018 14:06:03 -0600
Date: 2018-03-06T14:06:03-06:00	[thread overview]
Message-ID: <p7msbb$riu$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: 212bf1a1-1bcc-4474-b1f6-b98c1461ff07@googlegroups.com

"Mehdi Saada" <00120260a@gmail.com> wrote in message 
news:212bf1a1-1bcc-4474-b1f6-b98c1461ff07@googlegroups.com...
>>> Functions are like procedures except that logically allowed to run 
>>> parallel to each other.

> Ok, but aren't calls on protected procedures blocked when other tasks is 
> executing them ?

Not necessarily. On a monoprocessor, you are right in that waiting is 
essentially the same as blocking (the current task has to be suspended so 
that the protected operation can run and complete).

But on a multiprocessor, this is different as the protected operation is 
actively running on a different thread. So the task that is waiting is doing 
literally that, waiting for the lock to change. This does not necessarily 
cause the task to be suspended, it's not an abort point, and so on. It's 
often just a loop:

      while not Protected.Lock loop
           null; -- Possibly waste some time here.
      end loop;

In a properly designed protected object, the time of operations will be 
short and this will not waste significant processing time. (And it doesn't 
happen that much in practice, tasks usually are doing other things than 
calling POs.) So just wasting time in this way is the often the most 
efficient thing to do, as blocking (which requires a full context switch) is 
rather expensive.

                                   Randy.



      parent reply	other threads:[~2018-03-06 20:06 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-04 18:22 multiple delay alternative Mehdi Saada
2018-03-05  0:21 ` Mehdi Saada
2018-03-05  4:08 ` Bojan Bozovic
2018-03-05 10:17   ` Robert Eachus
2018-03-05  8:15 ` Dmitry A. Kazakov
2018-03-05  9:23 ` AdaMagica
2018-03-05 10:32 ` Bojan Bozovic
2018-03-05 13:50 ` Mehdi Saada
2018-03-05 14:35   ` Dmitry A. Kazakov
2018-03-05 15:09     ` Mehdi Saada
2018-03-06 11:05       ` Dmitry A. Kazakov
2018-03-05 17:37   ` Jeffrey R. Carter
2018-03-05 23:28 ` Simon Wright
2018-03-06  0:11   ` Anh Vo
2018-03-06  1:50 ` Mehdi Saada
2018-03-06  6:00   ` Robert Eachus
2018-03-06  6:03   ` J-P. Rosen
2018-03-06 16:36   ` Jeffrey R. Carter
2018-03-06 10:31 ` Mehdi Saada
2018-03-06 11:18   ` Dmitry A. Kazakov
2018-03-06 13:43     ` Mehdi Saada
2018-03-06 15:17       ` Dmitry A. Kazakov
2018-03-06 20:06       ` Randy Brukardt [this message]
replies disabled

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