comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: Task Scheduling
Date: Sun, 07 Jan 2007 15:49:26 +0100
Date: 2007-01-07T15:49:26+01:00	[thread overview]
Message-ID: <873b6mc2o9.fsf@ludovic-brenta.org> (raw)
In-Reply-To: mailman.13.1168180123.18371.comp.lang.ada@ada-france.org

jpluto writes:
> A questions please:
>
> I am trying to solve a problem, and I am not sure how to code it.
>
> For example, if I have three arbitrary tasks, task1 has a priority
> than task2.
> Therefore, task1 will always preempt task2 and task3.
>
> However, if task2 ran first and locked a shared data resource that is
> shared with ONLY task3 and NOT task1.  Then if task1 arrives, I want
> task1 to yield the processor to task2 until task2 is finished using
> the resource even though task1 has the highest priority.
>
> The problem, task1 has a higher priority and does NOT use this shared
> resource.
> How can I ask this task1 not to run, and to wait whenever this shared
> resource is locked by task2 or task3?
>
> If you cannot think of a solution, then is there a way to use Timing
> Events to stop task1 whenever it is running? If so, could you show me
> the code to do it?
>
> I do not think this would be a great solution since there is an
> overhead of context switching since task1 is run and we have then to
> tell it to stop, but at least if you can help, it is still a solution
> to my problem.
>
> Thank you very much
> Jane

So, task1 does not use the shared resource, but must wait while task2
uses the shared resource, right?  I'm not sure I understand why this
is so.  I suspect a design flaw, but cannot tell for sure.  Could you
please explain why task1 needs to block at all, if it doesn't use the
shared resource?

Anyway, it seems that priority ceiling locking (see ARM D.3) would do
what you want, but only on a uniprocessor machine.

* task1 would have priority 2.
* task2 and task3 would have priority 1.
* The protected object would have priority 3, and use priority ceiling
  locking.

While task2 or task3 holds the protected object, they inherit priority
3 from the protected object, and therefore task1 cannot preempt them.

An alternative, working on both uniprocessors and multiprocessors,
would be for task2 to call Ada.Asynchronous_Task_Control.Hold to stop
task1, and Ada.Asynchronous_Task_Control.Continue to resume it.  But
that reeks of a design flaw, as I said above.

HTH

-- 
Ludovic Brenta.



  reply	other threads:[~2007-01-07 14:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-07 14:28 Task Scheduling   jpluto
2007-01-07 14:49 ` Ludovic Brenta [this message]
2007-01-07 20:47 ` Jeffrey Creem
replies disabled

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